@@ -1926,20 +1926,26 @@ bool ClangImporter::canImportModule(ImportPath::Module modulePath,
1926
1926
ModuleDecl *ClangImporter::Implementation::loadModuleClang (
1927
1927
SourceLoc importLoc, ImportPath::Module path) {
1928
1928
auto &clangHeaderSearch = getClangPreprocessor ().getHeaderSearchInfo ();
1929
+ auto realModuleName = SwiftContext.getRealModuleName (path.front ().Item ).str ();
1929
1930
1930
1931
// Look up the top-level module first, to see if it exists at all.
1931
1932
clang::Module *clangModule = clangHeaderSearch.lookupModule (
1932
- path. front (). Item . str () , /* ImportLoc=*/ clang::SourceLocation (),
1933
+ realModuleName , /* ImportLoc=*/ clang::SourceLocation (),
1933
1934
/* AllowSearch=*/ true , /* AllowExtraModuleMapSearch=*/ true );
1934
1935
if (!clangModule)
1935
1936
return nullptr ;
1936
1937
1937
1938
// Convert the Swift import path over to a Clang import path.
1938
1939
SmallVector<std::pair<clang::IdentifierInfo *, clang::SourceLocation>, 4 >
1939
1940
clangPath;
1941
+ bool isTopModuleComponent = true ;
1940
1942
for (auto component : path) {
1943
+ StringRef item = isTopModuleComponent? realModuleName:
1944
+ component.Item .str ();
1945
+ isTopModuleComponent = false ;
1946
+
1941
1947
clangPath.emplace_back (
1942
- getClangPreprocessor ().getIdentifierInfo (component. Item . str () ),
1948
+ getClangPreprocessor ().getIdentifierInfo (item ),
1943
1949
exportSourceLoc (component.Loc ));
1944
1950
}
1945
1951
0 commit comments