diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 578d09f7971d6..48a873f2b52ac 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -397,6 +397,11 @@ PrintingPolicy CGDebugInfo::getPrintingPolicy() const { // Apply -fdebug-prefix-map. PP.Callbacks = &PrintCB; + // If we have lambdas as template parameters, two debug entries from different + // CUs will get merged in LTO, but their human-readable DW_AT_name will be + // different. Disable printing of location of an anonymous tag name to prevent + // that from happening. + PP.AnonymousTagLocations = false; return PP; } diff --git a/clang/test/DebugInfo/CXX/anonymous-locs.cpp b/clang/test/DebugInfo/CXX/anonymous-locs.cpp new file mode 100644 index 0000000000000..48a8aff57d520 --- /dev/null +++ b/clang/test/DebugInfo/CXX/anonymous-locs.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++20 -emit-obj -debug-info-kind=standalone -dwarf-version=5 -triple x86_64-apple-darwin -o %t %s +// RUN: llvm-dwarfdump %t | FileCheck %s + +// CHECK: DW_TAG_structure_type +// CHECK-NEXT: DW_AT_calling_convention (DW_CC_pass_by_value) +// CHECK-NEXT: DW_AT_name ("Foo<(lambda){}>") + +template +struct Foo { +}; + +Foo<[] {}> f; + +auto func() { return f; } \ No newline at end of file diff --git a/clang/test/DebugInfo/CXX/prefix-map-lambda.cpp b/clang/test/DebugInfo/CXX/prefix-map-lambda.cpp index f0fb1a312c8be..961aff1d66253 100644 --- a/clang/test/DebugInfo/CXX/prefix-map-lambda.cpp +++ b/clang/test/DebugInfo/CXX/prefix-map-lambda.cpp @@ -3,8 +3,6 @@ template void b(T) {} void c() { - // CHECK: !DISubprogram(name: "b<(lambda at - // CHECK-SAME: SOURCE_ROOT - // CHECK-SAME: [[@LINE+1]]:{{[0-9]+}})>" + // CHECK: !DISubprogram(name: "b<(lambda)>" b([]{}); } diff --git a/clang/test/DebugInfo/CXX/simple-template-names.cpp b/clang/test/DebugInfo/CXX/simple-template-names.cpp index 5a5d706e81972..97eb58c67b31f 100644 --- a/clang/test/DebugInfo/CXX/simple-template-names.cpp +++ b/clang/test/DebugInfo/CXX/simple-template-names.cpp @@ -70,18 +70,18 @@ void f() { // anything other than another unnamed class/struct. auto Lambda = [] {}; f1(); - // CHECK: !DISubprogram(name: "f1<(lambda at {{.*}}simple-template-names.cpp:[[# @LINE - 2]]:17)>", + // CHECK: !DISubprogram(name: "f1<(lambda)>", f1>>(); - // CHECK: !DISubprogram(name: "f1 > >", + // CHECK: !DISubprogram(name: "f1 > >", struct { } unnamed_struct; f1(); - // CHECK: !DISubprogram(name: "f1<(unnamed struct at {{.*}}simple-template-names.cpp:[[# @LINE - 3]]:3)>", + // CHECK: !DISubprogram(name: "f1<(unnamed)>", f1(); - // CHECK: !DISubprogram(name: "f1", + // CHECK: !DISubprogram(name: "f1", enum {} unnamed_enum; f1(); - // CHECK: !DISubprogram(name: "f1<(unnamed enum at {{.*}}simple-template-names.cpp:[[# @LINE - 2]]:3)>", + // CHECK: !DISubprogram(name: "f1<(unnamed)>", // Declarations can't readily be reversed as the value in the DWARF only // contains the address of the value - we'd have to do symbol lookup to find @@ -128,5 +128,5 @@ void f() { // CHECK: !DISubprogram(name: "f1", f4(); - // CHECK: !DISubprogram(name: "f4<((unnamed enum at {{.*}}))0>" + // CHECK: !DISubprogram(name: "f4<((unnamed))0>" } diff --git a/clang/test/DebugInfo/Generic/debug-prefix-map.cpp b/clang/test/DebugInfo/Generic/debug-prefix-map.cpp index 174bef5a07699..e6eadd66d1ffd 100644 --- a/clang/test/DebugInfo/Generic/debug-prefix-map.cpp +++ b/clang/test/DebugInfo/Generic/debug-prefix-map.cpp @@ -8,4 +8,4 @@ struct alignas(64) an { struct an *pan = new an; -// CHECK: !DISubprogram(name: "(unnamed struct at ./UNLIKELY_PATH/empty{{/|\\\\}}{{.*}}", +// CHECK: !DISubprogram(name: "(unnamed)", diff --git a/clang/test/DebugInfo/Generic/slash.test b/clang/test/DebugInfo/Generic/slash.test index 0e42912c18d21..09ce08502746a 100644 --- a/clang/test/DebugInfo/Generic/slash.test +++ b/clang/test/DebugInfo/Generic/slash.test @@ -6,5 +6,5 @@ RUN: cd %t-dir RUN: %clang -target x86_64-pc-win32 -emit-llvm -S -g %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=WIN %s RUN: %clang -target x86_64-linux-gnu -emit-llvm -S -g %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=LINUX %s -WIN: lambda at header\\Inputs\\debug-info-slash.h -LINUX: lambda at header/Inputs/debug-info-slash.h +WIN: lambda +LINUX: lambda