Report cannot load submodule if only able to load top module

For loaders that don't support loading submodules, canImportModule should report false instead of checking if can import top module.
This commit is contained in:
Apollo Zhu
2022-01-08 18:11:43 -08:00
parent 16d204bc51
commit 1f77f46e4f
3 changed files with 9 additions and 3 deletions

View File

@@ -1133,6 +1133,9 @@ swift::extractUserModuleVersionFromInterface(StringRef moduleInterfacePath) {
bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
llvm::VersionTuple version,
bool underlyingVersion) {
// FIXME: Swift submodules?
if (path.hasSubmodule())
return false;
// If underlying version is specified, this should be handled by Clang importer.
if (!version.empty() && underlyingVersion)
return false;
@@ -1153,7 +1156,6 @@ bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
unusedModuleDocBuffer = &moduleDocBuffer;
}
// FIXME: Swift submodules?
auto mID = path[0];
auto found = findModule(mID, unusedModuleInterfacePath, unusedModuleBuffer,
unusedModuleDocBuffer, unusedModuleSourceInfoBuffer,
@@ -1192,10 +1194,12 @@ bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
bool MemoryBufferSerializedModuleLoader::canImportModule(
ImportPath::Module path, llvm::VersionTuple version,
bool underlyingVersion) {
// FIXME: Swift submodules?
if (path.hasSubmodule())
return false;
// If underlying version is specified, this should be handled by Clang importer.
if (!version.empty() && underlyingVersion)
return false;
// FIXME: Swift submodules?
auto mID = path[0];
auto mIt = MemoryBuffers.find(mID.Item.str());
if (mIt == MemoryBuffers.end())