Skip to content

Commit ea2f222

Browse files
committed
[ClangImporter] Support loading clang modules that are aliased
1 parent f184504 commit ea2f222

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,20 +1926,26 @@ bool ClangImporter::canImportModule(ImportPath::Module modulePath,
19261926
ModuleDecl *ClangImporter::Implementation::loadModuleClang(
19271927
SourceLoc importLoc, ImportPath::Module path) {
19281928
auto &clangHeaderSearch = getClangPreprocessor().getHeaderSearchInfo();
1929+
auto realModuleName = SwiftContext.getRealModuleName(path.front().Item).str();
19291930

19301931
// Look up the top-level module first, to see if it exists at all.
19311932
clang::Module *clangModule = clangHeaderSearch.lookupModule(
1932-
path.front().Item.str(), /*ImportLoc=*/clang::SourceLocation(),
1933+
realModuleName, /*ImportLoc=*/clang::SourceLocation(),
19331934
/*AllowSearch=*/true, /*AllowExtraModuleMapSearch=*/true);
19341935
if (!clangModule)
19351936
return nullptr;
19361937

19371938
// Convert the Swift import path over to a Clang import path.
19381939
SmallVector<std::pair<clang::IdentifierInfo *, clang::SourceLocation>, 4>
19391940
clangPath;
1941+
bool isTopModuleComponent = true;
19401942
for (auto component : path) {
1943+
StringRef item = isTopModuleComponent? realModuleName:
1944+
component.Item.str();
1945+
isTopModuleComponent = false;
1946+
19411947
clangPath.emplace_back(
1942-
getClangPreprocessor().getIdentifierInfo(component.Item.str()),
1948+
getClangPreprocessor().getIdentifierInfo(item),
19431949
exportSourceLoc(component.Loc));
19441950
}
19451951

0 commit comments

Comments
 (0)