forked from OSchip/llvm-project
Module Debugging: Emit submodules as nested DW_TAG_modules.
llvm-svn: 248511
This commit is contained in:
parent
eb66a263c2
commit
835e6633ab
|
@ -159,7 +159,7 @@ public:
|
|||
: PCHModuleName(std::move(Name)), Path(std::move(Path)),
|
||||
ASTFile(std::move(ASTFile)), Signature(Signature){};
|
||||
ASTSourceDescriptor(const Module &M);
|
||||
std::string getFullModuleName() const;
|
||||
std::string getModuleName() const;
|
||||
StringRef getPath() const { return Path; }
|
||||
StringRef getASTFile() const { return ASTFile; }
|
||||
uint64_t getSignature() const { return Signature; }
|
||||
|
|
|
@ -36,9 +36,9 @@ ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M)
|
|||
ASTFile = File->getName();
|
||||
}
|
||||
|
||||
std::string ExternalASTSource::ASTSourceDescriptor::getFullModuleName() const {
|
||||
std::string ExternalASTSource::ASTSourceDescriptor::getModuleName() const {
|
||||
if (ClangModule)
|
||||
return ClangModule->getFullModuleName();
|
||||
return ClangModule->Name;
|
||||
else
|
||||
return PCHModuleName;
|
||||
}
|
||||
|
|
|
@ -1707,18 +1707,23 @@ CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod,
|
|||
}
|
||||
}
|
||||
|
||||
std::string FullModuleName = Mod.getFullModuleName();
|
||||
if (CreateSkeletonCU) {
|
||||
bool IsRootModule = M ? !M->Parent : true;
|
||||
if (CreateSkeletonCU && IsRootModule) {
|
||||
llvm::DIBuilder DIB(CGM.getModule());
|
||||
DIB.createCompileUnit(TheCU->getSourceLanguage(), FullModuleName,
|
||||
DIB.createCompileUnit(TheCU->getSourceLanguage(), Mod.getModuleName(),
|
||||
Mod.getPath(), TheCU->getProducer(), true,
|
||||
StringRef(), 0, Mod.getASTFile(),
|
||||
llvm::DIBuilder::FullDebug, Mod.getSignature());
|
||||
DIB.finalize();
|
||||
}
|
||||
llvm::DIModule *Parent =
|
||||
IsRootModule ? nullptr
|
||||
: getOrCreateModuleRef(
|
||||
ExternalASTSource::ASTSourceDescriptor(*M->Parent),
|
||||
CreateSkeletonCU);
|
||||
llvm::DIModule *DIMod =
|
||||
DBuilder.createModule(TheCU, FullModuleName, ConfigMacros, Mod.getPath(),
|
||||
CGM.getHeaderSearchOpts().Sysroot);
|
||||
DBuilder.createModule(Parent, Mod.getModuleName(), ConfigMacros,
|
||||
Mod.getPath(), CGM.getHeaderSearchOpts().Sysroot);
|
||||
ModRef.reset(DIMod);
|
||||
return DIMod;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fmodules -fmodule-format=obj -g -dwarf-ext-refs \
|
||||
// RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \
|
||||
// RUN: %s -emit-llvm -o - | FileCheck %s
|
||||
#include "DebugSubmoduleA.h"
|
||||
#include "DebugSubmoduleB.h"
|
||||
|
||||
// CHECK: !DICompileUnit
|
||||
// CHECK-NOT: !DICompileUnit
|
||||
// CHECK: !DIModule(scope: ![[PARENT:.*]], name: "DebugSubmoduleA"
|
||||
// CHECK: [[PARENT]] = !DIModule(scope: null, name: "DebugSubmodules"
|
||||
// CHECK: !DIModule(scope: ![[PARENT]], name: "DebugSubmoduleB"
|
||||
// CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}DebugSubmodules
|
||||
// CHECK-SAME: dwoId:
|
||||
// CHECK-NOT: !DICompileUnit
|
|
@ -1,16 +1,18 @@
|
|||
// RUN: rm -rf %t
|
||||
// RUN: %clang_cc1 -fmodules -fmodule-format=obj -g -dwarf-ext-refs \
|
||||
// RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \
|
||||
// RUN: %s -mllvm -debug-only=pchcontainer 2>&1 | FileCheck %s
|
||||
// RUN: %s -mllvm -debug-only=pchcontainer -emit-llvm -o %t.ll \
|
||||
// RUN: 2>&1 | FileCheck %s
|
||||
// REQUIRES: asserts
|
||||
#include "DebugSubmoduleA.h"
|
||||
|
||||
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "A",
|
||||
// CHECK-SAME: scope: ![[SUBMODULEA:[0-9]+]]
|
||||
// CHECK: ![[SUBMODULEA]] = !DIModule(
|
||||
// CHECK-SAME: name: "DebugSubmodules.DebugSubmoduleA",
|
||||
// CHECK: ![[SUBMODULEA]] = !DIModule(scope: ![[PARENT:[0-9]+]],
|
||||
// CHECK-SAME: name: "DebugSubmoduleA",
|
||||
// CHECK: ![[PARENT]] = !DIModule(scope: null, name: "DebugSubmodules"
|
||||
|
||||
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "B",
|
||||
// CHECK-SAME: scope: ![[SUBMODULEB:[0-9]+]]
|
||||
// CHECK: ![[SUBMODULEB]] = !DIModule(
|
||||
// CHECK-SAME: name: "DebugSubmodules.DebugSubmoduleB",
|
||||
// CHECK: ![[SUBMODULEB]] = !DIModule(scope: ![[PARENT]],
|
||||
// CHECK-SAME: name: "DebugSubmoduleB",
|
||||
|
|
Loading…
Reference in New Issue