1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -gline-tables-only -std=c++11 -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s
2*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -gline-tables-only -std=c++11 -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - -triple i686-linux-gnu | FileCheck %s
3*0a6a1f1dSLionel Sambuc
4*0a6a1f1dSLionel Sambuc // XFAIL: win32
5*0a6a1f1dSLionel Sambuc
6*0a6a1f1dSLionel Sambuc int &src();
7*0a6a1f1dSLionel Sambuc int *sink();
8*0a6a1f1dSLionel Sambuc extern "C" __complex float complex_src();
9*0a6a1f1dSLionel Sambuc extern "C" __complex float *complex_sink();
10*0a6a1f1dSLionel Sambuc
11*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f1()12*0a6a1f1dSLionel Sambuc void f1() {
13*0a6a1f1dSLionel Sambuc #line 100
14*0a6a1f1dSLionel Sambuc * // The store for the assignment should be attributed to the start of the
15*0a6a1f1dSLionel Sambuc // assignment expression here, regardless of the location of subexpressions.
16*0a6a1f1dSLionel Sambuc sink() = src();
17*0a6a1f1dSLionel Sambuc // CHECK: store {{.*}}, !dbg [[DBG_F1:!.*]]
18*0a6a1f1dSLionel Sambuc }
19*0a6a1f1dSLionel Sambuc
20*0a6a1f1dSLionel Sambuc struct foo {
21*0a6a1f1dSLionel Sambuc int i;
22*0a6a1f1dSLionel Sambuc int &j;
23*0a6a1f1dSLionel Sambuc __complex float k;
24*0a6a1f1dSLionel Sambuc foo();
25*0a6a1f1dSLionel Sambuc };
26*0a6a1f1dSLionel Sambuc
27*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
foo()28*0a6a1f1dSLionel Sambuc foo::foo()
29*0a6a1f1dSLionel Sambuc :
30*0a6a1f1dSLionel Sambuc #line 200
31*0a6a1f1dSLionel Sambuc i // CHECK: store i32 {{.*}} !dbg [[DBG_FOO_VALUE:!.*]]
32*0a6a1f1dSLionel Sambuc (src()),
33*0a6a1f1dSLionel Sambuc j // CHECK: store i32* {{.*}} !dbg [[DBG_FOO_REF:!.*]]
34*0a6a1f1dSLionel Sambuc (src()),
35*0a6a1f1dSLionel Sambuc k // CHECK: store float {{.*}} !dbg [[DBG_FOO_COMPLEX:!.*]]
36*0a6a1f1dSLionel Sambuc (complex_src()) {
37*0a6a1f1dSLionel Sambuc }
38*0a6a1f1dSLionel Sambuc
39*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define {{.*}}f2{{.*}}
f2()40*0a6a1f1dSLionel Sambuc void f2() {
41*0a6a1f1dSLionel Sambuc #line 300
42*0a6a1f1dSLionel Sambuc * // CHECK: store float {{.*}} !dbg [[DBG_F2:!.*]]
43*0a6a1f1dSLionel Sambuc complex_sink() = complex_src();
44*0a6a1f1dSLionel Sambuc }
45*0a6a1f1dSLionel Sambuc
46*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f3()47*0a6a1f1dSLionel Sambuc void f3() {
48*0a6a1f1dSLionel Sambuc #line 400
49*0a6a1f1dSLionel Sambuc * // CHECK: store float {{.*}} !dbg [[DBG_F3:!.*]]
50*0a6a1f1dSLionel Sambuc complex_sink() += complex_src();
51*0a6a1f1dSLionel Sambuc }
52*0a6a1f1dSLionel Sambuc
53*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f4()54*0a6a1f1dSLionel Sambuc void f4() {
55*0a6a1f1dSLionel Sambuc #line 500
56*0a6a1f1dSLionel Sambuc auto x // CHECK: store {{.*}} !dbg [[DBG_F4:!.*]]
57*0a6a1f1dSLionel Sambuc = src();
58*0a6a1f1dSLionel Sambuc }
59*0a6a1f1dSLionel Sambuc
60*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f5()61*0a6a1f1dSLionel Sambuc void f5() {
62*0a6a1f1dSLionel Sambuc #line 600
63*0a6a1f1dSLionel Sambuc auto x // CHECK: store float {{.*}} !dbg [[DBG_F5:!.*]]
64*0a6a1f1dSLionel Sambuc = complex_src();
65*0a6a1f1dSLionel Sambuc }
66*0a6a1f1dSLionel Sambuc
67*0a6a1f1dSLionel Sambuc struct agg { int i; };
68*0a6a1f1dSLionel Sambuc agg agg_src();
69*0a6a1f1dSLionel Sambuc
70*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f6()71*0a6a1f1dSLionel Sambuc void f6() {
72*0a6a1f1dSLionel Sambuc agg x;
73*0a6a1f1dSLionel Sambuc #line 700
74*0a6a1f1dSLionel Sambuc x // CHECK: call void @llvm.memcpy{{.*}} !dbg [[DBG_F6:!.*]]
75*0a6a1f1dSLionel Sambuc = agg_src();
76*0a6a1f1dSLionel Sambuc }
77*0a6a1f1dSLionel Sambuc
78*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f7()79*0a6a1f1dSLionel Sambuc void f7() {
80*0a6a1f1dSLionel Sambuc int *src1();
81*0a6a1f1dSLionel Sambuc int src2();
82*0a6a1f1dSLionel Sambuc #line 800
83*0a6a1f1dSLionel Sambuc int x = ( // CHECK: load {{.*}} !dbg [[DBG_F7:!.*]]
84*0a6a1f1dSLionel Sambuc src1())[src2()];
85*0a6a1f1dSLionel Sambuc }
86*0a6a1f1dSLionel Sambuc
87*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f8()88*0a6a1f1dSLionel Sambuc void f8() {
89*0a6a1f1dSLionel Sambuc int src1[1];
90*0a6a1f1dSLionel Sambuc int src2();
91*0a6a1f1dSLionel Sambuc #line 900
92*0a6a1f1dSLionel Sambuc int x = ( // CHECK: load {{.*}} !dbg [[DBG_F8:!.*]]
93*0a6a1f1dSLionel Sambuc src1)[src2()];
94*0a6a1f1dSLionel Sambuc }
95*0a6a1f1dSLionel Sambuc
96*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f9(int i)97*0a6a1f1dSLionel Sambuc void f9(int i) {
98*0a6a1f1dSLionel Sambuc int src1[1][i];
99*0a6a1f1dSLionel Sambuc int src2();
100*0a6a1f1dSLionel Sambuc #line 1000
101*0a6a1f1dSLionel Sambuc auto x = ( // CHECK: getelementptr {{.*}} !dbg [[DBG_F9:!.*]]
102*0a6a1f1dSLionel Sambuc src1)[src2()];
103*0a6a1f1dSLionel Sambuc }
104*0a6a1f1dSLionel Sambuc
105*0a6a1f1dSLionel Sambuc inline void *operator new(decltype(sizeof(1)), void *p) noexcept { return p; }
106*0a6a1f1dSLionel Sambuc
107*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f10()108*0a6a1f1dSLionel Sambuc void f10() {
109*0a6a1f1dSLionel Sambuc void *void_src();
110*0a6a1f1dSLionel Sambuc ( // CHECK: icmp {{.*}} !dbg [[DBG_F10_ICMP:.*]]
111*0a6a1f1dSLionel Sambuc // CHECK: store {{.*}} !dbg [[DBG_F10_STORE:!.*]]
112*0a6a1f1dSLionel Sambuc #line 1100
113*0a6a1f1dSLionel Sambuc new (void_src()) int(src()));
114*0a6a1f1dSLionel Sambuc }
115*0a6a1f1dSLionel Sambuc
116*0a6a1f1dSLionel Sambuc // noexcept just to simplify the codegen a bit
117*0a6a1f1dSLionel Sambuc void fn() noexcept(true);
118*0a6a1f1dSLionel Sambuc
119*0a6a1f1dSLionel Sambuc struct bar {
120*0a6a1f1dSLionel Sambuc bar();
121*0a6a1f1dSLionel Sambuc // noexcept(false) to convolute the global dtor
122*0a6a1f1dSLionel Sambuc ~bar() noexcept(false);
123*0a6a1f1dSLionel Sambuc };
124*0a6a1f1dSLionel Sambuc // global ctor cleanup
125*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
126*0a6a1f1dSLionel Sambuc // CHECK: invoke{{ }}
127*0a6a1f1dSLionel Sambuc // CHECK: invoke{{ }}
128*0a6a1f1dSLionel Sambuc // CHECK: to label {{.*}}, !dbg [[DBG_GLBL_CTOR_B:!.*]]
129*0a6a1f1dSLionel Sambuc
130*0a6a1f1dSLionel Sambuc // terminate caller
131*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
132*0a6a1f1dSLionel Sambuc
133*0a6a1f1dSLionel Sambuc // global dtor cleanup
134*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
135*0a6a1f1dSLionel Sambuc // CHECK: invoke{{ }}
136*0a6a1f1dSLionel Sambuc // CHECK: invoke{{ }}
137*0a6a1f1dSLionel Sambuc // CHECK: to label {{.*}}, !dbg [[DBG_GLBL_DTOR_B:!.*]]
138*0a6a1f1dSLionel Sambuc #line 1500
139*0a6a1f1dSLionel Sambuc bar b[1] = { //
140*0a6a1f1dSLionel Sambuc (fn(), //
141*0a6a1f1dSLionel Sambuc bar())};
142*0a6a1f1dSLionel Sambuc
143*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f11()144*0a6a1f1dSLionel Sambuc __complex double f11() {
145*0a6a1f1dSLionel Sambuc __complex double f;
146*0a6a1f1dSLionel Sambuc // CHECK: store {{.*}} !dbg [[DBG_F11:!.*]]
147*0a6a1f1dSLionel Sambuc #line 1200
148*0a6a1f1dSLionel Sambuc return f;
149*0a6a1f1dSLionel Sambuc }
150*0a6a1f1dSLionel Sambuc
151*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f12()152*0a6a1f1dSLionel Sambuc void f12() {
153*0a6a1f1dSLionel Sambuc int f12_1();
154*0a6a1f1dSLionel Sambuc void f12_2(int = f12_1());
155*0a6a1f1dSLionel Sambuc // CHECK: call {{(signext )?}}i32 {{.*}} !dbg [[DBG_F12:!.*]]
156*0a6a1f1dSLionel Sambuc #line 1300
157*0a6a1f1dSLionel Sambuc f12_2();
158*0a6a1f1dSLionel Sambuc }
159*0a6a1f1dSLionel Sambuc
160*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
f13()161*0a6a1f1dSLionel Sambuc void f13() {
162*0a6a1f1dSLionel Sambuc // CHECK: call {{.*}} !dbg [[DBG_F13:!.*]]
163*0a6a1f1dSLionel Sambuc #define F13_IMPL 1, src()
164*0a6a1f1dSLionel Sambuc 1,
165*0a6a1f1dSLionel Sambuc #line 1400
166*0a6a1f1dSLionel Sambuc F13_IMPL;
167*0a6a1f1dSLionel Sambuc }
168*0a6a1f1dSLionel Sambuc
169*0a6a1f1dSLionel Sambuc struct f14 {
170*0a6a1f1dSLionel Sambuc f14(int);
171*0a6a1f1dSLionel Sambuc };
172*0a6a1f1dSLionel Sambuc
173*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
174*0a6a1f1dSLionel Sambuc struct f14_use {
175*0a6a1f1dSLionel Sambuc // CHECK: call {{.*}}, !dbg [[DBG_F14_CTOR_CALL:![0-9]*]]
176*0a6a1f1dSLionel Sambuc #line 1600
177*0a6a1f1dSLionel Sambuc f14 v
178*0a6a1f1dSLionel Sambuc =
179*0a6a1f1dSLionel Sambuc 1;
180*0a6a1f1dSLionel Sambuc f14_use();
181*0a6a1f1dSLionel Sambuc };
182*0a6a1f1dSLionel Sambuc
183*0a6a1f1dSLionel Sambuc f14_use::f14_use() = default;
184*0a6a1f1dSLionel Sambuc
185*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
186*0a6a1f1dSLionel Sambuc
187*0a6a1f1dSLionel Sambuc // CHECK-LABEL: define
188*0a6a1f1dSLionel Sambuc int f21_a(int = 0);
189*0a6a1f1dSLionel Sambuc void f21_b(int = f21_a());
f21()190*0a6a1f1dSLionel Sambuc void f21() {
191*0a6a1f1dSLionel Sambuc // CHECK: call {{.*}}f21_b{{.*}}, !dbg [[DBG_F21:![0-9]*]]
192*0a6a1f1dSLionel Sambuc #line 2300
193*0a6a1f1dSLionel Sambuc f21_b();
194*0a6a1f1dSLionel Sambuc }
195*0a6a1f1dSLionel Sambuc
196*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F1]] = !MDLocation(line: 100,
197*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_FOO_VALUE]] = !MDLocation(line: 200,
198*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_FOO_REF]] = !MDLocation(line: 202,
199*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_FOO_COMPLEX]] = !MDLocation(line: 204,
200*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F2]] = !MDLocation(line: 300,
201*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F3]] = !MDLocation(line: 400,
202*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F4]] = !MDLocation(line: 500,
203*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F5]] = !MDLocation(line: 600,
204*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F6]] = !MDLocation(line: 700,
205*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F7]] = !MDLocation(line: 800,
206*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F8]] = !MDLocation(line: 900,
207*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F9]] = !MDLocation(line: 1000,
208*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F10_ICMP]] = !MDLocation(line: 1100,
209*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F10_STORE]] = !MDLocation(line: 1100,
210*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_GLBL_CTOR_B]] = !MDLocation(line: 1500,
211*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_GLBL_DTOR_B]] = !MDLocation(line: 1500,
212*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F11]] = !MDLocation(line: 1200,
213*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F12]] = !MDLocation(line: 1300,
214*0a6a1f1dSLionel Sambuc // CHECK: [[DBG_F13]] = !MDLocation(line: 1400,
215