summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/debug-info-line.cpp
blob: 100cfa6e5e9a258cdcd60a1764223c5807a5188e (plain)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
// RUN: %clang_cc1 -w -debug-info-kind=line-tables-only -std=c++11 -fexceptions -fcxx-exceptions -S -mllvm -no-discriminators -emit-llvm %s -o - -triple %itanium_abi_triple | FileCheck %s
// RUN: %clang_cc1 -w -debug-info-kind=line-tables-only -std=c++11 -fexceptions -fcxx-exceptions -S -mllvm -no-discriminators -emit-llvm %s -o - -triple i686-linux-gnu | FileCheck %s
// RUN: %clang_cc1 -w -debug-info-kind=line-directives-only -std=c++11 -fexceptions -fcxx-exceptions -S -mllvm -no-discriminators -emit-llvm %s -o - -triple %itanium_abi_triple | FileCheck %s
// RUN: %clang_cc1 -w -debug-info-kind=line-directives-only -std=c++11 -fexceptions -fcxx-exceptions -S -mllvm -no-discriminators -emit-llvm %s -o - -triple i686-linux-gnu | FileCheck %s

int &src();
int *sink();
extern "C" __complex float complex_src();
extern "C" __complex float *complex_sink();

// CHECK-LABEL: define
void f1() {
  *sink()
  // CHECK: store {{.*}}, !dbg [[DBG_F1:!.*]]
#line 100
      = //
      src();
}

struct foo {
  int i;
  int &j;
  __complex float k;
  foo();
};

// CHECK-LABEL: define
foo::foo()
    :
#line 200
      i // CHECK: store i32 {{.*}} !dbg [[DBG_FOO_VALUE:!.*]]
      (src()),
      j // CHECK: store i32* {{.*}} !dbg [[DBG_FOO_REF:!.*]]
      (src()),
      k // CHECK: store float {{.*}} !dbg [[DBG_FOO_COMPLEX:!.*]]
      (complex_src()) {
}

// CHECK-LABEL: define {{.*}}f2{{.*}}
void f2() {
  // CHECK: store float {{.*}} !dbg [[DBG_F2:!.*]]
  *complex_sink()
#line 300
      = //
      complex_src();
}

// CHECK-LABEL: define
void f3() {
  // CHECK: store float {{.*}} !dbg [[DBG_F3:!.*]]
  *complex_sink()
#line 400
      += //
      complex_src();
}

// CHECK-LABEL: define
void f4() {
#line 500
  auto x // CHECK: store {{.*}} !dbg [[DBG_F4:!.*]]
      = src();
}

// CHECK-LABEL: define
void f5() {
#line 600
  auto x // CHECK: store float {{.*}} !dbg [[DBG_F5:!.*]]
      = complex_src();
}

struct agg { int i; };
agg agg_src();

// CHECK-LABEL: define
void f6() {
  agg x;
  // CHECK: call void @llvm.memcpy{{.*}} !dbg [[DBG_F6:!.*]]
  x
#line 700
      = //
      agg_src();
}

// CHECK-LABEL: define
void f7() {
  int *src1();
  int src2();
#line 800
  int x = ( // CHECK: load {{.*}} !dbg [[DBG_F7:!.*]]
      src1())[src2()];
}

// CHECK-LABEL: define
void f8() {
  int src1[1];
  int src2();
#line 900
  int x = ( // CHECK: load {{.*}} !dbg [[DBG_F8:!.*]]
      src1)[src2()];
}

// CHECK-LABEL: define
void f9(int i) {
  int src1[1][i];
  int src2();
#line 1000
  auto x = ( // CHECK: getelementptr {{.*}} !dbg [[DBG_F9:!.*]]
      src1)[src2()];
}

inline void *operator new(decltype(sizeof(1)), void *p) noexcept { return p; }

// CHECK-LABEL: define
void f10() {
  void *void_src();
  (
    // CHECK: store {{.*}} !dbg [[DBG_F10_STORE:!.*]]
#line 1100
      new (void_src()) int(src()));
}

// noexcept just to simplify the codegen a bit
void fn() noexcept(true);

struct bar {
  bar();
  // noexcept(false) to convolute the global dtor
  ~bar() noexcept(false);
};
// global ctor cleanup
// CHECK-LABEL: define
// CHECK: invoke{{ }}
// CHECK: invoke{{ }}
// CHECK:   to label {{.*}}, !dbg [[DBG_GLBL_CTOR_B:!.*]]

// terminate caller
// CHECK-LABEL: define

// global dtor cleanup
// CHECK-LABEL: define
// CHECK: invoke{{ }}
// CHECK: invoke{{ }}
// CHECK:   to label {{.*}}, !dbg [[DBG_GLBL_DTOR_B:!.*]]
#line 1200
bar b[1] = { //
    (fn(),   //
     bar())};

// CHECK-LABEL: define
__complex double f11() {
  __complex double f;
// CHECK: store {{.*}} !dbg [[DBG_F11:!.*]]
#line 1300
  return f;
}

// CHECK-LABEL: define
void f12() {
  int f12_1();
  void f12_2(int = f12_1());
// CHECK: call {{.*}}{{(signext )?}}i32 {{.*}} !dbg [[DBG_F12:!.*]]
#line 1400
  f12_2();
}

// CHECK-LABEL: define
void f13() {
// CHECK: call {{.*}} !dbg [[DBG_F13:!.*]]
#define F13_IMPL 1, src()
  1,
#line 1500
  F13_IMPL;
}

struct f14_impl {
  f14_impl(int);
};

