Skip to content

Commit d256fcc

Browse files
committed
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.
1 parent dd7aebf commit d256fcc

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/Frontend/ModuleInterfaceLoader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,8 @@ bool ExplicitSwiftModuleLoader::canImportModule(ImportPath::Module path,
18321832
llvm::VersionTuple version,
18331833
bool underlyingVersion) {
18341834
// FIXME: Swift submodules?
1835+
if (path.hasSubmodule())
1836+
return false;
18351837
ImportPath::Element mID = path.front();
18361838
// Look up the module with the real name (physical name on disk);
18371839
// in case `-module-alias` is used, the name appearing in source files

lib/Sema/SourceLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ bool SourceLoader::canImportModule(ImportPath::Module path,
7373
llvm::VersionTuple version,
7474
bool underlyingVersion) {
7575
// FIXME: Swift submodules?
76-
if (path.size() > 1)
76+
if (path.hasSubmodule())
7777
return false;
7878

7979
auto ID = path[0];

lib/Serialization/SerializedModuleLoader.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,9 @@ swift::extractUserModuleVersionFromInterface(StringRef moduleInterfacePath) {
11261126
bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
11271127
llvm::VersionTuple version,
11281128
bool underlyingVersion) {
1129+
// FIXME: Swift submodules?
1130+
if (path.hasSubmodule())
1131+
return false;
11291132
// If underlying version is specified, this should be handled by Clang importer.
11301133
if (!version.empty() && underlyingVersion)
11311134
return false;
@@ -1146,7 +1149,6 @@ bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
11461149
unusedModuleDocBuffer = &moduleDocBuffer;
11471150
}
11481151

1149-
// FIXME: Swift submodules?
11501152
auto mID = path[0];
11511153
auto found = findModule(mID, unusedModuleInterfacePath, unusedModuleBuffer,
11521154
unusedModuleDocBuffer, unusedModuleSourceInfoBuffer,
@@ -1185,10 +1187,12 @@ bool SerializedModuleLoaderBase::canImportModule(ImportPath::Module path,
11851187
bool MemoryBufferSerializedModuleLoader::canImportModule(
11861188
ImportPath::Module path, llvm::VersionTuple version,
11871189
bool underlyingVersion) {
1190+
// FIXME: Swift submodules?
1191+
if (path.hasSubmodule())
1192+
return false;
11881193
// If underlying version is specified, this should be handled by Clang importer.
11891194
if (!version.empty() && underlyingVersion)
11901195
return false;
1191-
// FIXME: Swift submodules?
11921196
auto mID = path[0];
11931197
auto mIt = MemoryBuffers.find(mID.Item.str());
11941198
if (mIt == MemoryBuffers.end())

0 commit comments

Comments
 (0)