Skip to content

Commit de3f1b6

Browse files
committed
[lldb] Test case for the bug in #92328
1 parent 7fdbc30 commit de3f1b6

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Test that we can correctly resolve forward declared types when they only
2+
// differ in the template arguments of the surrounding context. The reproducer
3+
// is sensitive to the order of declarations, so we test in both directions.
4+
5+
// REQUIRES: lld
6+
7+
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-a.o -g -gsimple-template-names -DFILE_A
8+
// RUN: %clang --target=x86_64-pc-linux -c %s -o %t-b.o -g -gsimple-template-names -DFILE_B
9+
// RUN: ld.lld %t-a.o %t-b.o -o %t
10+
// RUN: %lldb %t -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s
11+
12+
// CHECK: (lldb) target variable
13+
// CHECK-NEXT: (ReferencesBoth<'A'>) both_a = {
14+
// CHECK-NEXT: (Outer<'A'>::Inner *) a = 0x{{[0-9A-Fa-f]*}} {}
15+
// CHECK-NEXT: (Outer<'A'>::Inner *) b = 0x{{[0-9A-Fa-f]*}} {}
16+
// CHECK-NEXT: }
17+
// CHECK-NEXT: (ReferencesBoth<'B'>) both_b = {
18+
// CHECK-NEXT: (Outer<'A'>::Inner *) a = 0x{{[0-9A-Fa-f]*}} {}
19+
// CHECK-NEXT: (Outer<'B'>::Inner *) b = 0x{{[0-9A-Fa-f]*}} {}
20+
// CHECK-NEXT: }
21+
22+
template<char C>
23+
struct Outer {
24+
struct Inner {};
25+
};
26+
27+
template<char C>
28+
struct ReferencesBoth {
29+
Outer<'A'>::Inner *a;
30+
Outer<'B'>::Inner *b;
31+
};
32+
33+
#ifdef FILE_A
34+
Outer<'A'>::Inner inner_a;
35+
extern Outer<'B'>::Inner inner_b;
36+
37+
ReferencesBoth<'A'> both_a{&inner_a, &inner_b};
38+
39+
#else
40+
extern Outer<'A'>::Inner inner_a;
41+
Outer<'B'>::Inner inner_b;
42+
43+
ReferencesBoth<'B'> both_b{&inner_a, &inner_b};
44+
#endif

0 commit comments

Comments
 (0)