• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Compile with:
2    for FILE in `seq 3`; do
3      clang -g -c  X86/odr-fwd-declaration.cpp -DFILE$FILE -o Inputs/odr-fwd-declaration/$FILE.o
4    done
5  */
6 
7 // 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
8 
9 #ifdef FILE1
10 # 1 "Header.h" 1
11 typedef struct S *Sptr;
12 typedef Sptr *Sptrptr;
13 # 3 "Source1.cpp" 2
foo()14 void foo() {
15   Sptrptr ptr1 = 0;
16 }
17 
18 // First we confirm that the typedefs reference the forward declaration of the
19 // struct S.
20 //
21 // CHECK: TAG_variable
22 // CHECK-NOT: {{DW_TAG|NULL}}
23 // CHECK: AT_name{{.*}} "ptr1"
24 // CHECK-NOT: {{DW_TAG|NULL}}
25 // CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF1:[a-f0-9]*]]
26 //
27 // CHECK: [[TYPEDEF1]]:{{.*}}TAG_typedef
28 // CHECK-NOT: {{DW_TAG|NULL}}
29 // CHECK: AT_type{{.*}}0x{{0*}}[[PTR1:[a-f0-9]*]]
30 // CHECK-NOT: {{DW_TAG|NULL}}
31 // CHECK: AT_name{{.*}} "Sptrptr"
32 //
33 // CHECK: [[PTR1]]:{{.*}}TAG_pointer_type
34 // CHECK-NOT: {{DW_TAG|NULL}}
35 // CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF2:[a-f0-9]*]]
36 //
37 // CHECK: [[TYPEDEF2]]:{{.*}}TAG_typedef
38 // CHECK-NOT: {{DW_TAG|NULL}}
39 // CHECK: AT_type{{.*}}0x{{0*}}[[PTR2:[a-f0-9]*]]
40 // CHECK-NOT: {{DW_TAG|NULL}}
41 // CHECK: AT_name{{.*}} "Sptr"
42 //
43 // CHECK: [[PTR2]]:{{.*}}TAG_pointer_type
44 // CHECK-NOT: {{DW_TAG|NULL}}
45 // CHECK: AT_type{{.*}}0x{{0*}}[[FWDSTRUCT:[a-f0-9]*]]
46 //
47 // CHECK: [[FWDSTRUCT]]:{{.*}}TAG_structure_type
48 // CHECK-NOT: {{DW_TAG|NULL}}
49 // CHECK: AT_name{{.*}} "S"
50 // CHECK-NOT: {{DW_TAG|NULL}}
51 // CHECK: AT_declaration
52 // CHECK-NOT AT_byte_size
53 
54 #elif defined(FILE2)
55 # 1 "Header.h" 1
56 typedef struct S *Sptr;
57 typedef Sptr *Sptrptr;
58 # 3 "Source2.cpp" 2
59 struct S {
60   int field;
61 };
bar()62 void bar() {
63   Sptrptr ptr2 = 0;
64 }
65 
66 // Next we confirm that the typedefs reference the definition rather than the
67 // previous declaration of S.
68 //
69 // CHECK: TAG_variable
70 // CHECK-NOT: {{DW_TAG|NULL}}
71 // CHECK: AT_name{{.*}} "ptr2"
72 // CHECK-NOT: {{DW_TAG|NULL}}
73 // CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF3:[a-f0-9]*]]
74 //
75 // CHECK: [[TYPEDEF3]]:{{.*}}TAG_typedef
76 // CHECK-NOT: {{DW_TAG|NULL}}
77 // CHECK: AT_type{{.*}}0x{{0*}}[[PTR3:[a-f0-9]*]]
78 // CHECK-NOT: {{DW_TAG|NULL}}
79 // CHECK: AT_name{{.*}} "Sptrptr"
80 //
81 // CHECK: [[PTR3]]:{{.*}}TAG_pointer_type
82 // CHECK-NOT: {{DW_TAG|NULL}}
83 // CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF4:[a-f0-9]*]]
84 //
85 // CHECK: [[TYPEDEF4]]:{{.*}}TAG_typedef
86 // CHECK-NOT: {{DW_TAG|NULL}}
87 // CHECK: AT_type{{.*}}0x{{0*}}[[PTR4:[a-f0-9]*]]
88 // CHECK-NOT: {{DW_TAG|NULL}}
89 // CHECK: AT_name{{.*}} "Sptr"
90 //
91 // CHECK: [[PTR4]]:{{.*}}TAG_pointer_type
92 // CHECK-NOT: {{DW_TAG|NULL}}
93 // CHECK: AT_type{{.*}}0x{{0*}}[[STRUCT:[a-f0-9]*]]
94 //
95 // CHECK: [[STRUCT]]:{{.*}}TAG_structure_type
96 // CHECK-NOT: {{DW_TAG|NULL}}
97 // CHECK: AT_name{{.*}} "S"
98 // CHECK-NOT: {{DW_TAG|NULL}}
99 // CHECK-NOT: AT_declaration
100 // CHECK: AT_byte_size
101 // CHECK-NOT: {{DW_TAG|NULL}}
102 // CHECK: TAG_member
103 
104 #elif defined(FILE3)
105 # 1 "Header.h" 1
106 typedef struct S *Sptr;
107 typedef Sptr *Sptrptr;
108 # 3 "Source1.cpp" 2
foo()109 void foo() {
110   Sptrptr ptr1 = 0;
111 }
112 
113 // Finally we confirm that uniquing is not broken and the same typedef is
114 // referenced by ptr1.
115 //
116 // CHECK: TAG_variable
117 // CHECK-NOT: {{DW_TAG|NULL}}
118 // CHECK: AT_name{{.*}} "ptr1"
119 // CHECK-NOT: {{DW_TAG|NULL}}
120 // CHECK: AT_type{{.*}}0x{{0*}}[[TYPEDEF3]]
121 // CHECK-NOT: TAG_typedef
122 // CHECK-NOT: TAG_pointer
123 // CHECK-NOT: TAG_structure_type
124 
125 #else
126 #error "You must define which file you generate"
127 #endif
128