[clang][modules] Don't prevent translation of FW_Private includes when explicitly...
[llvm-project.git] / clang / test / Analysis / scopes-cfg-output.cpp
blob4eb8967e3735169f6adc2983c3d64b92d52ccd4f
1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG -analyzer-config cfg-scopes=true %s > %t 2>&1
2 // RUN: FileCheck --input-file=%t %s
4 class A {
5 public:
6 // CHECK: [B1 (ENTRY)]
7 // CHECK-NEXT: Succs (1): B0
8 // CHECK: [B0 (EXIT)]
9 // CHECK-NEXT: Preds (1): B1
10 A() {}
12 // CHECK: [B1 (ENTRY)]
13 // CHECK-NEXT: Succs (1): B0
14 // CHECK: [B0 (EXIT)]
15 // CHECK-NEXT: Preds (1): B1
16 ~A() {}
18 // CHECK: [B2 (ENTRY)]
19 // CHECK-NEXT: Succs (1): B1
20 // CHECK: [B1]
21 // CHECK-NEXT: 1: 1
22 // CHECK-NEXT: 2: return [B1.1];
23 // CHECK-NEXT: Preds (1): B2
24 // CHECK-NEXT: Succs (1): B0
25 // CHECK: [B0 (EXIT)]
26 // CHECK-NEXT: Preds (1): B1
27 operator int() const { return 1; }
28 int *p;
31 int getX();
32 extern const bool UV;
34 // CHECK: [B2 (ENTRY)]
35 // CHECK-NEXT: Succs (1): B1
36 // CHECK: [B1]
37 // CHECK-NEXT: 1: CFGScopeBegin(a)
38 // CHECK-NEXT: 2: (CXXConstructExpr, [B1.3], A[2])
39 // CHECK-NEXT: 3: A a[2];
40 // CHECK-NEXT: 4: (CXXConstructExpr, [B1.5], A[0])
41 // CHECK-NEXT: 5: A b[0];
42 // CHECK-NEXT: 6: [B1.3].~A[2]() (Implicit destructor)
43 // CHECK-NEXT: 7: CFGScopeEnd(a)
44 // CHECK-NEXT: Preds (1): B2
45 // CHECK-NEXT: Succs (1): B0
46 // CHECK: [B0 (EXIT)]
47 // CHECK-NEXT: Preds (1): B1
48 void test_array() {
49 A a[2];
50 A b[0];
53 // CHECK: [B2 (ENTRY)]
54 // CHECK-NEXT: Succs (1): B1
55 // CHECK: [B1]
56 // CHECK-NEXT: 1: CFGScopeBegin(a)
57 // CHECK-NEXT: 2: (CXXConstructExpr, [B1.3], A)
58 // CHECK-NEXT: 3: A a;
59 // CHECK-NEXT: 4: CFGScopeBegin(c)
60 // CHECK-NEXT: 5: (CXXConstructExpr, [B1.6], A)
61 // CHECK-NEXT: 6: A c;
62 // CHECK-NEXT: 7: (CXXConstructExpr, [B1.8], A)
63 // CHECK-NEXT: 8: A d;
64 // CHECK-NEXT: 9: [B1.8].~A() (Implicit destructor)
65 // CHECK-NEXT: 10: [B1.6].~A() (Implicit destructor)
66 // CHECK-NEXT: 11: CFGScopeEnd(c)
67 // CHECK-NEXT: 12: (CXXConstructExpr, [B1.13], A)
68 // CHECK-NEXT: 13: A b;
69 // CHECK-NEXT: 14: [B1.13].~A() (Implicit destructor)
70 // CHECK-NEXT: 15: [B1.3].~A() (Implicit destructor)
71 // CHECK-NEXT: 16: CFGScopeEnd(a)
72 // CHECK-NEXT: Preds (1): B2
73 // CHECK-NEXT: Succs (1): B0
74 // CHECK: [B0 (EXIT)]
75 // CHECK-NEXT: Preds (1): B1
76 void test_scope() {
77 A a;
78 { A c;
79 A d;
81 A b;
84 // CHECK: [B4 (ENTRY)]
85 // CHECK-NEXT: Succs (1): B3
86 // CHECK: [B1]
87 // CHECK-NEXT: 1: (CXXConstructExpr, [B1.2], A)
88 // CHECK-NEXT: 2: A c;
89 // CHECK-NEXT: 3: [B1.2].~A() (Implicit destructor)
90 // CHECK-NEXT: 4: [B3.5].~A() (Implicit destructor)
91 // CHECK-NEXT: 5: [B3.3].~A() (Implicit destructor)
92 // CHECK-NEXT: 6: CFGScopeEnd(a)
93 // CHECK-NEXT: Preds (1): B3
94 // CHECK-NEXT: Succs (1): B0
95 // CHECK: [B2]
96 // CHECK-NEXT: 1: return;
97 // CHECK-NEXT: 2: [B3.5].~A() (Implicit destructor)
98 // CHECK-NEXT: 3: [B3.3].~A() (Implicit destructor)
99 // CHECK-NEXT: 4: CFGScopeEnd(a)
100 // CHECK-NEXT: Preds (1): B3
101 // CHECK-NEXT: Succs (1): B0
102 // CHECK: [B3]
103 // CHECK-NEXT: 1: CFGScopeBegin(a)
104 // CHECK-NEXT: 2: (CXXConstructExpr, [B3.3], A)
105 // CHECK-NEXT: 3: A a;
106 // CHECK-NEXT: 4: (CXXConstructExpr, [B3.5], A)
107 // CHECK-NEXT: 5: A b;
108 // CHECK-NEXT: 6: UV
109 // CHECK-NEXT: 7: [B3.6] (ImplicitCastExpr, LValueToRValue, _Bool)
110 // CHECK-NEXT: T: if [B3.7]
111 // CHECK-NEXT: Preds (1): B4
112 // CHECK-NEXT: Succs (2): B2 B1
113 // CHECK: [B0 (EXIT)]
114 // CHECK-NEXT: Preds (2): B1 B2
115 void test_return() {
116 A a;
117 A b;
118 if (UV) return;
119 A c;
122 // CHECK: [B5 (ENTRY)]
123 // CHECK-NEXT: Succs (1): B4
124 // CHECK: [B1]
125 // CHECK-NEXT: 1: [B4.8].~A() (Implicit destructor)
126 // CHECK-NEXT: 2: CFGScopeEnd(b)
127 // CHECK-NEXT: 3: [B4.3].~A() (Implicit destructor)
128 // CHECK-NEXT: 4: CFGScopeEnd(a)
129 // CHECK-NEXT: Preds (2): B2 B3
130 // CHECK-NEXT: Succs (1): B0
131 // CHECK: [B2]
132 // CHECK-NEXT: 1: CFGScopeBegin(c)
133 // CHECK-NEXT: 2: (CXXConstructExpr, [B2.3], A)
134 // CHECK-NEXT: 3: A c;
135 // CHECK-NEXT: 4: [B2.3].~A() (Implicit destructor)
136 // CHECK-NEXT: 5: CFGScopeEnd(c)
137 // CHECK-NEXT: Preds (1): B4
138 // CHECK-NEXT: Succs (1): B1
139 // CHECK: [B3]
140 // CHECK-NEXT: 1: CFGScopeBegin(c)
141 // CHECK-NEXT: 2: (CXXConstructExpr, [B3.3], A)
142 // CHECK-NEXT: 3: A c;
143 // CHECK-NEXT: 4: [B3.3].~A() (Implicit destructor)
144 // CHECK-NEXT: 5: CFGScopeEnd(c)
145 // CHECK-NEXT: Preds (1): B4
146 // CHECK-NEXT: Succs (1): B1
147 // CHECK: [B4]
148 // CHECK-NEXT: 1: CFGScopeBegin(a)
149 // CHECK-NEXT: 2: (CXXConstructExpr, [B4.3], A)
150 // CHECK-NEXT: 3: A a;
151 // CHECK-NEXT: 4: CFGScopeBegin(b)
152 // CHECK-NEXT: 5: a
153 // CHECK-NEXT: 6: [B4.5] (ImplicitCastExpr, NoOp, const A)
154 // CHECK-NEXT: 7: [B4.6] (CXXConstructExpr, [B4.8], A)
155 // CHECK-NEXT: 8: A b = a;
156 // CHECK-NEXT: 9: b
157 // CHECK-NEXT: 10: [B4.9] (ImplicitCastExpr, NoOp, const class A)
158 // CHECK-NEXT: 11: [B4.10].operator int
159 // CHECK-NEXT: 12: [B4.10]
160 // CHECK-NEXT: 13: [B4.12] (ImplicitCastExpr, UserDefinedConversion, int)
161 // CHECK-NEXT: 14: [B4.13] (ImplicitCastExpr, IntegralToBoolean, _Bool)
162 // CHECK-NEXT: T: if [B4.14]
163 // CHECK-NEXT: Preds (1): B5
164 // CHECK-NEXT: Succs (2): B3 B2
165 // CHECK: [B0 (EXIT)]
166 // CHECK-NEXT: Preds (1): B1
167 void test_if_implicit_scope() {
168 A a;
169 if (A b = a)
170 A c;
171 else A c;
174 // CHECK: [B9 (ENTRY)]
175 // CHECK-NEXT: Succs (1): B8
176 // CHECK: [B1]
177 // CHECK-NEXT: 1: [B8.8].~A() (Implicit destructor)
178 // CHECK-NEXT: 2: CFGScopeEnd(b)
179 // CHECK-NEXT: 3: (CXXConstructExpr, [B1.4], A)
180 // CHECK-NEXT: 4: A e;
181 // CHECK-NEXT: 5: [B1.4].~A() (Implicit destructor)
182 // CHECK-NEXT: 6: [B8.3].~A() (Implicit destructor)
183 // CHECK-NEXT: 7: CFGScopeEnd(a)
184 // CHECK-NEXT: Preds (2): B2 B5
185 // CHECK-NEXT: Succs (1): B0
186 // CHECK: [B2]
187 // CHECK-NEXT: 1: (CXXConstructExpr, [B2.2], A)
188 // CHECK-NEXT: 2: A d;
189 // CHECK-NEXT: 3: [B2.2].~A() (Implicit destructor)
190 // CHECK-NEXT: 4: [B4.3].~A() (Implicit destructor)
191 // CHECK-NEXT: 5: CFGScopeEnd(c)
192 // CHECK-NEXT: Preds (1): B4
193 // CHECK-NEXT: Succs (1): B1
194 // CHECK: [B3]
195 // CHECK-NEXT: 1: return;
196 // CHECK-NEXT: 2: [B4.3].~A() (Implicit destructor)
197 // CHECK-NEXT: 3: CFGScopeEnd(c)
198 // CHECK-NEXT: 4: [B8.8].~A() (Implicit destructor)
199 // CHECK-NEXT: 5: CFGScopeEnd(b)
200 // CHECK-NEXT: 6: [B8.3].~A() (Implicit destructor)
201 // CHECK-NEXT: 7: CFGScopeEnd(a)
202 // CHECK-NEXT: Preds (1): B4
203 // CHECK-NEXT: Succs (1): B0
204 // CHECK: [B4]
205 // CHECK-NEXT: 1: CFGScopeBegin(c)
206 // CHECK-NEXT: 2: (CXXConstructExpr, [B4.3], A)
207 // CHECK-NEXT: 3: A c;
208 // CHECK-NEXT: 4: UV
209 // CHECK-NEXT: 5: [B4.4] (ImplicitCastExpr, LValueToRValue, _Bool)
210 // CHECK-NEXT: T: if [B4.5]
211 // CHECK-NEXT: Preds (1): B8
212 // CHECK-NEXT: Succs (2): B3 B2
213 // CHECK: [B5]
214 // CHECK-NEXT: 1: (CXXConstructExpr, [B5.2], A)
215 // CHECK-NEXT: 2: A d;
216 // CHECK-NEXT: 3: [B5.2].~A() (Implicit destructor)
217 // CHECK-NEXT: 4: [B7.3].~A() (Implicit destructor)
218 // CHECK-NEXT: 5: CFGScopeEnd(c)
219 // CHECK-NEXT: Preds (1): B7
220 // CHECK-NEXT: Succs (1): B1
221 // CHECK: [B6]
222 // CHECK-NEXT: 1: return;
223 // CHECK-NEXT: 2: [B7.3].~A() (Implicit destructor)
224 // CHECK-NEXT: 3: CFGScopeEnd(c)
225 // CHECK-NEXT: 4: [B8.8].~A() (Implicit destructor)
226 // CHECK-NEXT: 5: CFGScopeEnd(b)
227 // CHECK-NEXT: 6: [B8.3].~A() (Implicit destructor)
228 // CHECK-NEXT: 7: CFGScopeEnd(a)
229 // CHECK-NEXT: Preds (1): B7
230 // CHECK-NEXT: Succs (1): B0
231 // CHECK: [B7]
232 // CHECK-NEXT: 1: CFGScopeBegin(c)
233 // CHECK-NEXT: 2: (CXXConstructExpr, [B7.3], A)
234 // CHECK-NEXT: 3: A c;
235 // CHECK-NEXT: 4: UV
236 // CHECK-NEXT: 5: [B7.4] (ImplicitCastExpr, LValueToRValue, _Bool)
237 // CHECK-NEXT: T: if [B7.5]
238 // CHECK-NEXT: Preds (1): B8
239 // CHECK-NEXT: Succs (2): B6 B5
240 // CHECK: [B8]
241 // CHECK-NEXT: 1: CFGScopeBegin(a)
242 // CHECK-NEXT: 2: (CXXConstructExpr, [B8.3], A)
243 // CHECK-NEXT: 3: A a;
244 // CHECK-NEXT: 4: CFGScopeBegin(b)
245 // CHECK-NEXT: 5: a
246 // CHECK-NEXT: 6: [B8.5] (ImplicitCastExpr, NoOp, const A)
247 // CHECK-NEXT: 7: [B8.6] (CXXConstructExpr, [B8.8], A)
248 // CHECK-NEXT: 8: A b = a;
249 // CHECK-NEXT: 9: b
250 // CHECK-NEXT: 10: [B8.9] (ImplicitCastExpr, NoOp, const class A)
251 // CHECK-NEXT: 11: [B8.10].operator int
252 // CHECK-NEXT: 12: [B8.10]
253 // CHECK-NEXT: 13: [B8.12] (ImplicitCastExpr, UserDefinedConversion, int)
254 // CHECK-NEXT: 14: [B8.13] (ImplicitCastExpr, IntegralToBoolean, _Bool)
255 // CHECK-NEXT: T: if [B8.14]
256 // CHECK-NEXT: Preds (1): B9
257 // CHECK-NEXT: Succs (2): B7 B4
258 // CHECK: [B0 (EXIT)]
259 // CHECK-NEXT: Preds (3): B1 B3 B6
260 void test_if_jumps() {
261 A a;
262 if (A b = a) {
263 A c;
264 if (UV) return;
265 A d;
266 } else {
267 A c;
268 if (UV) return;
269 A d;
271 A e;
274 // CHECK: [B6 (ENTRY)]
275 // CHECK-NEXT: Succs (1): B5
276 // CHECK: [B1]
277 // CHECK-NEXT: 1: [B4.5].~A() (Implicit destructor)
278 // CHECK-NEXT: 2: CFGScopeEnd(b)
279 // CHECK-NEXT: 3: [B5.3].~A() (Implicit destructor)
280 // CHECK-NEXT: 4: CFGScopeEnd(a)
281 // CHECK-NEXT: Preds (1): B4
282 // CHECK-NEXT: Succs (1): B0
283 // CHECK: [B2]
284 // CHECK-NEXT: Preds (1): B3
285 // CHECK-NEXT: Succs (1): B4
286 // CHECK: [B3]
287 // CHECK-NEXT: 1: CFGScopeBegin(c)
288 // CHECK-NEXT: 2: (CXXConstructExpr, [B3.3], A)
289 // CHECK-NEXT: 3: A c;
290 // CHECK-NEXT: 4: [B3.3].~A() (Implicit destructor)
291 // CHECK-NEXT: 5: CFGScopeEnd(c)
292 // CHECK-NEXT: 6: [B4.5].~A() (Implicit destructor)
293 // CHECK-NEXT: 7: CFGScopeEnd(b)
294 // CHECK-NEXT: Preds (1): B4
295 // CHECK-NEXT: Succs (1): B2
296 // CHECK: [B4]
297 // CHECK-NEXT: 1: CFGScopeBegin(b)
298 // CHECK-NEXT: 2: a
299 // CHECK-NEXT: 3: [B4.2] (ImplicitCastExpr, NoOp, const A)
300 // CHECK-NEXT: 4: [B4.3] (CXXConstructExpr, [B4.5], A)
301 // CHECK-NEXT: 5: A b = a;
302 // CHECK-NEXT: 6: b
303 // CHECK-NEXT: 7: [B4.6] (ImplicitCastExpr, NoOp, const class A)
304 // CHECK-NEXT: 8: [B4.7].operator int
305 // CHECK-NEXT: 9: [B4.7]
306 // CHECK-NEXT: 10: [B4.9] (ImplicitCastExpr, UserDefinedConversion, int)
307 // CHECK-NEXT: 11: [B4.10] (ImplicitCastExpr, IntegralToBoolean, _Bool)
308 // CHECK-NEXT: T: while [B4.11]
309 // CHECK-NEXT: Preds (2): B2 B5
310 // CHECK-NEXT: Succs (2): B3 B1
311 // CHECK: [B5]
312 // CHECK-NEXT: 1: CFGScopeBegin(a)
313 // CHECK-NEXT: 2: (CXXConstructExpr, [B5.3], A)
314 // CHECK-NEXT: 3: A a;
315 // CHECK-NEXT: Preds (1): B6
316 // CHECK-NEXT: Succs (1): B4
317 // CHECK: [B0 (EXIT)]
318 // CHECK-NEXT: Preds (1): B1
319 void test_while_implicit_scope() {
320 A a;
321 while (A b = a)
322 A c;
325 // CHECK: [B12 (ENTRY)]
326 // CHECK-NEXT: Succs (1): B11
327 // CHECK: [B1]
328 // CHECK-NEXT: 1: [B10.5].~A() (Implicit destructor)
329 // CHECK-NEXT: 2: CFGScopeEnd(b)
330 // CHECK-NEXT: 3: (CXXConstructExpr, [B1.4], A)
331 // CHECK-NEXT: 4: A e;
332 // CHECK-NEXT: 5: [B1.4].~A() (Implicit destructor)
333 // CHECK-NEXT: 6: [B11.3].~A() (Implicit destructor)
334 // CHECK-NEXT: 7: CFGScopeEnd(a)
335 // CHECK-NEXT: Preds (2): B8 B10
336 // CHECK-NEXT: Succs (1): B0
337 // CHECK: [B2]
338 // CHECK-NEXT: Preds (2): B3 B6
339 // CHECK-NEXT: Succs (1): B10
340 // CHECK: [B3]
341 // CHECK-NEXT: 1: (CXXConstructExpr, [B3.2], A)
342 // CHECK-NEXT: 2: A d;
343 // CHECK-NEXT: 3: [B3.2].~A() (Implicit destructor)
344 // CHECK-NEXT: 4: [B9.3].~A() (Implicit destructor)
345 // CHECK-NEXT: 5: CFGScopeEnd(c)
346 // CHECK-NEXT: 6: [B10.5].~A() (Implicit destructor)
347 // CHECK-NEXT: 7: CFGScopeEnd(b)
348 // CHECK-NEXT: Preds (1): B5
349 // CHECK-NEXT: Succs (1): B2
350 // CHECK: [B4]
351 // CHECK-NEXT: 1: return;
352 // CHECK-NEXT: 2: [B9.3].~A() (Implicit destructor)
353 // CHECK-NEXT: 3: CFGScopeEnd(c)
354 // CHECK-NEXT: 4: [B10.5].~A() (Implicit destructor)
355 // CHECK-NEXT: 5: CFGScopeEnd(b)
356 // CHECK-NEXT: 6: [B11.3].~A() (Implicit destructor)
357 // CHECK-NEXT: 7: CFGScopeEnd(a)
358 // CHECK-NEXT: Preds (1): B5
359 // CHECK-NEXT: Succs (1): B0
360 // CHECK: [B5]
361 // CHECK-NEXT: 1: UV
362 // CHECK-NEXT: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
363 // CHECK-NEXT: T: if [B5.2]
364 // CHECK-NEXT: Preds (1): B7
365 // CHECK-NEXT: Succs (2): B4 B3
366 // CHECK: [B6]
367 // CHECK-NEXT: 1: [B9.3].~A() (Implicit destructor)
368 // CHECK-NEXT: 2: CFGScopeEnd(c)
369 // CHECK-NEXT: 3: [B10.5].~A() (Implicit destructor)
370 // CHECK-NEXT: 4: CFGScopeEnd(b)
371 // CHECK-NEXT: T: continue;
372 // CHECK-NEXT: Preds (1): B7
373 // CHECK-NEXT: Succs (1): B2
374 // CHECK: [B7]
375 // CHECK-NEXT: 1: UV
376 // CHECK-NEXT: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
377 // CHECK-NEXT: T: if [B7.2]
378 // CHECK-NEXT: Preds (1): B9
379 // CHECK-NEXT: Succs (2): B6 B5
380 // CHECK: [B8]
381 // CHECK-NEXT: 1: [B9.3].~A() (Implicit destructor)
382 // CHECK-NEXT: 2: CFGScopeEnd(c)
383 // CHECK-NEXT: T: break;
384 // CHECK-NEXT: Preds (1): B9
385 // CHECK-NEXT: Succs (1): B1
386 // CHECK: [B9]
387 // CHECK-NEXT: 1: CFGScopeBegin(c)
388 // CHECK-NEXT: 2: (CXXConstructExpr, [B9.3], A)
389 // CHECK-NEXT: 3: A c;
390 // CHECK-NEXT: 4: UV
391 // CHECK-NEXT: 5: [B9.4] (ImplicitCastExpr, LValueToRValue, _Bool)
392 // CHECK-NEXT: T: if [B9.5]
393 // CHECK-NEXT: Preds (1): B10
394 // CHECK-NEXT: Succs (2): B8 B7
395 // CHECK: [B10]
396 // CHECK-NEXT: 1: CFGScopeBegin(b)
397 // CHECK-NEXT: 2: a
398 // CHECK-NEXT: 3: [B10.2] (ImplicitCastExpr, NoOp, const A)
399 // CHECK-NEXT: 4: [B10.3] (CXXConstructExpr, [B10.5], A)
400 // CHECK-NEXT: 5: A b = a;
401 // CHECK-NEXT: 6: b
402 // CHECK-NEXT: 7: [B10.6] (ImplicitCastExpr, NoOp, const class A)
403 // CHECK-NEXT: 8: [B10.7].operator int
404 // CHECK-NEXT: 9: [B10.7]
405 // CHECK-NEXT: 10: [B10.9] (ImplicitCastExpr, UserDefinedConversion, int)
406 // CHECK-NEXT: 11: [B10.10] (ImplicitCastExpr, IntegralToBoolean, _Bool)
407 // CHECK-NEXT: T: while [B10.11]
408 // CHECK-NEXT: Preds (2): B2 B11
409 // CHECK-NEXT: Succs (2): B9 B1
410 // CHECK: [B11]
411 // CHECK-NEXT: 1: CFGScopeBegin(a)
412 // CHECK-NEXT: 2: (CXXConstructExpr, [B11.3], A)
413 // CHECK-NEXT: 3: A a;
414 // CHECK-NEXT: Preds (1): B12
415 // CHECK-NEXT: Succs (1): B10
416 // CHECK: [B0 (EXIT)]
417 // CHECK-NEXT: Preds (2): B1 B4
418 void test_while_jumps() {
419 A a;
420 while (A b = a) {
421 A c;
422 if (UV) break;
423 if (UV) continue;
424 if (UV) return;
425 A d;
427 A e;
430 // CHECK: [B12 (ENTRY)]
431 // CHECK-NEXT: Succs (1): B11
432 // CHECK: [B1]
433 // CHECK-NEXT: 1: (CXXConstructExpr, [B1.2], A)
434 // CHECK-NEXT: 2: A d;
435 // CHECK-NEXT: 3: [B1.2].~A() (Implicit destructor)
436 // CHECK-NEXT: 4: [B11.3].~A() (Implicit destructor)
437 // CHECK-NEXT: 5: CFGScopeEnd(a)
438 // CHECK-NEXT: Preds (2): B8 B2
439 // CHECK-NEXT: Succs (1): B0
440 // CHECK: [B2]
441 // CHECK-NEXT: 1: UV
442 // CHECK-NEXT: 2: [B2.1] (ImplicitCastExpr, LValueToRValue, _Bool)
443 // CHECK-NEXT: T: do ... while [B2.2]
444 // CHECK-NEXT: Preds (2): B3 B6
445 // CHECK-NEXT: Succs (2): B10 B1
446 // CHECK: [B3]
447 // CHECK-NEXT: 1: (CXXConstructExpr, [B3.2], A)
448 // CHECK-NEXT: 2: A c;
449 // CHECK-NEXT: 3: [B3.2].~A() (Implicit destructor)
450 // CHECK-NEXT: 4: [B9.3].~A() (Implicit destructor)
451 // CHECK-NEXT: 5: CFGScopeEnd(b)
452 // CHECK-NEXT: Preds (1): B5
453 // CHECK-NEXT: Succs (1): B2
454 // CHECK: [B4]
455 // CHECK-NEXT: 1: return;
456 // CHECK-NEXT: 2: [B9.3].~A() (Implicit destructor)
457 // CHECK-NEXT: 3: CFGScopeEnd(b)
458 // CHECK-NEXT: 4: [B11.3].~A() (Implicit destructor)
459 // CHECK-NEXT: 5: CFGScopeEnd(a)
460 // CHECK-NEXT: Preds (1): B5
461 // CHECK-NEXT: Succs (1): B0
462 // CHECK: [B5]
463 // CHECK-NEXT: 1: UV
464 // CHECK-NEXT: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
465 // CHECK-NEXT: T: if [B5.2]
466 // CHECK-NEXT: Preds (1): B7
467 // CHECK-NEXT: Succs (2): B4 B3
468 // CHECK: [B6]
469 // CHECK-NEXT: 1: [B9.3].~A() (Implicit destructor)
470 // CHECK-NEXT: 2: CFGScopeEnd(b)
471 // CHECK-NEXT: T: continue;
472 // CHECK-NEXT: Preds (1): B7
473 // CHECK-NEXT: Succs (1): B2
474 // CHECK: [B7]
475 // CHECK-NEXT: 1: UV
476 // CHECK-NEXT: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
477 // CHECK-NEXT: T: if [B7.2]
478 // CHECK-NEXT: Preds (1): B9
479 // CHECK-NEXT: Succs (2): B6 B5
480 // CHECK: [B8]
481 // CHECK-NEXT: 1: [B9.3].~A() (Implicit destructor)
482 // CHECK-NEXT: 2: CFGScopeEnd(b)
483 // CHECK-NEXT: T: break;
484 // CHECK-NEXT: Preds (1): B9
485 // CHECK-NEXT: Succs (1): B1
486 // CHECK: [B9]
487 // CHECK-NEXT: 1: CFGScopeBegin(b)
488 // CHECK-NEXT: 2: (CXXConstructExpr, [B9.3], A)
489 // CHECK-NEXT: 3: A b;
490 // CHECK-NEXT: 4: UV
491 // CHECK-NEXT: 5: [B9.4] (ImplicitCastExpr, LValueToRValue, _Bool)
492 // CHECK-NEXT: T: if [B9.5]
493 // CHECK-NEXT: Preds (2): B10 B11
494 // CHECK-NEXT: Succs (2): B8 B7
495 // CHECK: [B10]
496 // CHECK-NEXT: Preds (1): B2
497 // CHECK-NEXT: Succs (1): B9
498 // CHECK: [B11]
499 // CHECK-NEXT: 1: CFGScopeBegin(a)
500 // CHECK-NEXT: 2: (CXXConstructExpr, [B11.3], A)
501 // CHECK-NEXT: 3: A a;
502 // CHECK-NEXT: Preds (1): B12
503 // CHECK-NEXT: Succs (1): B9
504 // CHECK: [B0 (EXIT)]
505 // CHECK-NEXT: Preds (2): B1 B4
506 void test_do_jumps() {
507 A a;
508 do {
509 A b;
510 if (UV) break;
511 if (UV) continue;
512 if (UV) return;
513 A c;
514 } while (UV);
515 A d;
518 // CHECK: [B6 (ENTRY)]
519 // CHECK-NEXT: Succs (1): B5
520 // CHECK: [B1]
521 // CHECK-NEXT: 1: [B4.5].~A() (Implicit destructor)
522 // CHECK-NEXT: 2: CFGScopeEnd(b)
523 // CHECK-NEXT: 3: [B5.3].~A() (Implicit destructor)
524 // CHECK-NEXT: 4: CFGScopeEnd(a)
525 // CHECK-NEXT: Preds (1): B4
526 // CHECK-NEXT: Succs (1): B0
527 // CHECK: [B2]
528 // CHECK-NEXT: 1: b
529 // CHECK-NEXT: 2: [B2.1].p
530 // CHECK-NEXT: 3: [B4.5].~A() (Implicit destructor)
531 // CHECK-NEXT: 4: CFGScopeEnd(b)
532 // CHECK-NEXT: Preds (1): B3
533 // CHECK-NEXT: Succs (1): B4
534 // CHECK: [B3]
535 // CHECK-NEXT: 1: CFGScopeBegin(c)
536 // CHECK-NEXT: 2: (CXXConstructExpr, [B3.3], A)
537 // CHECK-NEXT: 3: A c;
538 // CHECK-NEXT: 4: [B3.3].~A() (Implicit destructor)
539 // CHECK-NEXT: 5: CFGScopeEnd(c)
540 // CHECK-NEXT: Preds (1): B4
541 // CHECK-NEXT: Succs (1): B2
542 // CHECK: [B4]
543 // CHECK-NEXT: 1: CFGScopeBegin(b)
544 // CHECK-NEXT: 2: a
545 // CHECK-NEXT: 3: [B4.2] (ImplicitCastExpr, NoOp, const A)
546 // CHECK-NEXT: 4: [B4.3] (CXXConstructExpr, [B4.5], A)
547 // CHECK-NEXT: 5: A b = a;
548 // CHECK-NEXT: 6: b
549 // CHECK-NEXT: 7: [B4.6] (ImplicitCastExpr, NoOp, const class A)
550 // CHECK-NEXT: 8: [B4.7].operator int
551 // CHECK-NEXT: 9: [B4.7]
552 // CHECK-NEXT: 10: [B4.9] (ImplicitCastExpr, UserDefinedConversion, int)
553 // CHECK-NEXT: 11: [B4.10] (ImplicitCastExpr, IntegralToBoolean, _Bool)
554 // CHECK-NEXT: T: for (...; [B4.11]; ...)
555 // CHECK-NEXT: Preds (2): B2 B5
556 // CHECK-NEXT: Succs (2): B3 B1
557 // CHECK: [B5]
558 // CHECK-NEXT: 1: CFGScopeBegin(a)
559 // CHECK-NEXT: 2: (CXXConstructExpr, [B5.3], A)
560 // CHECK-NEXT: 3: A a;
561 // CHECK-NEXT: Preds (1): B6
562 // CHECK-NEXT: Succs (1): B4
563 // CHECK: [B0 (EXIT)]
564 // CHECK-NEXT: Preds (1): B1
565 void test_for_implicit_scope() {
566 for (A a; A b = a; b.p)
567 A c;
570 // CHECK: [B12 (ENTRY)]
571 // CHECK-NEXT: Succs (1): B11
572 // CHECK: [B1]
573 // CHECK-NEXT: 1: [B10.5].~A() (Implicit destructor)
574 // CHECK-NEXT: 2: CFGScopeEnd(c)
575 // CHECK-NEXT: 3: [B11.6].~A() (Implicit destructor)
576 // CHECK-NEXT: 4: CFGScopeEnd(b)
577 // CHECK-NEXT: 5: (CXXConstructExpr, [B1.6], A)
578 // CHECK-NEXT: 6: A f;
579 // CHECK-NEXT: 7: [B1.6].~A() (Implicit destructor)
580 // CHECK-NEXT: 8: [B11.3].~A() (Implicit destructor)
581 // CHECK-NEXT: 9: CFGScopeEnd(a)
582 // CHECK-NEXT: Preds (2): B8 B10
583 // CHECK-NEXT: Succs (1): B0
584 // CHECK: [B2]
585 // CHECK-NEXT: 1: [B10.5].~A() (Implicit destructor)
586 // CHECK-NEXT: 2: CFGScopeEnd(c)
587 // CHECK-NEXT: Preds (2): B3 B6
588 // CHECK-NEXT: Succs (1): B10
589 // CHECK: [B3]
590 // CHECK-NEXT: 1: (CXXConstructExpr, [B3.2], A)
591 // CHECK-NEXT: 2: A e;
592 // CHECK-NEXT: 3: [B3.2].~A() (Implicit destructor)
593 // CHECK-NEXT: 4: [B9.3].~A() (Implicit destructor)
594 // CHECK-NEXT: 5: CFGScopeEnd(d)
595 // CHECK-NEXT: Preds (1): B5
596 // CHECK-NEXT: Succs (1): B2
597 // CHECK: [B4]
598 // CHECK-NEXT: 1: return;
599 // CHECK-NEXT: 2: [B9.3].~A() (Implicit destructor)
600 // CHECK-NEXT: 3: CFGScopeEnd(d)
601 // CHECK-NEXT: 4: [B10.5].~A() (Implicit destructor)
602 // CHECK-NEXT: 5: CFGScopeEnd(c)
603 // CHECK-NEXT: 6: [B11.6].~A() (Implicit destructor)
604 // CHECK-NEXT: 7: CFGScopeEnd(b)
605 // CHECK-NEXT: 8: [B11.3].~A() (Implicit destructor)
606 // CHECK-NEXT: 9: CFGScopeEnd(a)
607 // CHECK-NEXT: Preds (1): B5
608 // CHECK-NEXT: Succs (1): B0
609 // CHECK: [B5]
610 // CHECK-NEXT: 1: UV
611 // CHECK-NEXT: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
612 // CHECK-NEXT: T: if [B5.2]
613 // CHECK-NEXT: Preds (1): B7
614 // CHECK-NEXT: Succs (2): B4 B3
615 // CHECK: [B6]
616 // CHECK-NEXT: 1: [B9.3].~A() (Implicit destructor)
617 // CHECK-NEXT: 2: CFGScopeEnd(d)
618 // CHECK-NEXT: T: continue;
619 // CHECK-NEXT: Preds (1): B7
620 // CHECK-NEXT: Succs (1): B2
621 // CHECK: [B7]
622 // CHECK-NEXT: 1: UV
623 // CHECK-NEXT: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
624 // CHECK-NEXT: T: if [B7.2]
625 // CHECK-NEXT: Preds (1): B9
626 // CHECK-NEXT: Succs (2): B6 B5
627 // CHECK: [B8]
628 // CHECK-NEXT: 1: [B9.3].~A() (Implicit destructor)
629 // CHECK-NEXT: 2: CFGScopeEnd(d)
630 // CHECK-NEXT: T: break;
631 // CHECK-NEXT: Preds (1): B9
632 // CHECK-NEXT: Succs (1): B1
633 // CHECK: [B9]
634 // CHECK-NEXT: 1: CFGScopeBegin(d)
635 // CHECK-NEXT: 2: (CXXConstructExpr, [B9.3], A)
636 // CHECK-NEXT: 3: A d;
637 // CHECK-NEXT: 4: UV
638 // CHECK-NEXT: 5: [B9.4] (ImplicitCastExpr, LValueToRValue, _Bool)
639 // CHECK-NEXT: T: if [B9.5]
640 // CHECK-NEXT: Preds (1): B10
641 // CHECK-NEXT: Succs (2): B8 B7
642 // CHECK: [B10]
643 // CHECK-NEXT: 1: CFGScopeBegin(c)
644 // CHECK-NEXT: 2: b
645 // CHECK-NEXT: 3: [B10.2] (ImplicitCastExpr, NoOp, const A)
646 // CHECK-NEXT: 4: [B10.3] (CXXConstructExpr, [B10.5], A)
647 // CHECK-NEXT: 5: A c = b;
648 // CHECK-NEXT: 6: c
649 // CHECK-NEXT: 7: [B10.6] (ImplicitCastExpr, NoOp, const class A)
650 // CHECK-NEXT: 8: [B10.7].operator int
651 // CHECK-NEXT: 9: [B10.7]
652 // CHECK-NEXT: 10: [B10.9] (ImplicitCastExpr, UserDefinedConversion, int)
653 // CHECK-NEXT: 11: [B10.10] (ImplicitCastExpr, IntegralToBoolean, _Bool)
654 // CHECK-NEXT: T: for (...; [B10.11]; )
655 // CHECK-NEXT: Preds (2): B2 B11
656 // CHECK-NEXT: Succs (2): B9 B1
657 // CHECK: [B11]
658 // CHECK-NEXT: 1: CFGScopeBegin(a)
659 // CHECK-NEXT: 2: (CXXConstructExpr, [B11.3], A)
660 // CHECK-NEXT: 3: A a;
661 // CHECK-NEXT: 4: CFGScopeBegin(b)
662 // CHECK-NEXT: 5: (CXXConstructExpr, [B11.6], A)
663 // CHECK-NEXT: 6: A b;
664 // CHECK-NEXT: Preds (1): B12
665 // CHECK-NEXT: Succs (1): B10
666 // CHECK: [B0 (EXIT)]
667 // CHECK-NEXT: Preds (2): B1 B4
668 void test_for_jumps() {
669 A a;
670 for (A b; A c = b; ) {
671 A d;
672 if (UV) break;
673 if (UV) continue;
674 if (UV) return;
675 A e;
677 A f;
680 // CHECK: [B9 (ENTRY)]
681 // CHECK-NEXT: Succs (1): B8
682 // CHECK: [B1]
683 // CHECK-NEXT: 1: [B7.5].~A() (Implicit destructor)
684 // CHECK-NEXT: 2: CFGScopeEnd(b)
685 // CHECK-NEXT: 3: [B8.3].~A() (Implicit destructor)
686 // CHECK-NEXT: 4: CFGScopeEnd(a)
687 // CHECK-NEXT: Preds (1): B7
688 // CHECK-NEXT: Succs (1): B0
689 // CHECK: [B2]
690 // CHECK-NEXT: 1: [B5.4] ? [B3.3] : [B4.2]
691 // CHECK-NEXT: 2: [B7.5].~A() (Implicit destructor)
692 // CHECK-NEXT: 3: CFGScopeEnd(b)
693 // CHECK-NEXT: Preds (2): B3 B4
694 // CHECK-NEXT: Succs (1): B7
695 // CHECK: [B3]
696 // CHECK-NEXT: 1: b
697 // CHECK-NEXT: 2: [B3.1].p
698 // CHECK-NEXT: 3: [B3.2]++
699 // CHECK-NEXT: Preds (1): B5
700 // CHECK-NEXT: Succs (1): B2
701 // CHECK: [B4]
702 // CHECK-NEXT: 1: 0
703 // CHECK-NEXT: 2: [B4.1] (ImplicitCastExpr, NullToPointer, int *)
704 // CHECK-NEXT: Preds (1): B5
705 // CHECK-NEXT: Succs (1): B2
706 // CHECK: [B5]
707 // CHECK-NEXT: 1: b
708 // CHECK-NEXT: 2: [B5.1].p
709 // CHECK-NEXT: 3: [B5.2] (ImplicitCastExpr, LValueToRValue, int *)
710 // CHECK-NEXT: 4: [B5.3] (ImplicitCastExpr, PointerToBoolean, _Bool)
711 // CHECK-NEXT: T: [B5.4] ? ... : ...
712 // CHECK-NEXT: Preds (1): B6
713 // CHECK-NEXT: Succs (2): B3 B4
714 // CHECK: [B6]
715 // CHECK-NEXT: 1: 0
716 // CHECK-NEXT: 2: (void)[B6.1] (CStyleCastExpr, ToVoid, void)
717 // CHECK-NEXT: Preds (1): B7
718 // CHECK-NEXT: Succs (1): B5
719 // CHECK: [B7]
720 // CHECK-NEXT: 1: CFGScopeBegin(b)
721 // CHECK-NEXT: 2: a
722 // CHECK-NEXT: 3: [B7.2] (ImplicitCastExpr, NoOp, const A)
723 // CHECK-NEXT: 4: [B7.3] (CXXConstructExpr, [B7.5], A)
724 // CHECK-NEXT: 5: A b = a;
725 // CHECK-NEXT: 6: b
726 // CHECK-NEXT: 7: [B7.6] (ImplicitCastExpr, NoOp, const class A)
727 // CHECK-NEXT: 8: [B7.7].operator int
728 // CHECK-NEXT: 9: [B7.7]
729 // CHECK-NEXT: 10: [B7.9] (ImplicitCastExpr, UserDefinedConversion, int)
730 // CHECK-NEXT: 11: [B7.10] (ImplicitCastExpr, IntegralToBoolean, _Bool)
731 // CHECK-NEXT: T: for (...; [B7.11]; ...)
732 // CHECK-NEXT: Preds (2): B2 B8
733 // CHECK-NEXT: Succs (2): B6 B1
734 // CHECK: [B8]
735 // CHECK-NEXT: 1: CFGScopeBegin(a)
736 // CHECK-NEXT: 2: (CXXConstructExpr, [B8.3], A)
737 // CHECK-NEXT: 3: A a;
738 // CHECK-NEXT: Preds (1): B9
739 // CHECK-NEXT: Succs (1): B7
740 void test_for_inc_conditional() {
741 for (A a; A b = a; b.p ? b.p++ : 0)
742 (void)0;
745 // CHECK: [B9 (ENTRY)]
746 // CHECK-NEXT: Succs (1): B7
747 // CHECK: [B1]
748 // CHECK-NEXT: l1:
749 // CHECK-NEXT: 1: (CXXConstructExpr, [B1.2], A)
750 // CHECK-NEXT: 2: A c;
751 // CHECK-NEXT: 3: [B1.2].~A() (Implicit destructor)
752 // CHECK-NEXT: 4: [B6.4].~A() (Implicit destructor)
753 // CHECK-NEXT: 5: [B6.2].~A() (Implicit destructor)
754 // CHECK-NEXT: 6: [B7.3].~A() (Implicit destructor)
755 // CHECK-NEXT: 7: CFGScopeEnd(a)
756 // CHECK-NEXT: Preds (2): B2 B3
757 // CHECK-NEXT: Succs (1): B0
758 // CHECK: [B2]
759 // CHECK-NEXT: 1: (CXXConstructExpr, [B2.2], A)
760 // CHECK-NEXT: 2: A nb;
761 // CHECK-NEXT: 3: [B2.2].~A() (Implicit destructor)
762 // CHECK-NEXT: 4: [B6.7].~A() (Implicit destructor)
763 // CHECK-NEXT: 5: CFGScopeEnd(na)
764 // CHECK-NEXT: Preds (1): B4
765 // CHECK-NEXT: Succs (1): B1
766 // CHECK: [B3]
767 // CHECK-NEXT: 1: [B6.7].~A() (Implicit destructor)
768 // CHECK-NEXT: 2: CFGScopeEnd(na)
769 // CHECK-NEXT: T: goto l1;
770 // CHECK-NEXT: Preds (1): B4
771 // CHECK-NEXT: Succs (1): B1
772 // CHECK: [B4]
773 // CHECK-NEXT: 1: UV
774 // CHECK-NEXT: 2: [B4.1] (ImplicitCastExpr, LValueToRValue, _Bool)
775 // CHECK-NEXT: T: if [B4.2]
776 // CHECK-NEXT: Preds (1): B6
777 // CHECK-NEXT: Succs (2): B3 B2
778 // CHECK: [B5]
779 // CHECK-NEXT: Preds (1): B6
780 // CHECK-NEXT: Succs (1): B8
781 // CHECK: [B6]
782 // CHECK-NEXT: l0:
783 // CHECK-NEXT: 1: (CXXConstructExpr, [B6.2], A)
784 // CHECK-NEXT: 2: A cb;
785 // CHECK-NEXT: 3: (CXXConstructExpr, [B6.4], A)
786 // CHECK-NEXT: 4: A b;
787 // CHECK-NEXT: 5: CFGScopeBegin(na)
788 // CHECK-NEXT: 6: (CXXConstructExpr, [B6.7], A)
789 // CHECK-NEXT: 7: A na;
790 // CHECK-NEXT: 8: UV
791 // CHECK-NEXT: 9: [B6.8] (ImplicitCastExpr, LValueToRValue, _Bool)
792 // CHECK-NEXT: T: if [B6.9]
793 // CHECK-NEXT: Preds (2): B7 B8
794 // CHECK-NEXT: Succs (2): B5 B4
795 // CHECK: [B7]
796 // CHECK-NEXT: 1: CFGScopeBegin(a)
797 // CHECK-NEXT: 2: (CXXConstructExpr, [B7.3], A)
798 // CHECK-NEXT: 3: A a;
799 // CHECK-NEXT: Preds (1): B9
800 // CHECK-NEXT: Succs (1): B6
801 // CHECK: [B8]
802 // CHECK-NEXT: 1: [B6.7].~A() (Implicit destructor)
803 // CHECK-NEXT: 2: CFGScopeEnd(na)
804 // CHECK-NEXT: 3: [B6.4].~A() (Implicit destructor)
805 // CHECK-NEXT: 4: [B6.2].~A() (Implicit destructor)
806 // CHECK-NEXT: T: goto l0;
807 // CHECK-NEXT: Preds (1): B5
808 // CHECK-NEXT: Succs (1): B6
809 // CHECK: [B0 (EXIT)]
810 // CHECK-NEXT: Preds (1): B1
811 void test_goto() {
812 A a;
814 A cb;
815 A b;
816 { A na;
817 if (UV) goto l0;
818 if (UV) goto l1;
819 A nb;
822 A c;
825 // CHECK: [B7 (ENTRY)]
826 // CHECK-NEXT: Succs (1): B6
827 // CHECK: [B1]
828 // CHECK-NEXT: 1: CFGScopeEnd(i)
829 // CHECK-NEXT: 2: CFGScopeBegin(unused2)
830 // CHECK-NEXT: 3: int unused2;
831 // CHECK-NEXT: 4: CFGScopeEnd(unused2)
832 // CHECK-NEXT: Preds (2): B4 B5
833 // CHECK-NEXT: Succs (1): B0
834 // CHECK: [B2]
835 // CHECK-NEXT: 1: i
836 // CHECK-NEXT: 2: ++[B2.1]
837 // CHECK-NEXT: Preds (1): B3
838 // CHECK-NEXT: Succs (1): B5
839 // CHECK: [B3]
840 // CHECK-NEXT: 1: CFGScopeEnd(unused1)
841 // CHECK-NEXT: Succs (1): B2
842 // CHECK: [B4]
843 // CHECK-NEXT: 1: CFGScopeBegin(unused1)
844 // CHECK-NEXT: 2: int unused1;
845 // CHECK-NEXT: 3: CFGScopeEnd(unused1)
846 // CHECK-NEXT: T: break;
847 // CHECK-NEXT: Preds (1): B5
848 // CHECK-NEXT: Succs (1): B1
849 // CHECK: [B5]
850 // CHECK-NEXT: 1: i
851 // CHECK-NEXT: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, int)
852 // CHECK-NEXT: 3: 3
853 // CHECK-NEXT: 4: [B5.2] < [B5.3]
854 // CHECK-NEXT: T: for (...; [B5.4]; ...)
855 // CHECK-NEXT: Preds (2): B2 B6
856 // CHECK-NEXT: Succs (2): B4 B1
857 // CHECK: [B6]
858 // CHECK-NEXT: 1: CFGScopeBegin(i)
859 // CHECK-NEXT: 2: 0
860 // CHECK-NEXT: 3: int i = 0;
861 // CHECK-NEXT: Preds (1): B7
862 // CHECK-NEXT: Succs (1): B5
863 // CHECK: [B0 (EXIT)]
864 // CHECK-NEXT: Preds (1): B1
865 void test_for_compound_and_break() {
866 for (int i = 0; i < 3; ++i) {
868 int unused1;
869 break;
873 int unused2;
877 // CHECK: [B6 (ENTRY)]
878 // CHECK-NEXT: Succs (1): B5
879 // CHECK: [B1]
880 // CHECK-NEXT: 1: CFGScopeEnd(__end1)
881 // CHECK-NEXT: 2: CFGScopeEnd(__begin1)
882 // CHECK-NEXT: 3: CFGScopeEnd(__range1)
883 // CHECK-NEXT: 4: [B5.3].~A[10]() (Implicit destructor)
884 // CHECK-NEXT: 5: CFGScopeEnd(a)
885 // CHECK-NEXT: Preds (1): B2
886 // CHECK-NEXT: Succs (1): B0
887 // CHECK: [B2]
888 // CHECK-NEXT: 1: __begin1
889 // CHECK-NEXT: 2: [B2.1] (ImplicitCastExpr, LValueToRValue, A *)
890 // CHECK-NEXT: 3: __end1
891 // CHECK-NEXT: 4: [B2.3] (ImplicitCastExpr, LValueToRValue, A *)
892 // CHECK-NEXT: 5: [B2.2] != [B2.4]
893 // CHECK-NEXT: T: for (auto &i : [B5.4])
894 // CHECK: [B4.11];
895 // CHECK: Preds (2): B3 B5
896 // CHECK-NEXT: Succs (2): B4 B1
897 // CHECK: [B3]
898 // CHECK-NEXT: 1: __begin1
899 // CHECK-NEXT: 2: ++[B3.1]
900 // CHECK-NEXT: Preds (1): B4
901 // CHECK-NEXT: Succs (1): B2
902 // CHECK: [B4]
903 // CHECK-NEXT: 1: CFGScopeBegin(i)
904 // CHECK-NEXT: 2: __begin1
905 // CHECK-NEXT: 3: [B4.2] (ImplicitCastExpr, LValueToRValue, A *)
906 // CHECK-NEXT: 4: *[B4.3]
907 // CHECK-NEXT: 5: auto &i
908 // CHECK-NEXT: 6: operator=
909 // CHECK-NEXT: 7: [B4.6] (ImplicitCastExpr, FunctionToPointerDecay, A &(*)(const A &)
910 // CHECK-NEXT: 8: i
911 // CHECK-NEXT: 9: b
912 // CHECK-NEXT: 10: [B4.9] (ImplicitCastExpr, NoOp, const A)
913 // CHECK-NEXT: 11: [B4.8] = [B4.10] (OperatorCall)
914 // CHECK-NEXT: 12: CFGScopeEnd(i)
915 // CHECK-NEXT: Preds (1): B2
916 // CHECK-NEXT: Succs (1): B3
917 // CHECK: [B5]
918 // CHECK-NEXT: 1: CFGScopeBegin(a)
919 // CHECK-NEXT: 2: (CXXConstructExpr, [B5.3], A[10])
920 // CHECK-NEXT: 3: A a[10];
921 // CHECK-NEXT: 4: a
922 // CHECK-NEXT: 5: auto &&__range1 = a;
923 // CHECK-NEXT: 6: CFGScopeBegin(__end1)
924 // CHECK-NEXT: 7: __range1
925 // CHECK-NEXT: 8: [B5.7] (ImplicitCastExpr, ArrayToPointerDecay, A *)
926 // CHECK-NEXT: 9: 10
927 // CHECK-NEXT: 10: [B5.8] + [B5.9]
928 // CHECK-NEXT: 11: auto __end1 = __range1 + 10
929 // CHECK-NEXT: 12: __range1
930 // CHECK-NEXT: 13: [B5.12] (ImplicitCastExpr, ArrayToPointerDecay, A *)
931 // CHECK-NEXT: 14: auto __begin1 = __range1;
932 // CHECK-NEXT: Preds (1): B6
933 // CHECK-NEXT: Succs (1): B2
934 // CHECK: [B0 (EXIT)]
935 // CHECK-NEXT: Preds (1): B1
936 void test_range_for(A &b) {
937 A a[10];
938 for (auto &i : a)
939 i = b;
942 // CHECK: [B8 (ENTRY)]
943 // CHECK-NEXT: Succs (1): B2
944 // CHECK: [B1]
945 // CHECK-NEXT: 1: CFGScopeEnd(i)
946 // CHECK-NEXT: 2: 1
947 // CHECK-NEXT: 3: int k = 1;
948 // CHECK-NEXT: 4: CFGScopeEnd(c)
949 // CHECK-NEXT: Preds (3): B3 B5 B6
950 // CHECK-NEXT: Succs (1): B0
951 // CHECK: [B2]
952 // CHECK-NEXT: 1: CFGScopeBegin(c)
953 // CHECK-NEXT: 2: '1'
954 // CHECK-NEXT: 3: char c = '1';
955 // CHECK-NEXT: 4: CFGScopeBegin(i)
956 // CHECK-NEXT: 5: getX
957 // CHECK-NEXT: 6: [B2.5] (ImplicitCastExpr, FunctionToPointerDecay, int (*)(void))
958 // CHECK-NEXT: 7: [B2.6]()
959 // CHECK-NEXT: 8: int i = getX();
960 // CHECK-NEXT: 9: i
961 // CHECK-NEXT: 10: [B2.9] (ImplicitCastExpr, LValueToRValue, int)
962 // CHECK-NEXT: T: switch [B2.10]
963 // CHECK-NEXT: Preds (1): B8
964 // CHECK-NEXT: Succs (5): B4 B5 B6 B7 B3
965 // CHECK: [B3]
966 // CHECK-NEXT: default:
967 // CHECK-NEXT: 1: CFGScopeBegin(a)
968 // CHECK-NEXT: 2: 0
969 // CHECK-NEXT: 3: int a = 0;
970 // CHECK-NEXT: 4: i
971 // CHECK-NEXT: 5: ++[B3.4]
972 // CHECK-NEXT: 6: CFGScopeEnd(a)
973 // CHECK-NEXT: Preds (2): B4 B2
974 // CHECK-NEXT: Succs (1): B1
975 // CHECK: [B4]
976 // CHECK-NEXT: case 3:
977 // CHECK-NEXT: 1: '2'
978 // CHECK-NEXT: 2: c
979 // CHECK-NEXT: 3: [B4.2] = [B4.1]
980 // CHECK-NEXT: Preds (1): B2
981 // CHECK-NEXT: Succs (1): B3
982 // CHECK: [B5]
983 // CHECK-NEXT: case 2:
984 // CHECK-NEXT: 1: '2'
985 // CHECK-NEXT: 2: c
986 // CHECK-NEXT: 3: [B5.2] = [B5.1]
987 // CHECK-NEXT: T: break;
988 // CHECK-NEXT: Preds (1): B2
989 // CHECK-NEXT: Succs (1): B1
990 // CHECK: [B6]
991 // CHECK-NEXT: case 1:
992 // CHECK-NEXT: 1: '3'
993 // CHECK-NEXT: 2: c
994 // CHECK-NEXT: 3: [B6.2] = [B6.1]
995 // CHECK-NEXT: T: break;
996 // CHECK-NEXT: Preds (2): B2 B7
997 // CHECK-NEXT: Succs (1): B1
998 // CHECK: [B7]
999 // CHECK-NEXT: case 0:
1000 // CHECK-NEXT: 1: '2'
1001 // CHECK-NEXT: 2: c
1002 // CHECK-NEXT: 3: [B7.2] = [B7.1]
1003 // CHECK-NEXT: Preds (1): B2
1004 // CHECK-NEXT: Succs (1): B6
1005 // CHECK: [B0 (EXIT)]
1006 // CHECK-NEXT: Preds (1): B1
1007 void test_switch_with_compound_with_default() {
1008 char c = '1';
1009 switch (int i = getX()) {
1010 case 0:
1011 c = '2';
1012 case 1:
1013 c = '3';
1014 break;
1015 case 2: {
1016 c = '2';
1017 break;
1019 case 3:
1020 c = '2';
1021 default: {
1022 int a = 0;
1023 ++i;
1026 int k = 1;
1029 // CHECK: [B6 (ENTRY)]
1030 // CHECK-NEXT: Succs (1): B2
1031 // CHECK: [B1]
1032 // CHECK-NEXT: 1: CFGScopeEnd(i)
1033 // CHECK-NEXT: 2: 3
1034 // CHECK-NEXT: 3: int k = 3;
1035 // CHECK-NEXT: 4: CFGScopeEnd(c)
1036 // CHECK-NEXT: Preds (3): B3 B4 B2
1037 // CHECK-NEXT: Succs (1): B0
1038 // CHECK: [B2]
1039 // CHECK-NEXT: 1: CFGScopeBegin(c)
1040 // CHECK-NEXT: 2: '1'
1041 // CHECK-NEXT: 3: char c = '1';
1042 // CHECK-NEXT: 4: CFGScopeBegin(i)
1043 // CHECK-NEXT: 5: getX
1044 // CHECK-NEXT: 6: [B2.5] (ImplicitCastExpr, FunctionToPointerDecay, int (*)(void))
1045 // CHECK-NEXT: 7: [B2.6]()
1046 // CHECK-NEXT: 8: int i = getX();
1047 // CHECK-NEXT: 9: i
1048 // CHECK-NEXT: 10: [B2.9] (ImplicitCastExpr, LValueToRValue, int)
1049 // CHECK-NEXT: T: switch [B2.10]
1050 // CHECK-NEXT: Preds (1): B6
1051 // CHECK-NEXT: Succs (4): B3 B4 B5 B1
1052 // CHECK: [B3]
1053 // CHECK-NEXT: case 2:
1054 // CHECK-NEXT: 1: '3'
1055 // CHECK-NEXT: 2: c
1056 // CHECK-NEXT: 3: [B3.2] = [B3.1]
1057 // CHECK-NEXT: T: break;
1058 // CHECK-NEXT: Preds (1): B2
1059 // CHECK-NEXT: Succs (1): B1
1060 // CHECK: [B4]
1061 // CHECK-NEXT: case 1:
1062 // CHECK-NEXT: 1: '1'
1063 // CHECK-NEXT: 2: c
1064 // CHECK-NEXT: 3: [B4.2] = [B4.1]
1065 // CHECK-NEXT: T: break;
1066 // CHECK-NEXT: Preds (2): B2 B5
1067 // CHECK-NEXT: Succs (1): B1
1068 // CHECK: [B5]
1069 // CHECK-NEXT: case 0:
1070 // CHECK-NEXT: 1: '2'
1071 // CHECK-NEXT: 2: c
1072 // CHECK-NEXT: 3: [B5.2] = [B5.1]
1073 // CHECK-NEXT: Preds (1): B2
1074 // CHECK-NEXT: Succs (1): B4
1075 // CHECK: [B0 (EXIT)]
1076 // CHECK-NEXT: Preds (1): B1
1077 int test_switch_with_compound_without_default() {
1078 char c = '1';
1079 switch (int i = getX()) {
1080 case 0:
1081 c = '2';
1082 case 1:
1083 c = '1';
1084 break;
1085 case 2:
1086 c = '3';
1087 break;
1089 int k = 3;
1092 // CHECK: [B5 (ENTRY)]
1093 // CHECK-NEXT: Succs (1): B2
1094 // CHECK: [B1]
1095 // CHECK-NEXT: 1: CFGScopeEnd(i)
1096 // CHECK-NEXT: 2: 1
1097 // CHECK-NEXT: 3: int k = 1;
1098 // CHECK-NEXT: 4: CFGScopeEnd(s)
1099 // CHECK-NEXT: Preds (1): B3
1100 // CHECK-NEXT: Succs (1): B0
1101 // CHECK: [B2]
1102 // CHECK-NEXT: 1: CFGScopeBegin(s)
1103 // CHECK-NEXT: 2: '1'
1104 // CHECK-NEXT: 3: char s = '1';
1105 // CHECK-NEXT: 4: CFGScopeBegin(i)
1106 // CHECK-NEXT: 5: getX
1107 // CHECK-NEXT: 6: [B2.5] (ImplicitCastExpr, FunctionToPointerDecay, int (*)(void))
1108 // CHECK-NEXT: 7: [B2.6]()
1109 // CHECK-NEXT: 8: int i = getX();
1110 // CHECK-NEXT: 9: i
1111 // CHECK-NEXT: 10: [B2.9] (ImplicitCastExpr, LValueToRValue, int)
1112 // CHECK-NEXT: T: switch [B2.10]
1113 // CHECK-NEXT: Preds (1): B5
1114 // CHECK-NEXT: Succs (2): B4 B3
1115 // CHECK: [B3]
1116 // CHECK-NEXT: default:
1117 // CHECK-NEXT: 1: CFGScopeBegin(a)
1118 // CHECK-NEXT: 2: 0
1119 // CHECK-NEXT: 3: int a = 0;
1120 // CHECK-NEXT: 4: i
1121 // CHECK-NEXT: 5: ++[B3.4]
1122 // CHECK-NEXT: 6: CFGScopeEnd(a)
1123 // CHECK-NEXT: Preds (2): B4 B2
1124 // CHECK-NEXT: Succs (1): B1
1125 // CHECK: [B4]
1126 // CHECK-NEXT: case 0:
1127 // CHECK-NEXT: Preds (1): B2
1128 // CHECK-NEXT: Succs (1): B3
1129 // CHECK: [B0 (EXIT)]
1130 // CHECK-NEXT: Preds (1): B1
1131 void test_without_compound() {
1132 char s = '1';
1133 switch (int i = getX())
1134 case 0:
1135 default: {
1136 int a = 0;
1137 ++i;
1139 int k = 1;
1142 // CHECK: [B12 (ENTRY)]
1143 // CHECK-NEXT: Succs (1): B11
1144 // CHECK: [B1]
1145 // CHECK-NEXT: 1: CFGScopeEnd(i)
1146 // CHECK-NEXT: Preds (2): B4 B10
1147 // CHECK-NEXT: Succs (1): B0
1148 // CHECK: [B2]
1149 // CHECK-NEXT: 1: i
1150 // CHECK-NEXT: 2: ++[B2.1]
1151 // CHECK-NEXT: Preds (2): B3 B7
1152 // CHECK-NEXT: Succs (1): B10
1153 // CHECK: [B3]
1154 // CHECK-NEXT: 1: CFGScopeEnd(z)
1155 // CHECK-NEXT: Succs (1): B2
1156 // CHECK: [B4]
1157 // CHECK-NEXT: 1: CFGScopeBegin(z)
1158 // CHECK-NEXT: 2: 5
1159 // CHECK-NEXT: 3: int z = 5;
1160 // CHECK-NEXT: 4: CFGScopeEnd(z)
1161 // CHECK-NEXT: T: break;
1162 // CHECK-NEXT: Preds (2): B6 B8
1163 // CHECK-NEXT: Succs (1): B1
1164 // CHECK: [B5]
1165 // CHECK-NEXT: 1: x
1166 // CHECK-NEXT: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, int)
1167 // CHECK-NEXT: T: switch [B5.2]
1168 // CHECK-NEXT: Preds (1): B10
1169 // CHECK-NEXT: Succs (4): B7 B8 B9 B6
1170 // CHECK: [B6]
1171 // CHECK-NEXT: default:
1172 // CHECK-NEXT: 1: 3
1173 // CHECK-NEXT: 2: y
1174 // CHECK-NEXT: 3: [B6.2] = [B6.1]
1175 // CHECK-NEXT: Preds (1): B5
1176 // CHECK-NEXT: Succs (1): B4
1177 // CHECK: [B7]
1178 // CHECK-NEXT: case 2:
1179 // CHECK-NEXT: 1: 4
1180 // CHECK-NEXT: 2: y
1181 // CHECK-NEXT: 3: [B7.2] = [B7.1]
1182 // CHECK-NEXT: T: continue;
1183 // CHECK-NEXT: Preds (1): B5
1184 // CHECK-NEXT: Succs (1): B2
1185 // CHECK: [B8]
1186 // CHECK-NEXT: case 1:
1187 // CHECK-NEXT: 1: 2
1188 // CHECK-NEXT: 2: y
1189 // CHECK-NEXT: 3: [B8.2] = [B8.1]
1190 // CHECK-NEXT: T: break;
1191 // CHECK-NEXT: Preds (2): B5 B9
1192 // CHECK-NEXT: Succs (1): B4
1193 // CHECK: [B9]
1194 // CHECK-NEXT: case 0:
1195 // CHECK-NEXT: 1: 1
1196 // CHECK-NEXT: 2: y
1197 // CHECK-NEXT: 3: [B9.2] = [B9.1]
1198 // CHECK-NEXT: Preds (1): B5
1199 // CHECK-NEXT: Succs (1): B8
1200 // CHECK: [B10]
1201 // CHECK-NEXT: 1: i
1202 // CHECK-NEXT: 2: [B10.1] (ImplicitCastExpr, LValueToRValue, int)
1203 // CHECK-NEXT: 3: 1000
1204 // CHECK-NEXT: 4: [B10.2] < [B10.3]
1205 // CHECK-NEXT: T: for (...; [B10.4]; ...)
1206 // CHECK-NEXT: Preds (2): B2 B11
1207 // CHECK-NEXT: Succs (2): B5 B1
1208 // CHECK: [B11]
1209 // CHECK-NEXT: 1: CFGScopeBegin(i)
1210 // CHECK-NEXT: 2: int i;
1211 // CHECK-NEXT: 3: int x;
1212 // CHECK-NEXT: 4: int y;
1213 // CHECK-NEXT: 5: 0
1214 // CHECK-NEXT: 6: i
1215 // CHECK-NEXT: 7: [B11.6] = [B11.5]
1216 // CHECK-NEXT: Preds (1): B12
1217 // CHECK-NEXT: Succs (1): B10
1218 // CHECK: [B0 (EXIT)]
1219 // CHECK-NEXT: Preds (1): B1
1220 void test_for_switch_in_for() {
1221 int i, x, y;
1222 for (i = 0; i < 1000; ++i) {
1223 switch (x) {
1224 case 0:
1225 y = 1;
1226 case 1:
1227 y = 2;
1228 break; // break from switch
1229 case 2:
1230 y = 4;
1231 continue; // continue in loop
1232 default:
1233 y = 3;
1236 int z = 5;
1237 break; // break from loop
1242 // CHECK: [B4 (ENTRY)]
1243 // CHECK-NEXT: Succs (1): B3
1244 // CHECK: [B1]
1245 // CHECK-NEXT: label:
1246 // CHECK-NEXT: 1: CFGScopeEnd(n2t)
1247 // CHECK-NEXT: 2: CFGScopeEnd(n1t)
1248 // CHECK-NEXT: 3: [B3.3].~A() (Implicit destructor)
1249 // CHECK-NEXT: 4: CFGScopeEnd(a)
1250 // CHECK-NEXT: Preds (2): B2 B3
1251 // CHECK-NEXT: Succs (1): B0
1252 // CHECK: [B2]
1253 // CHECK-NEXT: 1: [B3.9].~A() (Implicit destructor)
1254 // CHECK-NEXT: 2: CFGScopeEnd(n2s)
1255 // CHECK-NEXT: 3: [B3.6].~A() (Implicit destructor)
1256 // CHECK-NEXT: 4: CFGScopeEnd(n1s)
1257 // CHECK-NEXT: 5: CFGScopeBegin(n1t)
1258 // CHECK-NEXT: 6: int n1t;
1259 // CHECK-NEXT: 7: CFGScopeBegin(n2t)
1260 // CHECK-NEXT: 8: int n2t;
1261 // CHECK-NEXT: Succs (1): B1
1262 // CHECK: [B3]
1263 // CHECK-NEXT: 1: CFGScopeBegin(a)
1264 // CHECK-NEXT: 2: (CXXConstructExpr, [B3.3], A)
1265 // CHECK-NEXT: 3: A a;
1266 // CHECK-NEXT: 4: CFGScopeBegin(n1s)
1267 // CHECK-NEXT: 5: (CXXConstructExpr, [B3.6], A)
1268 // CHECK-NEXT: 6: A n1s;
1269 // CHECK-NEXT: 7: CFGScopeBegin(n2s)
1270 // CHECK-NEXT: 8: (CXXConstructExpr, [B3.9], A)
1271 // CHECK-NEXT: 9: A n2s;
1272 // CHECK-NEXT: 10: [B3.9].~A() (Implicit destructor)
1273 // CHECK-NEXT: 11: CFGScopeEnd(n2s)
1274 // CHECK-NEXT: 12: [B3.6].~A() (Implicit destructor)
1275 // CHECK-NEXT: 13: CFGScopeEnd(n1s)
1276 // CHECK-NEXT: 14: CFGScopeBegin(n1t)
1277 // CHECK-NEXT: 15: CFGScopeBegin(n2t)
1278 // CHECK-NEXT: T: goto label;
1279 // CHECK-NEXT: Preds (1): B4
1280 // CHECK-NEXT: Succs (1): B1
1281 // CHECK: [B0 (EXIT)]
1282 // CHECK-NEXT: Preds (1): B1
1283 void test_goto_multiple_scopes() {
1284 A a;
1286 A n1s;
1288 A n2s;
1289 goto label;
1293 int n1t;
1295 int n2t;
1296 label:
1301 // CHECK: [B5 (ENTRY)]
1302 // CHECK-NEXT: Succs (1): B3
1303 // CHECK: [B1]
1304 // CHECK-NEXT: 1: [B2.8].~A() (Implicit destructor)
1305 // CHECK-NEXT: 2: CFGScopeEnd(n2s)
1306 // CHECK-NEXT: 3: [B2.5].~A() (Implicit destructor)
1307 // CHECK-NEXT: 4: CFGScopeEnd(n1s)
1308 // CHECK-NEXT: 5: [B3.3].~A() (Implicit destructor)
1309 // CHECK-NEXT: 6: CFGScopeEnd(a)
1310 // CHECK-NEXT: Succs (1): B0
1311 // CHECK: [B2]
1312 // CHECK-NEXT: label:
1313 // CHECK-NEXT: 1: CFGScopeEnd(n2t)
1314 // CHECK-NEXT: 2: CFGScopeEnd(n1t)
1315 // CHECK-NEXT: 3: CFGScopeBegin(n1s)
1316 // CHECK-NEXT: 4: (CXXConstructExpr, [B2.5], A)
1317 // CHECK-NEXT: 5: A n1s;
1318 // CHECK-NEXT: 6: CFGScopeBegin(n2s)
1319 // CHECK-NEXT: 7: (CXXConstructExpr, [B2.8], A)
1320 // CHECK-NEXT: 8: A n2s;
1321 // CHECK-NEXT: Preds (2): B3 B4
1322 // CHECK-NEXT: Succs (1): B4
1323 // CHECK: [B3]
1324 // CHECK-NEXT: 1: CFGScopeBegin(a)
1325 // CHECK-NEXT: 2: (CXXConstructExpr, [B3.3], A)
1326 // CHECK-NEXT: 3: A a;
1327 // CHECK-NEXT: 4: CFGScopeBegin(n1t)
1328 // CHECK-NEXT: 5: int n1t;
1329 // CHECK-NEXT: 6: CFGScopeBegin(n2t)
1330 // CHECK-NEXT: 7: int n2t;
1331 // CHECK-NEXT: Preds (1): B5
1332 // CHECK-NEXT: Succs (1): B2
1333 // CHECK: [B4]
1334 // CHECK-NEXT: 1: [B2.8].~A() (Implicit destructor)
1335 // CHECK-NEXT: 2: CFGScopeEnd(n2s)
1336 // CHECK-NEXT: 3: [B2.5].~A() (Implicit destructor)
1337 // CHECK-NEXT: 4: CFGScopeEnd(n1s)
1338 // CHECK-NEXT: 5: CFGScopeBegin(n1t)
1339 // CHECK-NEXT: 6: CFGScopeBegin(n2t)
1340 // CHECK-NEXT: T: goto label;
1341 // CHECK-NEXT: Preds (1): B2
1342 // CHECK-NEXT: Succs (1): B2
1343 // CHECK: [B0 (EXIT)]
1344 // CHECK-NEXT: Preds (1): B1
1345 void test_backpatched_goto_multiple_scopes() {
1346 A a;
1348 int n1t;
1350 int n2t;
1351 label:
1355 A n1s;
1357 A n2s;
1358 goto label;
1363 // CHECK: [B8 (ENTRY)]
1364 // CHECK-NEXT: Succs (1): B7
1365 // CHECK: [B1]
1366 // CHECK-NEXT: label:
1367 // CHECK-NEXT: 1: CFGScopeEnd(n2t)
1368 // CHECK-NEXT: 2: CFGScopeEnd(n1t)
1369 // CHECK-NEXT: Preds (4): B2 B3 B4 B6
1370 // CHECK-NEXT: Succs (1): B0
1371 // CHECK: [B2]
1372 // CHECK-NEXT: T: goto label;
1373 // CHECK-NEXT: Preds (1): B3
1374 // CHECK-NEXT: Succs (1): B1
1375 // CHECK: [B3]
1376 // CHECK-NEXT: 1: CFGScopeBegin(n2t)
1377 // CHECK-NEXT: 2: int n2t;
1378 // CHECK-NEXT: 3: UV
1379 // CHECK-NEXT: 4: [B3.3] (ImplicitCastExpr, LValueToRValue, _Bool)
1380 // CHECK-NEXT: T: if [B3.4]
1381 // CHECK-NEXT: Preds (1): B5
1382 // CHECK-NEXT: Succs (2): B2 B1
1383 // CHECK: [B4]
1384 // CHECK-NEXT: 1: CFGScopeBegin(n2t)
1385 // CHECK-NEXT: T: goto label;
1386 // CHECK-NEXT: Preds (1): B5
1387 // CHECK-NEXT: Succs (1): B1
1388 // CHECK: [B5]
1389 // CHECK-NEXT: 1: CFGScopeBegin(n1t)
1390 // CHECK-NEXT: 2: int n1t;
1391 // CHECK-NEXT: 3: UV
1392 // CHECK-NEXT: 4: [B5.3] (ImplicitCastExpr, LValueToRValue, _Bool)
1393 // CHECK-NEXT: T: if [B5.4]
1394 // CHECK-NEXT: Preds (1): B7
1395 // CHECK-NEXT: Succs (2): B4 B3
1396 // CHECK: [B6]
1397 // CHECK-NEXT: 1: CFGScopeBegin(n1t)
1398 // CHECK-NEXT: 2: CFGScopeBegin(n2t)
1399 // CHECK-NEXT: T: goto label;
1400 // CHECK-NEXT: Preds (1): B7
1401 // CHECK-NEXT: Succs (1): B1
1402 // CHECK: [B7]
1403 // CHECK-NEXT: 1: UV
1404 // CHECK-NEXT: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
1405 // CHECK-NEXT: T: if [B7.2]
1406 // CHECK-NEXT: Preds (1): B8
1407 // CHECK-NEXT: Succs (2): B6 B5
1408 // CHECK: [B0 (EXIT)]
1409 // CHECK-NEXT: Preds (1): B1
1410 void test_multiple_goto_entering_scopes() {
1411 if (UV) goto label;
1413 int n1t;
1414 if (UV) goto label;
1416 int n2t;
1417 if (UV) goto label;
1418 label:
1423 // CHECK: [B1]
1424 // CHECK-NEXT: 1: CFGScopeBegin(i)
1425 // CHECK-NEXT: 2: int i __attribute__((cleanup(cleanup_int)));
1426 // CHECK-NEXT: 3: CleanupFunction (cleanup_int)
1427 // CHECK-NEXT: 4: CFGScopeEnd(i)
1428 void cleanup_int(int *i);
1429 void test_cleanup_functions() {
1430 int i __attribute__((cleanup(cleanup_int)));
1433 // CHECK: [B1]
1434 // CHECK-NEXT: 1: 10
1435 // CHECK-NEXT: 2: i
1436 // CHECK-NEXT: 3: [B1.2] = [B1.1]
1437 // CHECK-NEXT: 4: return;
1438 // CHECK-NEXT: 5: CleanupFunction (cleanup_int)
1439 // CHECK-NEXT: 6: CFGScopeEnd(i)
1440 // CHECK-NEXT: Preds (1): B3
1441 // CHECK-NEXT: Succs (1): B0
1442 // CHECK: [B2]
1443 // CHECK-NEXT: 1: return;
1444 // CHECK-NEXT: 2: CleanupFunction (cleanup_int)
1445 // CHECK-NEXT: 3: CFGScopeEnd(i)
1446 // CHECK-NEXT: Preds (1): B3
1447 // CHECK-NEXT: Succs (1): B0
1448 // CHECK: [B3]
1449 // CHECK-NEXT: 1: CFGScopeBegin(i)
1450 // CHECK-NEXT: 2: int i __attribute__((cleanup(cleanup_int)));
1451 // CHECK-NEXT: 3: m
1452 // CHECK-NEXT: 4: [B3.3] (ImplicitCastExpr, LValueToRValue, int)
1453 // CHECK-NEXT: 5: 1
1454 // CHECK-NEXT: 6: [B3.4] == [B3.5]
1455 // CHECK-NEXT: T: if [B3.6]
1456 // CHECK-NEXT: Preds (1): B4
1457 // CHECK-NEXT: Succs (2): B2 B1
1458 void test_cleanup_functions2(int m) {
1459 int i __attribute__((cleanup(cleanup_int)));
1461 if (m == 1) {
1462 return;
1465 i = 10;
1466 return;
1469 // CHECK: [B1]
1470 // CHECK-NEXT: 1: CFGScopeBegin(f)
1471 // CHECK-NEXT: 2: (CXXConstructExpr, [B1.3], F)
1472 // CHECK-NEXT: 3: __attribute__((cleanup(cleanup_F))) F f;
1473 // CHECK-NEXT: 4: CleanupFunction (cleanup_F)
1474 // CHECK-NEXT: 5: [B1.3].~F() (Implicit destructor)
1475 // CHECK-NEXT: 6: CFGScopeEnd(f)
1476 // CHECK-NEXT: Preds (1): B2
1477 // CHECK-NEXT: Succs (1): B0
1478 class F {
1479 public:
1480 ~F();
1482 void cleanup_F(F *f);
1484 void test() {
1485 F f __attribute((cleanup(cleanup_F)));