[PATCH] D95772: [DebugInfo] Normalize paths by removing unnecessary dots
Petr Hosek via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 31 22:36:05 PST 2021
phosek created this revision.
phosek added reviewers: dblaikie, jhenderson.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
This was suggested in https://reviews.llvm.org/D87657 as a better
alternative which doesn't require having to guess separators.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95772
Files:
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/debug-info-abspath.c
clang/test/CodeGen/debug-info-relpath.c
clang/test/CodeGenCXX/linetable-fnbegin.cpp
clang/test/Modules/debug-info-moduleimport.m
Index: clang/test/Modules/debug-info-moduleimport.m
===================================================================
--- clang/test/Modules/debug-info-moduleimport.m
+++ clang/test/Modules/debug-info-moduleimport.m
@@ -16,7 +16,7 @@
// RUN: -debugger-tuning=lldb -o - | FileCheck %s
// CHECK: ![[CU:.*]] = distinct !DICompileUnit
-// CHECK-SAME: sysroot: "/tmp/..")
+// CHECK-SAME: sysroot: "/")
@import DebugObjC;
// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: ![[CU]],
// CHECK-SAME: entity: ![[MODULE:.*]], file: ![[F:[0-9]+]],
Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===================================================================
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -4,7 +4,7 @@
// CHECK: define{{.*}}bar
// CHECK-NOT: define
// CHECK: ret {{.*}}, !dbg [[DBG:.*]]
-// CHECK: [[HPP:.*]] = !DIFile(filename: "./template.hpp",
+// CHECK: [[HPP:.*]] = !DIFile(filename: "template.hpp",
// CHECK: [[SP:.*]] = distinct !DISubprogram(name: "bar",
// CHECK-SAME: file: [[HPP]], line: 22
// CHECK-SAME: DISPFlagDefinition
Index: clang/test/CodeGen/debug-info-relpath.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/debug-info-relpath.c
@@ -0,0 +1,21 @@
+// RUN: mkdir -p %t/UNIQUEISH_SENTINEL
+// RUN: cp %s %t/UNIQUEISH_SENTINEL/debug-info-abspath.c
+// RUN: cd %t
+
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN: UNIQUEISH_SENTINEL/debug-info-abspath.c -emit-llvm -o - \
+// RUN: | FileCheck %s
+
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN: ./UNIQUEISH_SENTINEL/../UNIQUEISH_SENTINEL/debug-info-abspath.c \
+// RUN: -emit-llvm -o - | FileCheck %s
+
+void foo() {}
+
+// Since %s is a relative path, directory should be the common
+// prefix, but the directory part should be part of the filename.
+
+// CHECK: = distinct !DISubprogram({{.*}}file: ![[SPFILE:[0-9]+]]
+// CHECK: ![[SPFILE]] = !DIFile(filename: "UNIQUEISH_SENTINEL
+// CHECK-SAME: debug-info-abspath.c"
+// CHECK-NOT: directory: "{{.*}}UNIQUEISH_SENTINEL")
Index: clang/test/CodeGen/debug-info-abspath.c
===================================================================
--- clang/test/CodeGen/debug-info-abspath.c
+++ clang/test/CodeGen/debug-info-abspath.c
@@ -5,6 +5,10 @@
// RUN: %t/UNIQUEISH_SENTINEL/debug-info-abspath.c -emit-llvm -o - \
// RUN: | FileCheck %s
+// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
+// RUN: %t/UNIQUEISH_SENTINEL/../UNIQUEISH_SENTINEL/debug-info-abspath.c \
+// RUN: -emit-llvm -o - | FileCheck %s
+
// RUN: cp %s %t.c
// RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple \
// RUN: %t.c -emit-llvm -o - | FileCheck %s --check-prefix=INTREE
@@ -24,7 +28,7 @@
// CHECK: = distinct !DISubprogram({{.*}}file: ![[SPFILE:[0-9]+]]
// CHECK: ![[SPFILE]] = !DIFile(filename: "{{.*}}UNIQUEISH_SENTINEL
// CHECK-SAME: debug-info-abspath.c"
-// CHECK-NOT: directory: "{{.*}}UNIQUEISH_SENTINEL
+// CHECK-NOT: directory: "{{.*}}UNIQUEISH_SENTINEL)
// INTREE: = distinct !DISubprogram({{.*}}![[SPFILE:[0-9]+]]
// INTREE: DIFile({{.*}}directory: "{{.+}}CodeGen{{.*}}")
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -477,10 +477,8 @@
}
std::string CGDebugInfo::remapDIPath(StringRef Path) const {
- if (DebugPrefixMap.empty())
- return Path.str();
-
SmallString<256> P = Path;
+ llvm::sys::path::remove_dots(P, /*remove_dot_dot=*/true);
for (const auto &Entry : DebugPrefixMap)
if (llvm::sys::path::replace_path_prefix(P, Entry.first, Entry.second))
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95772.320396.patch
Type: text/x-patch
Size: 4002 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210201/ce5a0063/attachment.bin>
More information about the cfe-commits
mailing list