xref: /llvm-project/llvm/test/tools/dsymutil/X86/DWARFLinkerParallel/odr-fwd-declaration2.test (revision f1fdfe6888f93b9f6dfb4689e1f3206de584ff5b)
1/* Compile with:
2   for FILE in `seq 3`; do
3     clang -g -c  X86/odr-fwd-declaration2.cpp -DFILE$FILE -o
4       Inputs/odr-fwd-declaration2/$FILE.o done
5*/
6
7// RUN: dsymutil --linker=parallel -f \
8// RUN: -oso-prepend-path=%p/../../Inputs/odr-fwd-declaration2 \
9// RUN: -y %p/../dummy-debug-map.map -o %t1.out
10// RUN: llvm-dwarfdump -v %t1.out -debug-info | FileCheck %s
11
12#ifdef FILE1
13# 1 "Header.h" 1
14struct A {
15  struct B;
16  B *bPtr;
17  B &bRef;
18  int B::*bPtrToField;
19};
20# 3 "Source1.cpp" 2
21void foo() { A *ptr1 = 0; }
22
23// First we check that types are in type table unit.
24
25// CHECK: DW_TAG_compile_unit
26// CHECK: AT_name{{.*}}"__artificial_type_unit"
27
28// CHECK: 0x[[INT_BASE:[a-f0-9]*]]: DW_TAG_base_type
29// CHECK: AT_name{{.*}}"int"
30
31// CHECK: 0x[[PTR_A:[a-f0-9]*]]: DW_TAG_pointer_type
32// CHECK-NEXT: DW_AT_type [DW_FORM_ref4]   {{.*}}0x[[STRUCT_A:[a-f0-9]*]]} "A")
33
34// CHECK: 0x[[PTR_B:[a-f0-9]*]]: DW_TAG_pointer_type
35// CHECK-NEXT: DW_AT_type [DW_FORM_ref4]   {{.*}}0x[[STRUCT_B:[a-f0-9]*]]} "A::B")
36
37// CHECK: 0x[[REF_B:[a-f0-9]*]]: DW_TAG_reference_type
38// CHECK-NEXT: DW_AT_type [DW_FORM_ref4]   {{.*}}0x[[STRUCT_B]]} "A::B")
39
40// CHECK: 0x[[STRUCT_A]]: DW_TAG_structure_type
41// CHECK: AT_name{{.*}}"A"
42
43// CHECK: DW_TAG_member
44// CHECK-NEXT: AT_name{{.*}}"bPtr"
45// CHECK-NEXT: DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[PTR_B]]} "A::B *")
46
47// CHECK: DW_TAG_member
48// CHECK-NEXT: AT_name{{.*}}"bRef"
49// CHECK-NEXT: DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[REF_B]]} "A::B &"
50
51// CHECK: DW_TAG_member
52// CHECK-NEXT: AT_name{{.*}}"bPtrToField"
53// CHECK-NEXT: DW_AT_type [DW_FORM_ref4] {{.*}}{0x[[PTR_TO_FIELD:[a-f0-9]*]]} "int A::B::*"
54
55// CHECK: 0x[[STRUCT_B]]: DW_TAG_structure_type
56// CHECK: AT_name{{.*}}"B"
57
58// CHECK: DW_TAG_member
59// CHECK: AT_name{{.*}}"x"
60
61// CHECK: 0x[[PTR_TO_FIELD]]: DW_TAG_ptr_to_member_type
62// CHECK-NEXT: DW_AT_type [DW_FORM_ref4]   {{.*}}{0x[[INT_BASE]]} "int"
63// CHECK-NEXT: DW_AT_containing_type [DW_FORM_ref4] {{.*}}{0x[[STRUCT_B]]} "A::B")
64
65// Next we check that second compile unit references type from type table unit.
66//
67
68// CHECK: DW_TAG_compile_unit
69// CHECK: AT_name{{.*}}"X86/odr-fwd-declaration2.cpp"
70
71// CHECK: DW_TAG_subprogram
72
73// CHECK: DW_TAG_variable
74// CHECK: DW_AT_name{{.*}}"ptr1"
75// CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000[[PTR_A]] "A *"
76
77#elif defined(FILE2)
78# 1 "Header.h" 1
79struct A {
80  struct B;
81  B *bPtr;
82  B &bRef;
83  int B::*bPtrToField;
84};
85# 3 "Source2.cpp" 2
86struct A::B {
87  int x;
88};
89void bar() { A *ptr2 = 0; }
90
91// Next we check that thrid compile unit references type from type table unit.
92//
93
94// CHECK: DW_TAG_compile_unit
95// CHECK: AT_name{{.*}}"X86/odr-fwd-declaration2.cpp"
96
97// CHECK: DW_TAG_subprogram
98
99// CHECK: DW_TAG_variable
100// CHECK: DW_AT_name{{.*}}"ptr2"
101// CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000[[PTR_A]] "A *"
102
103#elif defined(FILE3)
104# 1 "Header.h" 1
105struct A {
106  struct B;
107  B *bPtr;
108  B &bRef;
109  int B::*bPtrToField;
110};
111# 3 "Source2.cpp" 2
112struct A::B {
113  int x;
114};
115void bar() { A *ptr2 = 0; }
116
117// Next we check that fourth compile unit references type from type table unit.
118//
119
120// CHECK: DW_TAG_compile_unit
121// CHECK: AT_name{{.*}}"X86/odr-fwd-declaration2.cpp"
122
123// CHECK: DW_TAG_subprogram
124
125// CHECK: DW_TAG_variable
126// CHECK: DW_AT_name{{.*}}"ptr2"
127// CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000[[PTR_A]] "A *"
128
129#else
130#error "You must define which file you generate"
131#endif
132