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