diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/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; diff --git a/clang/test/CodeGen/debug-info-abspath.c b/clang/test/CodeGen/debug-info-abspath.c --- a/clang/test/CodeGen/debug-info-abspath.c +++ b/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{{.*}}") diff --git a/clang/test/CodeGen/debug-info-relpath.c b/clang/test/CodeGen/debug-info-relpath.c new file mode 100644 --- /dev/null +++ b/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") diff --git a/clang/test/CodeGenCXX/linetable-fnbegin.cpp b/clang/test/CodeGenCXX/linetable-fnbegin.cpp --- a/clang/test/CodeGenCXX/linetable-fnbegin.cpp +++ b/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 diff --git a/clang/test/Modules/debug-info-moduleimport.m b/clang/test/Modules/debug-info-moduleimport.m --- a/clang/test/Modules/debug-info-moduleimport.m +++ b/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]+]],