@@ -660,6 +660,24 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
660
660
isa<ConstructorDecl>(DeclCtx);
661
661
}
662
662
663
+ void createImportedModule (llvm::DIScope *Context,
664
+ ModuleDecl::ImportedModule M, llvm::DIFile *File,
665
+ unsigned Line) {
666
+ // For overlays of Clang modules also emit an import of the underlying Clang
667
+ // module. The helps the debugger resolve types that are present only in the
668
+ // underlying module.
669
+ if (const clang::Module *UnderlyingClangModule =
670
+ M.importedModule ->findUnderlyingClangModule ()) {
671
+ DBuilder.createImportedModule (
672
+ Context,
673
+ getOrCreateModule (
674
+ {*const_cast <clang::Module *>(UnderlyingClangModule)},
675
+ UnderlyingClangModule),
676
+ File, 0 );
677
+ }
678
+ DBuilder.createImportedModule (Context, getOrCreateModule (M), File, Line);
679
+ }
680
+
663
681
llvm::DIModule *getOrCreateModule (const void *Key, llvm::DIScope *Parent,
664
682
StringRef Name, StringRef IncludePath,
665
683
uint64_t Signature = ~1ULL ,
@@ -1871,8 +1889,7 @@ void IRGenDebugInfoImpl::finalize() {
1871
1889
ModuleDecl::ImportFilterKind::ImplementationOnly});
1872
1890
for (auto M : ModuleWideImports)
1873
1891
if (!ImportedModules.count (M.importedModule ))
1874
- DBuilder.createImportedModule (MainFile, getOrCreateModule (M), MainFile,
1875
- 0 );
1892
+ createImportedModule (MainFile, M, MainFile, 0 );
1876
1893
1877
1894
// Finalize all replaceable forward declarations.
1878
1895
for (auto &Ty : ReplaceMap) {
@@ -2113,10 +2130,9 @@ void IRGenDebugInfoImpl::emitImport(ImportDecl *D) {
2113
2130
2114
2131
assert (D->getModule () && " compiler-synthesized ImportDecl is incomplete" );
2115
2132
ModuleDecl::ImportedModule Imported = { D->getAccessPath (), D->getModule () };
2116
- auto DIMod = getOrCreateModule (Imported);
2117
2133
auto L = getDebugLoc (*this , D);
2118
2134
auto *File = getOrCreateFile (L.Filename );
2119
- DBuilder. createImportedModule (File, DIMod , File, L.Line );
2135
+ createImportedModule (File, Imported , File, L.Line );
2120
2136
ImportedModules.insert (Imported.importedModule );
2121
2137
}
2122
2138
0 commit comments