@@ -96,6 +96,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
96
96
97
97
// / A list of replaceable fwddecls that need to be RAUWed at the end.
98
98
std::vector<std::pair<TypeBase *, llvm::TrackingMDRef>> ReplaceMap;
99
+ // / The set of imported modules.
100
+ llvm::DenseSet<ModuleDecl::ImportedModule> ImportedModules;
99
101
100
102
llvm::BumpPtrAllocator DebugInfoNames;
101
103
StringRef CWDName; // / The current working directory.
@@ -1550,6 +1552,15 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
1550
1552
void IRGenDebugInfoImpl::finalize () {
1551
1553
assert (LocationStack.empty () && " Mismatch of pushLoc() and popLoc()." );
1552
1554
1555
+ // Get the list of imported modules (which may actually be different
1556
+ // from all ImportDecls).
1557
+ SmallVector<ModuleDecl::ImportedModule, 8 > ModuleWideImports;
1558
+ IGM.getSwiftModule ()->getImportedModules (ModuleWideImports,
1559
+ ModuleDecl::ImportFilter::All);
1560
+ for (auto M : ModuleWideImports)
1561
+ if (!ImportedModules.count (M))
1562
+ DBuilder.createImportedModule (MainFile, getOrCreateModule (M), 0 );
1563
+
1553
1564
// Finalize all replaceable forward declarations.
1554
1565
for (auto &Ty : ReplaceMap) {
1555
1566
llvm::TempMDNode FwdDecl (cast<llvm::MDNode>(Ty.second ));
@@ -1716,9 +1727,11 @@ void IRGenDebugInfoImpl::emitImport(ImportDecl *D) {
1716
1727
assert (M && " Could not find module for import decl." );
1717
1728
return ;
1718
1729
}
1719
- auto DIMod = getOrCreateModule ({D->getModulePath (), M});
1730
+ ModuleDecl::ImportedModule Imported = {D->getModulePath (), M};
1731
+ auto DIMod = getOrCreateModule (Imported);
1720
1732
auto L = getDebugLoc (*this , D);
1721
1733
DBuilder.createImportedModule (getOrCreateFile (L.Filename ), DIMod, L.Line );
1734
+ ImportedModules.insert (Imported);
1722
1735
}
1723
1736
1724
1737
llvm::DISubprogram *IRGenDebugInfoImpl::emitFunction (SILFunction &SILFn,
0 commit comments