Always add an implicit import of 'Cxx' module when C++ Interop is enabled.

We cannot always rely on being able to do so only as an overlay query upon loading 'requires cplusplus' modulemap modules. The 'requires' statement only applies to submodules, and we may not be able to query language feature modulemap attributes in dependency scanning context.
This commit is contained in:
Artem Chikin
2024-02-13 14:14:28 -08:00
committed by artemcm
parent eb1c0e71d8
commit 6ea604bf9f
5 changed files with 24 additions and 7 deletions

View File

@@ -392,7 +392,7 @@ std::error_code SerializedModuleLoaderBase::openModuleFile(
return std::error_code();
}
SerializedModuleLoaderBase::BinaryModuleImports
llvm::ErrorOr<SerializedModuleLoaderBase::BinaryModuleImports>
SerializedModuleLoaderBase::getImportsOfModule(
const ModuleFileSharedCore &loadedModuleFile,
ModuleLoadingBehavior transitiveBehavior, StringRef packageName,
@@ -484,7 +484,7 @@ SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework,
getImportsOfModule(*loadedModuleFile, ModuleLoadingBehavior::Optional,
Ctx.LangOpts.PackageName, isTestableImport);
auto importedModuleSet = binaryModuleImports.moduleImports;
auto importedModuleSet = binaryModuleImports->moduleImports;
std::vector<std::string> importedModuleNames;
importedModuleNames.reserve(importedModuleSet.size());
llvm::transform(importedModuleSet.keys(),
@@ -493,8 +493,8 @@ SerializedModuleLoaderBase::scanModuleFile(Twine modulePath, bool isFramework,
return N.str();
});
auto importedHeader = binaryModuleImports.headerImport;
auto &importedOptionalModuleSet = binaryModuleOptionalImports.moduleImports;
auto importedHeader = binaryModuleImports->headerImport;
auto &importedOptionalModuleSet = binaryModuleOptionalImports->moduleImports;
std::vector<std::string> importedOptionalModuleNames;
for (const auto optionalImportedModule : importedOptionalModuleSet.keys())
if (!importedModuleSet.contains(optionalImportedModule))