Load modules using real names if module aliases are used

rdar://83591943
This commit is contained in:
elsh
2021-09-30 14:05:45 -07:00
parent 140c02466a
commit 55b9fa11d8
5 changed files with 65 additions and 10 deletions

View File

@@ -1739,7 +1739,13 @@ bool ExplicitSwiftModuleLoader::findModule(ImportPath::Element ModuleID,
std::unique_ptr<llvm::MemoryBuffer> *ModuleDocBuffer,
std::unique_ptr<llvm::MemoryBuffer> *ModuleSourceInfoBuffer,
bool skipBuildingInterface, bool &IsFramework, bool &IsSystemModule) {
StringRef moduleName = ModuleID.Item.str();
// Find a module with an actual, physical name on disk, in case
// -module-alias is used (otherwise same).
//
// For example, if '-module-alias Foo=Bar' is passed in to the frontend, and an
// input file has 'import Foo', a module called Bar (real name) should be searched.
StringRef moduleName = Ctx.getRealModuleName(ModuleID.Item).str();
auto it = Impl.ExplicitModuleMap.find(moduleName);
// If no explicit module path is given matches the name, return with an
// error code.