| 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-n-a.o -g -gsimple-template-names -DFILE_A |
| 8 | // RUN: %clang --target=x86_64-pc-linux -c %s -o %t-n-b.o -g -gsimple-template-names -DFILE_B |
| 9 | // RUN: ld.lld %t-n-a.o %t-n-b.o -o %t-n |
| 10 | // RUN: %lldb %t-n -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s |
| 11 | |
| 12 | // RUN: %clang --target=x86_64-pc-linux -c %s -o %t-t-a.o -g -fdebug-types-section -DFILE_A |
| 13 | // RUN: %clang --target=x86_64-pc-linux -c %s -o %t-t-b.o -g -fdebug-types-section -DFILE_B |
| 14 | // RUN: ld.lld %t-t-a.o %t-t-b.o -o %t-t |
| 15 | // RUN: %lldb %t-t -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s |
| 16 | |
| 17 | // RUN: %clang --target=x86_64-pc-linux -c %s -o %t-tn-a.o -g -fdebug-types-section -gsimple-template-names -DFILE_A |
| 18 | // RUN: %clang --target=x86_64-pc-linux -c %s -o %t-tn-b.o -g -fdebug-types-section -gsimple-template-names -DFILE_B |
| 19 | // RUN: ld.lld %t-tn-a.o %t-tn-b.o -o %t-tn |
| 20 | // RUN: %lldb %t-tn -o "target variable --ptr-depth 1 --show-types both_a both_b" -o exit | FileCheck %s |
| 21 | |
| 22 | // CHECK: (lldb) target variable |
| 23 | // CHECK-NEXT: (ReferencesBoth<'A'>) both_a = { |
| 24 | // CHECK-NEXT: (Outer<'A'>::Inner *) a = 0x{{[0-9A-Fa-f]*}} {} |
| 25 | // CHECK-NEXT: (Outer<'B'>::Inner *) b = 0x{{[0-9A-Fa-f]*}} {} |
| 26 | // CHECK-NEXT: } |
| 27 | // CHECK-NEXT: (ReferencesBoth<'B'>) both_b = { |
| 28 | // CHECK-NEXT: (Outer<'A'>::Inner *) a = 0x{{[0-9A-Fa-f]*}} {} |
| 29 | // CHECK-NEXT: (Outer<'B'>::Inner *) b = 0x{{[0-9A-Fa-f]*}} {} |
| 30 | // CHECK-NEXT: } |
| 31 | |
| 32 | template <char C> struct Outer { |
| 33 | struct Inner {}; |
| 34 | }; |
| 35 | |
| 36 | template <char C> struct ReferencesBoth { |
| 37 | Outer<'A'>::Inner *a; |
| 38 | Outer<'B'>::Inner *b; |
| 39 | }; |
| 40 | |
| 41 | #ifdef FILE_A |
| 42 | Outer<'A'>::Inner inner_a; |
| 43 | extern Outer<'B'>::Inner inner_b; |
| 44 | |
| 45 | ReferencesBoth<'A'> both_a{&inner_a, &inner_b}; |
| 46 | |
| 47 | #else |
| 48 | extern Outer<'A'>::Inner inner_a; |
| 49 | Outer<'B'>::Inner inner_b; |
| 50 | |
| 51 | ReferencesBoth<'B'> both_b{.a: &inner_a, .b: &inner_b}; |
| 52 | #endif |
| 53 | |