[clang] 079c6dd - Correctly initialize the DW_AT_comp_dir attribute of Clang module skeleton CUs
Adrian Prantl via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 20 14:18:32 PDT 2020
Author: Adrian Prantl
Date: 2020-03-20T14:18:14-07:00
New Revision: 079c6ddaf5344eb501652c2a874e3e4e8c466c2b
URL: https://github.com/llvm/llvm-project/commit/079c6ddaf5344eb501652c2a874e3e4e8c466c2b
DIFF: https://github.com/llvm/llvm-project/commit/079c6ddaf5344eb501652c2a874e3e4e8c466c2b.diff
LOG: Correctly initialize the DW_AT_comp_dir attribute of Clang module skeleton CUs
Before this patch a Clang module skeleton CU would have a
DW_AT_comp_dir pointing to the directory of the module map file, and
this information was not used by anyone. Even worse, LLDB actually
resolves relative DWO paths by appending it to DW_AT_comp_dir. This
patch sets it to the same directory that is used as the main CU's
compilation directory, which would make the LLDB code work.
Differential Revision: https://reviews.llvm.org/D76377
Added:
Modified:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/Modules/debug-info-moduleimport.m
clang/test/PCH/debug-info-pch-path.c
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index eeb1927177c5..6d0960687a95 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2492,12 +2492,16 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
? (uint64_t)Mod.getSignature()[1] << 32 | Mod.getSignature()[0]
: ~1ULL;
llvm::DIBuilder DIB(CGM.getModule());
+ SmallString<0> PCM;
+ if (!llvm::sys::path::is_absolute(PCM))
+ PCM = Mod.getPath();
+ llvm::sys::path::append(PCM, Mod.getASTFile());
+ StringRef CompDir = getCurrentDirname();
DIB.createCompileUnit(TheCU->getSourceLanguage(),
// TODO: Support "Source" from external AST providers?
- DIB.createFile(Mod.getModuleName(), Mod.getPath()),
- TheCU->getProducer(), true, StringRef(), 0,
- Mod.getASTFile(), llvm::DICompileUnit::FullDebug,
- Signature);
+ DIB.createFile(Mod.getModuleName(), CompDir),
+ TheCU->getProducer(), true, StringRef(), 0, PCM,
+ llvm::DICompileUnit::FullDebug, Signature);
DIB.finalize();
}
diff --git a/clang/test/Modules/debug-info-moduleimport.m b/clang/test/Modules/debug-info-moduleimport.m
index f07c6fce784d..837459b0786c 100644
--- a/clang/test/Modules/debug-info-moduleimport.m
+++ b/clang/test/Modules/debug-info-moduleimport.m
@@ -28,5 +28,7 @@
// RUN: -fmodule-format=obj -dwarf-ext-refs \
// RUN: %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \
// RUN: | FileCheck %s --check-prefix=SKEL-CHECK
-// SKEL-CHECK: distinct !DICompileUnit
-// SKEL-CHECK: distinct !DICompileUnit{{.*}}dwoId
+// SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[CUFILE:[0-9]+]]
+// SKEL-CHECK: ![[CUFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR:.*]]"
+// SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[DWOFILE:[0-9]+]]{{.*}}dwoId
+// SKEL-CHECK: ![[DWOFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR]]"
diff --git a/clang/test/PCH/debug-info-pch-path.c b/clang/test/PCH/debug-info-pch-path.c
index dcf7ed41f50e..32d1cbd44bdf 100644
--- a/clang/test/PCH/debug-info-pch-path.c
+++ b/clang/test/PCH/debug-info-pch-path.c
@@ -23,7 +23,7 @@
// CHECK-REL-NODIR: ![[C]] = !DIFile({{.*}}directory: "[[DIR:.*]]"
// CHECK-REL-NODIR: !DICompileUnit(
// CHECK-REL-NODIR-SAME: file: ![[PCH:[0-9]+]]
-// CHECK-REL-NODIR-SAME: splitDebugFilename: "prefix.pch"
+// CHECK-REL-NODIR-SAME: splitDebugFilename: "{{.*}}PCH{{.*}}prefix.pch"
// CHECK-REL-NODIR: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]
// ---------------------------------------------------------------------
@@ -47,8 +47,8 @@
// CHECK-REL: ![[C]] = !DIFile({{.*}}directory: "[[DIR:.*]]"
// CHECK-REL: !DICompileUnit(
// CHECK-REL-SAME: file: ![[PCH:[0-9]+]]
-// CHECK-REL-SAME: splitDebugFilename: "prefix.pch"
-// CHECK-REL: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]{{.*}}pchdir"
+// CHECK-REL-SAME: splitDebugFilename: "[[DIR]]{{.*}}pchdir{{.*}}prefix.pch"
+// CHECK-REL: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]"
// ---------------------------------------------------------------------
// Absolute PCH.
@@ -70,5 +70,5 @@
// CHECK-ABS: ![[C]] = !DIFile({{.*}}directory: "[[DIR:.*]]"
// CHECK-ABS: !DICompileUnit(
// CHECK-ABS-SAME: file: ![[PCH:[0-9]+]]
-// CHECK-ABS-SAME: splitDebugFilename: "prefix.pch"
+// CHECK-ABS-SAME: splitDebugFilename: "[[DIR]]{{.*}}prefix.pch"
// CHECK-ABS: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]
More information about the cfe-commits
mailing list