[interop][sourcekit] report a module error for any unconditional module loading failure

This ensures that interface gen reports an error when importing a framework Swift module
that also imports the underlying C++ module into Swift, when interop is disabled, so that
we can retry the interface gen with interop enabled.
This commit is contained in:
Alex Lorenz
2023-03-30 11:05:31 -07:00
parent 2b31287b35
commit 3b143d7d4e
2 changed files with 37 additions and 2 deletions

View File

@@ -287,9 +287,12 @@ static bool getModuleInterfaceInfo(ASTContext &Ctx,
ErrMsg += ModuleName;
return true;
}
if (Mod->failedToLoad() && ModuleName == "CxxStdlib") {
if (Mod->failedToLoad()) {
// We might fail to load the underlying Clang module
// for a Swift overlay module like 'CxxStdlib'. Make sure an error is reported in this case, so that we can either retry to load with C++ interoperability enabled, and if that fails, we can report this to the user.
// for a Swift overlay module like 'CxxStdlib', or a mixed-language
// framework. Make sure an error is reported in this case, so that we can
// either retry to load with C++ interoperability enabled, and if that
// fails, we can report this to the user.
ErrMsg = "Could not load underlying module for: ";
ErrMsg += ModuleName;
return true;