[PATCH] D111352: [clang] Fix absolute file paths with -fdebug-prefix-map

Keith Smiley via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 8 10:35:43 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa23a59679322: [clang] Fix absolute file paths with -fdebug-prefix-map (authored by keith).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111352

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/relative-debug-prefix-map.c


Index: clang/test/CodeGen/relative-debug-prefix-map.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/relative-debug-prefix-map.c
@@ -0,0 +1,17 @@
+// RUN: mkdir -p %t.nested/dir && cd %t.nested/dir
+// RUN: cp %s %t.nested/dir/main.c
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%t.nested=. %t.nested/dir/main.c -emit-llvm -o - | FileCheck %s
+//
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=. %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-DIRECT
+//
+// RUN: cd %p
+// RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-compilation-dir=. relative-debug-prefix-map.c -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-DIRECT
+
+// CHECK: !DIFile(filename: "main.c", directory: "./dir")
+// CHECK-DIRECT: !DIFile(filename: "relative-debug-prefix-map.c", directory: ".")
+
+int main(int argc, char **argv) {
+  (void)argc;
+  (void)argv;
+  return 0;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -446,6 +446,9 @@
       Dir = DirBuf;
       File = FileBuf;
     }
+  } else if (llvm::sys::path::is_absolute(FileName)) {
+    Dir = llvm::sys::path::parent_path(RemappedFile);
+    File = llvm::sys::path::filename(RemappedFile);
   } else {
     Dir = CurDir;
     File = RemappedFile;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111352.378297.patch
Type: text/x-patch
Size: 1445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211008/773b29a8/attachment.bin>


More information about the cfe-commits mailing list