Files
clang-p2996/lldb/test/Shell/SymbolFile/DWARF/x86/simple-template-names-context.cpp
Pavel Labath c2f976649a [lldb/DWARF] Fix type definition search with simple template names (#95905)
With simple template names the template arguments aren't embedded in the
DW_AT_name attribute of the type. The code in
FindDefinitionTypeForDWARFDeclContext was comparing the synthesized
template arguments on the leaf (most deeply nested) DIE, but was not
sufficient, as the difference get be at any level above that
(Foo<T>::Bar vs. Foo<U>::Bar). This patch makes sure we compare the
entire context.

As a drive-by I also remove the completely unnecessary
ConstStringification of the GetDIEClassTemplateParams result.
2024-06-20 08:09:02 +02:00

45 lines
1.4 KiB
C++

// Test that we can correctly resolve forward declared types when they only
// differ in the template arguments of the surrounding context. The reproducer
// is sensitive to the order of declarations, so we test in both directions.
// REQUIRES: lld
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-a.o -g -gsimple-template-names -DFILE_A
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-b.o -g -gsimple-template-names -DFILE_B
// RUN: ld.lld %t-a.o %t-b.o -o %t
// RUN: %lldb %t -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s
// CHECK: (lldb) target variable
// CHECK-NEXT: (ReferencesBoth<'A'>) both_a = {
// CHECK-NEXT: (Outer<'A'>::Inner *) a = 0x{{[0-9A-Fa-f]*}} {}
// CHECK-NEXT: (Outer<'B'>::Inner *) b = 0x{{[0-9A-Fa-f]*}} {}
// CHECK-NEXT: }
// CHECK-NEXT: (ReferencesBoth<'B'>) both_b = {
// CHECK-NEXT: (Outer<'A'>::Inner *) a = 0x{{[0-9A-Fa-f]*}} {}
// CHECK-NEXT: (Outer<'B'>::Inner *) b = 0x{{[0-9A-Fa-f]*}} {}
// CHECK-NEXT: }
template<char C>
struct Outer {
struct Inner {};
};
template<char C>
struct ReferencesBoth {
Outer<'A'>::Inner *a;
Outer<'B'>::Inner *b;
};
#ifdef FILE_A
Outer<'A'>::Inner inner_a;
extern Outer<'B'>::Inner inner_b;
ReferencesBoth<'A'> both_a{&inner_a, &inner_b};
#else
extern Outer<'A'>::Inner inner_a;
Outer<'B'>::Inner inner_b;
ReferencesBoth<'B'> both_b{&inner_a, &inner_b};
#endif