This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG43580a5c5afc: Allow remapping Clang module skeleton CU 
references with -fdebug-prefix-map (authored by aprantl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D76383?vs=251160&id=251791#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76383/new/

https://reviews.llvm.org/D76383

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/Modules/debug-info-moduleimport.m
  clang/test/PCH/debug-info-pch-path.c

Index: clang/test/PCH/debug-info-pch-path.c
===================================================================
--- clang/test/PCH/debug-info-pch-path.c
+++ 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]]
Index: clang/test/Modules/debug-info-moduleimport.m
===================================================================
--- clang/test/Modules/debug-info-moduleimport.m
+++ 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]]"
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2493,14 +2493,18 @@
             : ~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();
   }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to