Author: adrian Date: Thu Sep 24 11:10:10 2015 New Revision: 248511 URL: http://llvm.org/viewvc/llvm-project?rev=248511&view=rev Log: Module Debugging: Emit submodules as nested DW_TAG_modules.
Added: cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h cfe/trunk/lib/AST/ExternalASTSource.cpp cfe/trunk/lib/CodeGen/CGDebugInfo.cpp cfe/trunk/test/Modules/DebugInfoSubmodules.c Modified: cfe/trunk/include/clang/AST/ExternalASTSource.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ExternalASTSource.h?rev=248511&r1=248510&r2=248511&view=diff ============================================================================== --- cfe/trunk/include/clang/AST/ExternalASTSource.h (original) +++ cfe/trunk/include/clang/AST/ExternalASTSource.h Thu Sep 24 11:10:10 2015 @@ -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; } Modified: cfe/trunk/lib/AST/ExternalASTSource.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExternalASTSource.cpp?rev=248511&r1=248510&r2=248511&view=diff ============================================================================== --- cfe/trunk/lib/AST/ExternalASTSource.cpp (original) +++ cfe/trunk/lib/AST/ExternalASTSource.cpp Thu Sep 24 11:10:10 2015 @@ -36,9 +36,9 @@ ExternalASTSource::ASTSourceDescriptor:: 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; } Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=248511&r1=248510&r2=248511&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original) +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 24 11:10:10 2015 @@ -1707,18 +1707,23 @@ CGDebugInfo::getOrCreateModuleRef(Extern } } - 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; } Added: cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c?rev=248511&view=auto ============================================================================== --- cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c (added) +++ cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c Thu Sep 24 11:10:10 2015 @@ -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 Modified: cfe/trunk/test/Modules/DebugInfoSubmodules.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfoSubmodules.c?rev=248511&r1=248510&r2=248511&view=diff ============================================================================== --- cfe/trunk/test/Modules/DebugInfoSubmodules.c (original) +++ cfe/trunk/test/Modules/DebugInfoSubmodules.c Thu Sep 24 11:10:10 2015 @@ -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", _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits