odr-fwd-declaration.cpp
3.31 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/* Compile with:
for FILE in `seq 3`; do
clang -g -c X86/odr-fwd-declaration.cpp -DFILE$FILE -o Inputs/odr-fwd-declaration/$FILE.o
done
*/
// RUN: dsymutil -f -oso-prepend-path=%p/../Inputs/odr-fwd-declaration -y %p/dummy-debug-map.map -o - | llvm-dwarfdump -v -debug-info - | FileCheck %s
#ifdef FILE1
# 1 "Header.h" 1
typedef struct S *Sptr;
typedef Sptr *Sptrptr;
# 3 "Source1.cpp" 2
void foo() {
Sptrptr ptr1 = 0;
}
// First we confirm that the typedefs reference the forward declaration of the
// struct S.
//
// CHECK: TAG_variable
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "ptr1"
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF1:[a-f0-9]*]]
//
// CHECK: [[TYPEDEF1]]:{{.*}}TAG_typedef
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[PTR1:[a-f0-9]*]]
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "Sptrptr"
//
// CHECK: [[PTR1]]:{{.*}}TAG_pointer_type
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF2:[a-f0-9]*]]
//
// CHECK: [[TYPEDEF2]]:{{.*}}TAG_typedef
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[PTR2:[a-f0-9]*]]
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "Sptr"
//
// CHECK: [[PTR2]]:{{.*}}TAG_pointer_type
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[FWDSTRUCT:[a-f0-9]*]]
//
// CHECK: [[FWDSTRUCT]]:{{.*}}TAG_structure_type
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "S"
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_declaration
// CHECK-NOT: AT_byte_size
#elif defined(FILE2)
# 1 "Header.h" 1
typedef struct S *Sptr;
typedef Sptr *Sptrptr;
# 3 "Source2.cpp" 2
struct S {
int field;
};
void bar() {
Sptrptr ptr2 = 0;
}
// Next we confirm that the typedefs reference the definition rather than the
// previous declaration of S.
//
// CHECK: TAG_variable
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "ptr2"
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF3:[a-f0-9]*]]
//
// CHECK: [[TYPEDEF3]]:{{.*}}TAG_typedef
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[PTR3:[a-f0-9]*]]
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "Sptrptr"
//
// CHECK: [[PTR3]]:{{.*}}TAG_pointer_type
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF4:[a-f0-9]*]]
//
// CHECK: [[TYPEDEF4]]:{{.*}}TAG_typedef
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[PTR4:[a-f0-9]*]]
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "Sptr"
//
// CHECK: [[PTR4]]:{{.*}}TAG_pointer_type
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[STRUCT:[a-f0-9]*]]
//
// CHECK: [[STRUCT]]:{{.*}}TAG_structure_type
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "S"
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK-NOT: AT_declaration
// CHECK: AT_byte_size
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: TAG_member
#elif defined(FILE3)
# 1 "Header.h" 1
typedef struct S *Sptr;
typedef Sptr *Sptrptr;
# 3 "Source1.cpp" 2
void foo() {
Sptrptr ptr1 = 0;
}
// Finally we confirm that uniquing is not broken and the same typedef is
// referenced by ptr1.
//
// CHECK: TAG_variable
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_name{{.*}} "ptr1"
// CHECK-NOT: {{DW_TAG|NULL}}
// CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF3]]
// CHECK-NOT: TAG_typedef
// CHECK-NOT: TAG_pointer
// CHECK-NOT: TAG_structure_type
#else
#error "You must define which file you generate"
#endif