aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/Shell/SymbolFile/DWARF/x86/simple-template-names-context.cpp
blob: a8a4d3b8fbd5fed347e50b61f7c28286cfa937f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// 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<'A'>::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