@@ -660,6 +660,24 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
660660 isa<ConstructorDecl>(DeclCtx);
661661 }
662662
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+
663681 llvm::DIModule *getOrCreateModule (const void *Key, llvm::DIScope *Parent,
664682 StringRef Name, StringRef IncludePath,
665683 uint64_t Signature = ~1ULL ,
@@ -1871,8 +1889,7 @@ void IRGenDebugInfoImpl::finalize() {
18711889 ModuleDecl::ImportFilterKind::ImplementationOnly});
18721890 for (auto M : ModuleWideImports)
18731891 if (!ImportedModules.count (M.importedModule ))
1874- DBuilder.createImportedModule (MainFile, getOrCreateModule (M), MainFile,
1875- 0 );
1892+ createImportedModule (MainFile, M, MainFile, 0 );
18761893
18771894 // Finalize all replaceable forward declarations.
18781895 for (auto &Ty : ReplaceMap) {
@@ -2113,10 +2130,9 @@ void IRGenDebugInfoImpl::emitImport(ImportDecl *D) {
21132130
21142131 assert (D->getModule () && " compiler-synthesized ImportDecl is incomplete" );
21152132 ModuleDecl::ImportedModule Imported = { D->getAccessPath (), D->getModule () };
2116- auto DIMod = getOrCreateModule (Imported);
21172133 auto L = getDebugLoc (*this , D);
21182134 auto *File = getOrCreateFile (L.Filename );
2119- DBuilder. createImportedModule (File, DIMod , File, L.Line );
2135+ createImportedModule (File, Imported , File, L.Line );
21202136 ImportedModules.insert (Imported.importedModule );
21212137}
21222138
0 commit comments