: 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; }
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;
}
}
}
- 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;
}
--- /dev/null
+// 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
// 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",