mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Debug Info: Generate imported entities for implicitly imported parent modules.
The Swift compiler uses an ugly hack that auto-imports a submodule's top-level-module, even if we didn't ask for it. Reflect that in the debug info. <rdar://problem/31310320>
This commit is contained in:
@@ -96,6 +96,8 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
|
|||||||
|
|
||||||
/// A list of replaceable fwddecls that need to be RAUWed at the end.
|
/// A list of replaceable fwddecls that need to be RAUWed at the end.
|
||||||
std::vector<std::pair<TypeBase *, llvm::TrackingMDRef>> ReplaceMap;
|
std::vector<std::pair<TypeBase *, llvm::TrackingMDRef>> ReplaceMap;
|
||||||
|
/// The set of imported modules.
|
||||||
|
llvm::DenseSet<ModuleDecl::ImportedModule> ImportedModules;
|
||||||
|
|
||||||
llvm::BumpPtrAllocator DebugInfoNames;
|
llvm::BumpPtrAllocator DebugInfoNames;
|
||||||
StringRef CWDName; /// The current working directory.
|
StringRef CWDName; /// The current working directory.
|
||||||
@@ -1550,6 +1552,15 @@ IRGenDebugInfoImpl::IRGenDebugInfoImpl(const IRGenOptions &Opts,
|
|||||||
void IRGenDebugInfoImpl::finalize() {
|
void IRGenDebugInfoImpl::finalize() {
|
||||||
assert(LocationStack.empty() && "Mismatch of pushLoc() and popLoc().");
|
assert(LocationStack.empty() && "Mismatch of pushLoc() and popLoc().");
|
||||||
|
|
||||||
|
// Get the list of imported modules (which may actually be different
|
||||||
|
// from all ImportDecls).
|
||||||
|
SmallVector<ModuleDecl::ImportedModule, 8> ModuleWideImports;
|
||||||
|
IGM.getSwiftModule()->getImportedModules(ModuleWideImports,
|
||||||
|
ModuleDecl::ImportFilter::All);
|
||||||
|
for (auto M : ModuleWideImports)
|
||||||
|
if (!ImportedModules.count(M))
|
||||||
|
DBuilder.createImportedModule(MainFile, getOrCreateModule(M), 0);
|
||||||
|
|
||||||
// Finalize all replaceable forward declarations.
|
// Finalize all replaceable forward declarations.
|
||||||
for (auto &Ty : ReplaceMap) {
|
for (auto &Ty : ReplaceMap) {
|
||||||
llvm::TempMDNode FwdDecl(cast<llvm::MDNode>(Ty.second));
|
llvm::TempMDNode FwdDecl(cast<llvm::MDNode>(Ty.second));
|
||||||
@@ -1716,9 +1727,11 @@ void IRGenDebugInfoImpl::emitImport(ImportDecl *D) {
|
|||||||
assert(M && "Could not find module for import decl.");
|
assert(M && "Could not find module for import decl.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto DIMod = getOrCreateModule({D->getModulePath(), M});
|
ModuleDecl::ImportedModule Imported = {D->getModulePath(), M};
|
||||||
|
auto DIMod = getOrCreateModule(Imported);
|
||||||
auto L = getDebugLoc(*this, D);
|
auto L = getDebugLoc(*this, D);
|
||||||
DBuilder.createImportedModule(getOrCreateFile(L.Filename), DIMod, L.Line);
|
DBuilder.createImportedModule(getOrCreateFile(L.Filename), DIMod, L.Line);
|
||||||
|
ImportedModules.insert(Imported);
|
||||||
}
|
}
|
||||||
|
|
||||||
llvm::DISubprogram *IRGenDebugInfoImpl::emitFunction(SILFunction &SILFn,
|
llvm::DISubprogram *IRGenDebugInfoImpl::emitFunction(SILFunction &SILFn,
|
||||||
|
|||||||
@@ -10,7 +10,12 @@
|
|||||||
// CHECK-SAME: configMacros:
|
// CHECK-SAME: configMacros:
|
||||||
// CHECK-SAME: {{..}}-DFOO=foo{{..}}
|
// CHECK-SAME: {{..}}-DFOO=foo{{..}}
|
||||||
// CHECK-SAME: {{..}}-UBAR{{..}}
|
// CHECK-SAME: {{..}}-UBAR{{..}}
|
||||||
|
|
||||||
// CHECK: !DIImportedEntity({{.*}}, entity: ![[SUBMODULE]], line: [[@LINE+1]])
|
// CHECK: !DIImportedEntity({{.*}}, entity: ![[SUBMODULE]], line: [[@LINE+1]])
|
||||||
import ClangModule.SubModule
|
import ClangModule.SubModule
|
||||||
|
|
||||||
|
// The Swift compiler uses an ugly hack that auto-imports a
|
||||||
|
// submodule's top-level-module, even if we didn't ask for it.
|
||||||
|
// CHECK: !DIImportedEntity({{.*}}, entity: ![[CLANGMODULE]])
|
||||||
|
|
||||||
let bar = Bar()
|
let bar = Bar()
|
||||||
|
|||||||
Reference in New Issue
Block a user