[clang] 43580a5 - Allow remapping Clang module skeleton CU references with -fdebug-prefix-map
Adrian Prantl via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 20 15:16:04 PDT 2020
Author: Adrian Prantl
Date: 2020-03-20T15:15:56-07:00
New Revision: 43580a5c5afc3cd935e4e3d67f285fe81dd7e8c5
URL: https://github.com/llvm/llvm-project/commit/43580a5c5afc3cd935e4e3d67f285fe81dd7e8c5
DIFF: https://github.com/llvm/llvm-project/commit/43580a5c5afc3cd935e4e3d67f285fe81dd7e8c5.diff
LOG: Allow remapping Clang module skeleton CU references with -fdebug-prefix-map
Differential Revision: https://reviews.llvm.org/D76383
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 9645dd1deb42..a98d82f7152c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2493,14 +2493,18 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
: ~1ULL;
llvm::DIBuilder DIB(CGM.getModule());
SmallString<0> PCM;
- if (!llvm::sys::path::is_absolute(PCM))
+ if (!llvm::sys::path::is_absolute(Mod.getASTFile()))
PCM = Mod.getPath();
llvm::sys::path::append(PCM, Mod.getASTFile());
- StringRef CompDir = getCurrentDirname();
+ std::string RemappedPCM = remapDIPath(PCM);
+ StringRef RelativePCM(RemappedPCM);
+ StringRef CompDir = TheCU->getDirectory();
+ if (RelativePCM.consume_front(CompDir))
+ RelativePCM.consume_front(llvm::sys::path::get_separator());
DIB.createCompileUnit(TheCU->getSourceLanguage(),
// TODO: Support "Source" from external AST providers?
DIB.createFile(Mod.getModuleName(), CompDir),
- TheCU->getProducer(), false, StringRef(), 0, PCM,
+ TheCU->getProducer(), false, StringRef(), 0, RelativePCM,
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 837459b0786c..9dee9964b538 100644
--- a/clang/test/Modules/debug-info-moduleimport.m
+++ b/clang/test/Modules/debug-info-moduleimport.m
@@ -1,11 +1,19 @@
// RUN: rm -rf %t
-// RUN: %clang_cc1 -debug-info-kind=limited -fmodules -DGREETING="Hello World" -UNDEBUG -fimplicit-module-maps -fmodules-cache-path=%t %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - | FileCheck %s --check-prefix=NOIMPORT
+// RUN: %clang_cc1 -debug-info-kind=limited -fmodules \
+// RUN: -DGREETING="Hello World" -UNDEBUG \
+// RUN: -fimplicit-module-maps -fmodules-cache-path=%t %s \
+// RUN: -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \
+// RUN: | FileCheck %s --check-prefix=NOIMPORT
// NOIMPORT-NOT: !DIImportedEntity
// NOIMPORT-NOT: !DIModule
// RUN: rm -rf %t
-// RUN: %clang_cc1 -debug-info-kind=limited -fmodules -DGREETING="Hello World" -UNDEBUG -fimplicit-module-maps -fmodules-cache-path=%t %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=limited -fmodules \
+// RUN: -DGREETING="Hello World" -UNDEBUG \
+// RUN: -fimplicit-module-maps -fmodules-cache-path=%t %s \
+// RUN: -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm \
+// RUN: -debugger-tuning=lldb -o - | FileCheck %s
// CHECK: ![[CU:.*]] = distinct !DICompileUnit
// CHECK-SAME: sysroot: "/tmp/..")
@@ -18,17 +26,18 @@
// CHECK-SAME: includePath: "{{.*}}test{{.*}}Modules{{.*}}Inputs"
// CHECK: ![[F]] = !DIFile(filename: {{.*}}debug-info-moduleimport.m
-// RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
-// RUN: %s -I %S/Inputs -isysroot /tmp/.. -I %t -emit-llvm -o - \
-// RUN: | FileCheck %s --check-prefix=NO-SKEL-CHECK
+// RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t %s -I %S/Inputs -isysroot /tmp/.. -I %t \
+// RUN: -emit-llvm -o - | FileCheck %s --check-prefix=NO-SKEL-CHECK
// NO-SKEL-CHECK: distinct !DICompileUnit
// NO-SKEL-CHECK-NOT: distinct !DICompileUnit
-// RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN: %clang_cc1 -debug-info-kind=limited -fmodules -fimplicit-module-maps \
+// RUN: -fmodules-cache-path=%t -fdebug-prefix-map=%t=/MODULE-CACHE \
// 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({{.*}}file: ![[CUFILE:[0-9]+]]
// SKEL-CHECK: ![[CUFILE]] = !DIFile({{.*}}directory: "[[COMP_DIR:.*]]"
-// SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[DWOFILE:[0-9]+]]{{.*}}dwoId
+// SKEL-CHECK: distinct !DICompileUnit({{.*}}file: ![[DWOFILE:[0-9]+]]{{.*}}splitDebugFilename: "/MODULE-CACHE{{.*}}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 32d1cbd44bdf..272d9ac1ab7c 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: "{{.*}}PCH{{.*}}prefix.pch"
+// CHECK-REL-NODIR-SAME: splitDebugFilename: "prefix.pch"
// CHECK-REL-NODIR: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]
// ---------------------------------------------------------------------
@@ -47,7 +47,7 @@
// CHECK-REL: ![[C]] = !DIFile({{.*}}directory: "[[DIR:.*]]"
// CHECK-REL: !DICompileUnit(
// CHECK-REL-SAME: file: ![[PCH:[0-9]+]]
-// CHECK-REL-SAME: splitDebugFilename: "[[DIR]]{{.*}}pchdir{{.*}}prefix.pch"
+// CHECK-REL-SAME: splitDebugFilename: "pchdir{{.*}}prefix.pch"
// CHECK-REL: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]"
// ---------------------------------------------------------------------
@@ -70,5 +70,5 @@
// CHECK-ABS: ![[C]] = !DIFile({{.*}}directory: "[[DIR:.*]]"
// CHECK-ABS: !DICompileUnit(
// CHECK-ABS-SAME: file: ![[PCH:[0-9]+]]
-// CHECK-ABS-SAME: splitDebugFilename: "[[DIR]]{{.*}}prefix.pch"
+// CHECK-ABS-SAME: splitDebugFilename: "prefix.pch"
// CHECK-ABS: ![[PCH]] = !DIFile({{.*}}directory: "[[DIR]]
More information about the cfe-commits
mailing list