1 // RUN: %clang_cc1 -w -debug-info-kind=line-tables-only -std=c++11 -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - -triple %itanium_abi_triple | FileCheck %s
2 // RUN: %clang_cc1 -w -debug-info-kind=line-tables-only -std=c++11 -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - -triple i686-linux-gnu | FileCheck %s
3
4 int &src();
5 int *sink();
6 extern "C" __complex float complex_src();
7 extern "C" __complex float *complex_sink();
8
9 // CHECK-LABEL: define
f1()10 void f1() {
11 *sink()
12 // CHECK: store {{.*}}, !dbg [[DBG_F1:!.*]]
13 #line 100
14 = //
15 src();
16 }
17
18 struct foo {
19 int i;
20 int &j;
21 __complex float k;
22 foo();
23 };
24
25 // CHECK-LABEL: define
foo()26 foo::foo()
27 :
28 #line 200
29 i // CHECK: store i32 {{.*}} !dbg [[DBG_FOO_VALUE:!.*]]
30 (src()),
31 j // CHECK: store i32* {{.*}} !dbg [[DBG_FOO_REF:!.*]]
32 (src()),
33 k // CHECK: store float {{.*}} !dbg [[DBG_FOO_COMPLEX:!.*]]
34 (complex_src()) {
35 }
36
37 // CHECK-LABEL: define {{.*}}f2{{.*}}
f2()38 void f2() {
39 // CHECK: store float {{.*}} !dbg [[DBG_F2:!.*]]
40 *complex_sink()
41 #line 300
42 = //
43 complex_src();
44 }
45
46 // CHECK-LABEL: define
f3()47 void f3() {
48 // CHECK: store float {{.*}} !dbg [[DBG_F3:!.*]]
49 *complex_sink()
50 #line 400
51 += //
52 complex_src();
53 }
54
55 // CHECK-LABEL: define
f4()56 void f4() {
57 #line 500
58 auto x // CHECK: store {{.*}} !dbg [[DBG_F4:!.*]]
59 = src();
60 }
61
62 // CHECK-LABEL: define
f5()63 void f5() {
64 #line 600
65 auto x // CHECK: store float {{.*}} !dbg [[DBG_F5:!.*]]
66 = complex_src();
67 }
68
69 struct agg { int i; };
70 agg agg_src();
71
72 // CHECK-LABEL: define
f6()73 void f6() {
74 agg x;
75 // CHECK: call void @llvm.memcpy{{.*}} !dbg [[DBG_F6:!.*]]
76 x
77 #line 700
78 = //
79 agg_src();
80 }
81
82 // CHECK-LABEL: define
f7()83 void f7() {
84 int *src1();
85 int src2();
86 #line 800
87 int x = ( // CHECK: load {{.*}} !dbg [[DBG_F7:!.*]]
88 src1())[src2()];
89 }
90
91 // CHECK-LABEL: define
f8()92 void f8() {
93 int src1[1];
94 int src2();
95 #line 900
96 int x = ( // CHECK: load {{.*}} !dbg [[DBG_F8:!.*]]
97 src1)[src2()];
98 }
99
100 // CHECK-LABEL: define
f9(int i)101 void f9(int i) {
102 int src1[1][i];
103 int src2();
104 #line 1000
105 auto x = ( // CHECK: getelementptr {{.*}} !dbg [[DBG_F9:!.*]]
106 src1)[src2()];
107 }
108
109 inline void *operator new(decltype(sizeof(1)), void *p) noexcept { return p; }
110
111 // CHECK-LABEL: define
f10()112 void f10() {
113 void *void_src();
114 (
115 // CHECK: store {{.*}} !dbg [[DBG_F10_STORE:!.*]]
116 #line 1100
117 new (void_src()) int(src()));
118 }
119
120 // noexcept just to simplify the codegen a bit
121 void fn() noexcept(true);
122
123 struct bar {
124 bar();
125 // noexcept(false) to convolute the global dtor
126 ~bar() noexcept(false);
127 };
128 // global ctor cleanup
129 // CHECK-LABEL: define
130 // CHECK: invoke{{ }}
131 // CHECK: invoke{{ }}
132 // CHECK: to label {{.*}}, !dbg [[DBG_GLBL_CTOR_B:!.*]]
133
134 // terminate caller
135 // CHECK-LABEL: define
136
137 // global dtor cleanup
138 // CHECK-LABEL: define
139 // CHECK: invoke{{ }}
140 // CHECK: invoke{{ }}
141 // CHECK: to label {{.*}}, !dbg [[DBG_GLBL_DTOR_B:!.*]]
142 #line 1200
143 bar b[1] = { //
144 (fn(), //
145 bar())};
146
147 // CHECK-LABEL: define
f11()148 __complex double f11() {
149 __complex double f;
150 // CHECK: store {{.*}} !dbg [[DBG_F11:!.*]]
151 #line 1300
152 return f;
153 }
154
155 // CHECK-LABEL: define
f12()156 void f12() {
157 int f12_1();
158 void f12_2(int = f12_1());
159 // CHECK: call {{.*}}{{(signext )?}}i32 {{.*}} !dbg [[DBG_F12:!.*]]
160 #line 1400
161 f12_2();
162 }
163
164 // CHECK-LABEL: define
f13()165 void f13() {
166 // CHECK: call {{.*}} !dbg [[DBG_F13:!.*]]
167 #define F13_IMPL 1, src()
168 1,
169 #line 1500
170 F13_IMPL;
171 }
172
173 struct f14_impl {
174 f14_impl(int);
175 };
176
177 // CHECK-LABEL: define
178 struct f14_use {
179 // CHECK: call {{.*}}f14_impl{{.*}}, !dbg [[DBG_F14_CTOR_CALL:![0-9]*]]
180 #line 1600
181 f14_impl v{//
182 1};
183 f14_use();
184 };
185
186 f14_use::f14_use() = default;
187
188 // CHECK-LABEL: define
189 // CHECK-LABEL: define
190 void func(foo);
f15(foo * f)191 void f15(foo *f) {
192 func(
193 // CHECK: getelementptr {{.*}}, !dbg [[DBG_F15:![0-9]*]]
194 #line 1700
195 f[3]);
196 }
197
198 // CHECK-LABEL: define
f16(__complex float f)199 void f16(__complex float f) {
200 __complex float g = //
201 // CHECK: add {{.*}}, !dbg [[DBG_F16:![0-9]*]]
202 #line 1800
203 f + 1;
204 }
205
206 // CHECK-LABEL: define
f17(int * x)207 void f17(int *x) {
208 1,
209 // CHECK: getelementptr {{.*}}, !dbg [[DBG_F17:![0-9]*]]
210 #line 1900
211 x[1];
212 }
213
214 // CHECK-LABEL: define
f18(int a,int b)215 void f18(int a, int b) {
216 // CHECK: icmp {{.*}}, !dbg [[DBG_F18_1:![0-9]*]]
217 // CHECK: br {{.*}}, !dbg [[DBG_F18_2:![0-9]*]]
218 #line 2000
219 if (a //
220 && //
221 b)
222 ;
223 }
224
225 // CHECK-LABEL: define
f19(int a,int b)226 void f19(int a, int b) {
227 // CHECK: icmp {{.*}}, !dbg [[DBG_F19_1:![0-9]*]]
228 // CHECK: br {{.*}}, !dbg [[DBG_F19_2:![0-9]*]]
229 #line 2100
230 if (a //
231 || //
232 b)
233 ;
234 }
235
236 // CHECK-LABEL: define
f20(int a,int b,int c)237 void f20(int a, int b, int c) {
238 // CHECK: icmp {{.*}}, !dbg [[DBG_F20_1:![0-9]*]]
239 // FIXME: Conditional operator's exprloc should be the '?' not the start of the
240 // expression, then this would go in the right place. (but adding getExprLoc to
241 // the ConditionalOperator breaks the ARC migration tool - need to investigate
242 // further).
243 // CHECK: br {{.*}}, !dbg [[DBG_F20_1]]
244 #line 2200
245 if (a //
246 ? //
247 b : c)
248 ;
249 }
250
251 // CHECK-LABEL: define
252 int f21_a(int = 0);
253 void f21_b(int = f21_a());
f21()254 void f21() {
255 // CHECK: call {{.*}}f21_b{{.*}}, !dbg [[DBG_F21:![0-9]*]]
256 #line 2300
257 f21_b();
258 }
259
260 // CHECK-LABEL: define
261 struct f22_dtor {
262 ~f22_dtor();
263 };
f22()264 void f22() {
265 {
266 f22_dtor f;
267 src();
268 // CHECK: invoke {{.*}}src
269 // CHECK: call {{.*}}, !dbg [[DBG_F22:![0-9]*]]
270 // CHECK: call {{.*}}, !dbg [[DBG_F22]]
271 #line 2400
272 }
273 }
274
275 // CHECK-LABEL: define
276 struct f23_struct {
277 };
278 f23_struct f23_a();
279 void f23_b(f23_struct = f23_a());
f23()280 void f23() {
281 // CHECK: call {{.*}}f23_a{{.*}}, !dbg [[DBG_F23:![0-9]*]]
282 #line 2500
283 f23_b();
284 }
285
286 // CHECK-LABEL: define
287 void f24_a(__complex float = complex_src());
f24()288 void f24() {
289 // CHECK: call {{.*}}complex_src{{.*}}, !dbg [[DBG_F24:![0-9]*]]
290 #line 2600
291 f24_a();
292 }
293
294 // CHECK: [[DBG_F1]] = !DILocation(line: 100,
295 // CHECK: [[DBG_FOO_VALUE]] = !DILocation(line: 200,
296 // CHECK: [[DBG_FOO_REF]] = !DILocation(line: 202,
297 // CHECK: [[DBG_FOO_COMPLEX]] = !DILocation(line: 204,
298 // CHECK: [[DBG_F2]] = !DILocation(line: 300,
299 // CHECK: [[DBG_F3]] = !DILocation(line: 400,
300 // CHECK: [[DBG_F4]] = !DILocation(line: 500,
301 // CHECK: [[DBG_F5]] = !DILocation(line: 600,
302 // CHECK: [[DBG_F6]] = !DILocation(line: 700,
303 // CHECK: [[DBG_F7]] = !DILocation(line: 800,
304 // CHECK: [[DBG_F8]] = !DILocation(line: 900,
305 // CHECK: [[DBG_F9]] = !DILocation(line: 1000,
306 // CHECK: [[DBG_F10_STORE]] = !DILocation(line: 1100,
307 // CHECK: [[DBG_GLBL_CTOR_B]] = !DILocation(line: 1200,
308 // CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 1200,
309 // CHECK: [[DBG_F11]] = !DILocation(line: 1300,
310 // CHECK: [[DBG_F12]] = !DILocation(line: 1400,
311 // CHECK: [[DBG_F13]] = !DILocation(line: 1500,
312 // CHECK: [[DBG_F14_CTOR_CALL]] = !DILocation(line: 1600,
313 // CHECK: [[DBG_F15]] = !DILocation(line: 1700,
314 // CHECK: [[DBG_F16]] = !DILocation(line: 1800,
315 // CHECK: [[DBG_F17]] = !DILocation(line: 1900,
316 // CHECK: [[DBG_F18_1]] = !DILocation(line: 2000,
317 // CHECK: [[DBG_F18_2]] = !DILocation(line: 2001,
318 // CHECK: [[DBG_F19_1]] = !DILocation(line: 2100,
319 // CHECK: [[DBG_F19_2]] = !DILocation(line: 2101,
320 // CHECK: [[DBG_F20_1]] = !DILocation(line: 2200,
321 // CHECK: [[DBG_F23]] = !DILocation(line: 2500,
322 // CHECK: [[DBG_F24]] = !DILocation(line: 2600,
323