// CHECK-LABEL: define
struct f14_use {
// CHECK: call {{.*}}f14_impl{{.*}}, !dbg [[DBG_F14_CTOR_CALL:![0-9]*]]
#line 1600
  f14_impl v{//
             1};
  f14_use();
};

f14_use::f14_use() = default;

// CHECK-LABEL: define
// CHECK-LABEL: define
void func(foo);
void f15(foo *f) {
  func(
// CHECK: getelementptr {{.*}}, !dbg [[DBG_F15:![0-9]*]]
#line 1700
      f[3]);
}

// CHECK-LABEL: define
void f16(__complex float f) {
  __complex float g = //
// CHECK: add {{.*}}, !dbg [[DBG_F16:![0-9]*]]
#line 1800
      f + 1;
}

// CHECK-LABEL: define
void f17(int *x) {
  1,
// CHECK: getelementptr {{.*}}, !dbg [[DBG_F17:![0-9]*]]
#line 1900
      x[1];
}

// CHECK-LABEL: define
void f18(int a, int b) {
// CHECK: icmp {{.*}}, !dbg [[DBG_F18_1:![0-9]*]]
// CHECK: br {{.*}}, !dbg [[DBG_F18_2:![0-9]*]]
#line 2000
  if (a  //
      && //
      b)
    ;
}

// CHECK-LABEL: define
void f19(int a, int b) {
// CHECK: icmp {{.*}}, !dbg [[DBG_F19_1:![0-9]*]]
// CHECK: br {{.*}}, !dbg [[DBG_F19_2:![0-9]*]]
#line 2100
  if (a  //
      || //
      b)
    ;
}

// CHECK-LABEL: define
void f20(int a, int b, int c) {
// CHECK: icmp {{.*}}, !dbg [[DBG_F20_1:![0-9]*]]
// FIXME: Conditional operator's exprloc should be the '?' not the start of the
// expression, then this would go in the right place. (but adding getExprLoc to
// the ConditionalOperator breaks the ARC migration tool - need to investigate
// further).
// CHECK: br {{.*}}, !dbg [[DBG_F20_1]]
#line 2200
  if (a  //
      ? //
      b : c)
    ;
}

// CHECK-LABEL: define
int f21_a(int = 0);
void f21_b(int = f21_a());
void f21() {
// CHECK: call {{.*}}f21_b{{.*}}, !dbg [[DBG_F21:![0-9]*]]
#line 2300
  f21_b();
}

// CHECK-LABEL: define
struct f22_dtor {
  ~f22_dtor();
};
void f22() {
  {
    f22_dtor f;
    src();
// CHECK: invoke {{.*}}src
// CHECK: call {{.*}}, !dbg [[DBG_F22:![0-9]*]]
// CHECK: call {{.*}}, !dbg [[DBG_F22]]
#line 2400
  }
}

// CHECK-LABEL: define
struct f23_struct {
};
f23_struct f23_a();
void f23_b(f23_struct = f23_a());
void f23() {
// CHECK: call {{.*}}f23_a{{.*}}, !dbg [[DBG_F23:![0-9]*]]
#line 2500
  f23_b();
}

// CHECK-LABEL: define
void f24_a(__complex float = complex_src());
void f24() {
// CHECK: call {{.*}}complex_src{{.*}}, !dbg [[DBG_F24:![0-9]*]]
#line 2600
  f24_a();
}

// CHECK: [[DBG_F1]] = !DILocation(line: 100,
// CHECK: [[DBG_FOO_VALUE]] = !DILocation(line: 200,
// CHECK: [[DBG_FOO_REF]] = !DILocation(line: 202,
// CHECK: [[DBG_FOO_COMPLEX]] = !DILocation(line: 204,
// CHECK: [[DBG_F2]] = !DILocation(line: 300,
// CHECK: [[DBG_F3]] = !DILocation(line: 400,
// CHECK: [[DBG_F4]] = !DILocation(line: 500,
// CHECK: [[DBG_F5]] = !DILocation(line: 600,
// CHECK: [[DBG_F6]] = !DILocation(line: 700,
// CHECK: [[DBG_F7]] = !DILocation(line: 800,
// CHECK: [[DBG_F8]] = !DILocation(line: 900,
// CHECK: [[DBG_F9]] = !DILocation(line: 1000,
// CHECK: [[DBG_F10_STORE]] = !DILocation(line: 1100,
// CHECK: [[DBG_GLBL_CTOR_B]] = !DILocation(line: 1200,
// CHECK: [[DBG_GLBL_DTOR_B]] = !DILocation(line: 1200,
// CHECK: [[DBG_F11]] = !DILocation(line: 1300,
// CHECK: [[DBG_F12]] = !DILocation(line: 1400,
// CHECK: [[DBG_F13]] = !DILocation(line: 1500,
// CHECK: [[DBG_F14_CTOR_CALL]] = !DILocation(line: 1600,
// CHECK: [[DBG_F15]] = !DILocation(line: 1700,
// CHECK: [[DBG_F16]] = !DILocation(line: 1800,
// CHECK: [[DBG_F17]] = !DILocation(line: 1900,
// CHECK: [[DBG_F18_1]] = !DILocation(line: 2000,
// CHECK: [[DBG_F18_2]] = !DILocation(line: 2001,
// CHECK: [[DBG_F19_1]] = !DILocation(line: 2100,
// CHECK: [[DBG_F19_2]] = !DILocation(line: 2101,
// CHECK: [[DBG_F20_1]] = !DILocation(line: 2200,
// CHECK: [[DBG_F23]] = !DILocation(line: 2500,
// CHECK: [[DBG_F24]] = !DILocation(line: 2600,