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
7 // CHECK-NEXT: Succs (1): B0
9 // CHECK-NEXT: Preds (1): B1
12 // CHECK: [B1 (ENTRY)]
13 // CHECK-NEXT: Succs (1): B0
15 // CHECK-NEXT: Preds (1): B1
18 // CHECK: [B2 (ENTRY)]
19 // CHECK-NEXT: Succs (1): B1
22 // CHECK-NEXT: 2: return [B1.1];
23 // CHECK-NEXT: Preds (1): B2
24 // CHECK-NEXT: Succs (1): B0
26 // CHECK-NEXT: Preds (1): B1
27 operator int() const { return 1; }
34 // CHECK: [B2 (ENTRY)]
35 // CHECK-NEXT: Succs (1): 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
47 // CHECK-NEXT: Preds (1): B1
53 // CHECK: [B2 (ENTRY)]
54 // CHECK-NEXT: Succs (1): 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
75 // CHECK-NEXT: Preds (1): B1
84 // CHECK: [B4 (ENTRY)]
85 // CHECK-NEXT: Succs (1): B3
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
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
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;
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
122 // CHECK: [B5 (ENTRY)]
123 // CHECK-NEXT: Succs (1): B4
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
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
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
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)
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;
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() {
174 // CHECK: [B9 (ENTRY)]
175 // CHECK-NEXT: Succs (1): B8
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
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
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
205 // CHECK-NEXT: 1: CFGScopeBegin(c)
206 // CHECK-NEXT: 2: (CXXConstructExpr, [B4.3], A)
207 // CHECK-NEXT: 3: A c;
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
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
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
232 // CHECK-NEXT: 1: CFGScopeBegin(c)
233 // CHECK-NEXT: 2: (CXXConstructExpr, [B7.3], A)
234 // CHECK-NEXT: 3: A c;
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
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)
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;
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() {
274 // CHECK: [B6 (ENTRY)]
275 // CHECK-NEXT: Succs (1): B5
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
284 // CHECK-NEXT: Preds (1): B3
285 // CHECK-NEXT: Succs (1): B4
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
297 // CHECK-NEXT: 1: CFGScopeBegin(b)
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;
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
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() {
325 // CHECK: [B12 (ENTRY)]
326 // CHECK-NEXT: Succs (1): B11
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
338 // CHECK-NEXT: Preds (2): B3 B6
339 // CHECK-NEXT: Succs (1): B10
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
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
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
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
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
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
387 // CHECK-NEXT: 1: CFGScopeBegin(c)
388 // CHECK-NEXT: 2: (CXXConstructExpr, [B9.3], A)
389 // CHECK-NEXT: 3: A c;
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
396 // CHECK-NEXT: 1: CFGScopeBegin(b)
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;
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
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() {
430 // CHECK: [B12 (ENTRY)]
431 // CHECK-NEXT: Succs (1): B11
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
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
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
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
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
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
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
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
487 // CHECK-NEXT: 1: CFGScopeBegin(b)
488 // CHECK-NEXT: 2: (CXXConstructExpr, [B9.3], A)
489 // CHECK-NEXT: 3: A b;
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
496 // CHECK-NEXT: Preds (1): B2
497 // CHECK-NEXT: Succs (1): B9
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() {
518 // CHECK: [B6 (ENTRY)]
519 // CHECK-NEXT: Succs (1): B5
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
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
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
543 // CHECK-NEXT: 1: CFGScopeBegin(b)
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;
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
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
)
570 // CHECK: [B12 (ENTRY)]
571 // CHECK-NEXT: Succs (1): B11
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
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
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
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
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
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
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
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
634 // CHECK-NEXT: 1: CFGScopeBegin(d)
635 // CHECK-NEXT: 2: (CXXConstructExpr, [B9.3], A)
636 // CHECK-NEXT: 3: A d;
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
643 // CHECK-NEXT: 1: CFGScopeBegin(c)
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;
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
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() {
670 for (A b
; A c
= b
; ) {
680 // CHECK: [B9 (ENTRY)]
681 // CHECK-NEXT: Succs (1): B8
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
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
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
703 // CHECK-NEXT: 2: [B4.1] (ImplicitCastExpr, NullToPointer, int *)
704 // CHECK-NEXT: Preds (1): B5
705 // CHECK-NEXT: Succs (1): B2
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
716 // CHECK-NEXT: 2: (void)[B6.1] (CStyleCastExpr, ToVoid, void)
717 // CHECK-NEXT: Preds (1): B7
718 // CHECK-NEXT: Succs (1): B5
720 // CHECK-NEXT: 1: CFGScopeBegin(b)
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;
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
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)
745 // CHECK: [B9 (ENTRY)]
746 // CHECK-NEXT: Succs (1): B7
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
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
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
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
779 // CHECK-NEXT: Preds (1): B6
780 // CHECK-NEXT: Succs (1): B8
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;
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
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
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
825 // CHECK: [B7 (ENTRY)]
826 // CHECK-NEXT: Succs (1): B6
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
836 // CHECK-NEXT: 2: ++[B2.1]
837 // CHECK-NEXT: Preds (1): B3
838 // CHECK-NEXT: Succs (1): B5
840 // CHECK-NEXT: 1: CFGScopeEnd(unused1)
841 // CHECK-NEXT: Succs (1): B2
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
851 // CHECK-NEXT: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, int)
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
858 // CHECK-NEXT: 1: CFGScopeBegin(i)
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
) {
877 // CHECK: [B6 (ENTRY)]
878 // CHECK-NEXT: Succs (1): B5
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
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])
895 // CHECK: Preds (2): B3 B5
896 // CHECK-NEXT: Succs (2): B4 B1
898 // CHECK-NEXT: 1: __begin1
899 // CHECK-NEXT: 2: ++[B3.1]
900 // CHECK-NEXT: Preds (1): B4
901 // CHECK-NEXT: Succs (1): B2
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 &)
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
918 // CHECK-NEXT: 1: CFGScopeBegin(a)
919 // CHECK-NEXT: 2: (CXXConstructExpr, [B5.3], A[10])
920 // CHECK-NEXT: 3: A a[10];
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 *)
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
) {
942 // CHECK: [B8 (ENTRY)]
943 // CHECK-NEXT: Succs (1): B2
945 // CHECK-NEXT: 1: CFGScopeEnd(i)
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
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();
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
966 // CHECK-NEXT: default:
967 // CHECK-NEXT: 1: CFGScopeBegin(a)
969 // CHECK-NEXT: 3: int a = 0;
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
976 // CHECK-NEXT: case 3:
977 // CHECK-NEXT: 1: '2'
979 // CHECK-NEXT: 3: [B4.2] = [B4.1]
980 // CHECK-NEXT: Preds (1): B2
981 // CHECK-NEXT: Succs (1): B3
983 // CHECK-NEXT: case 2:
984 // CHECK-NEXT: 1: '2'
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
991 // CHECK-NEXT: case 1:
992 // CHECK-NEXT: 1: '3'
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
999 // CHECK-NEXT: case 0:
1000 // CHECK-NEXT: 1: '2'
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() {
1009 switch (int i
= getX()) {
1029 // CHECK: [B6 (ENTRY)]
1030 // CHECK-NEXT: Succs (1): B2
1032 // CHECK-NEXT: 1: CFGScopeEnd(i)
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
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();
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
1053 // CHECK-NEXT: case 2:
1054 // CHECK-NEXT: 1: '3'
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
1061 // CHECK-NEXT: case 1:
1062 // CHECK-NEXT: 1: '1'
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
1069 // CHECK-NEXT: case 0:
1070 // CHECK-NEXT: 1: '2'
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() {
1079 switch (int i
= getX()) {
1092 // CHECK: [B5 (ENTRY)]
1093 // CHECK-NEXT: Succs (1): B2
1095 // CHECK-NEXT: 1: CFGScopeEnd(i)
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
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();
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
1116 // CHECK-NEXT: default:
1117 // CHECK-NEXT: 1: CFGScopeBegin(a)
1119 // CHECK-NEXT: 3: int a = 0;
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
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() {
1133 switch (int i
= getX())
1142 // CHECK: [B12 (ENTRY)]
1143 // CHECK-NEXT: Succs (1): B11
1145 // CHECK-NEXT: 1: CFGScopeEnd(i)
1146 // CHECK-NEXT: Preds (2): B4 B10
1147 // CHECK-NEXT: Succs (1): B0
1150 // CHECK-NEXT: 2: ++[B2.1]
1151 // CHECK-NEXT: Preds (2): B3 B7
1152 // CHECK-NEXT: Succs (1): B10
1154 // CHECK-NEXT: 1: CFGScopeEnd(z)
1155 // CHECK-NEXT: Succs (1): B2
1157 // CHECK-NEXT: 1: CFGScopeBegin(z)
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
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
1171 // CHECK-NEXT: default:
1174 // CHECK-NEXT: 3: [B6.2] = [B6.1]
1175 // CHECK-NEXT: Preds (1): B5
1176 // CHECK-NEXT: Succs (1): B4
1178 // CHECK-NEXT: case 2:
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
1186 // CHECK-NEXT: case 1:
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
1194 // CHECK-NEXT: case 0:
1197 // CHECK-NEXT: 3: [B9.2] = [B9.1]
1198 // CHECK-NEXT: Preds (1): B5
1199 // CHECK-NEXT: Succs (1): B8
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
1209 // CHECK-NEXT: 1: CFGScopeBegin(i)
1210 // CHECK-NEXT: 2: int i;
1211 // CHECK-NEXT: 3: int x;
1212 // CHECK-NEXT: 4: int y;
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() {
1222 for (i
= 0; i
< 1000; ++i
) {
1228 break; // break from switch
1231 continue; // continue in loop
1237 break; // break from loop
1242 // CHECK: [B4 (ENTRY)]
1243 // CHECK-NEXT: Succs (1): B3
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
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
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() {
1301 // CHECK: [B5 (ENTRY)]
1302 // CHECK-NEXT: Succs (1): B3
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
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
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
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() {
1363 // CHECK: [B8 (ENTRY)]
1364 // CHECK-NEXT: Succs (1): B7
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
1372 // CHECK-NEXT: T: goto label;
1373 // CHECK-NEXT: Preds (1): B3
1374 // CHECK-NEXT: Succs (1): B1
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
1384 // CHECK-NEXT: 1: CFGScopeBegin(n2t)
1385 // CHECK-NEXT: T: goto label;
1386 // CHECK-NEXT: Preds (1): B5
1387 // CHECK-NEXT: Succs (1): B1
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
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
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() {
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
)));
1434 // CHECK-NEXT: 1: 10
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
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
1449 // CHECK-NEXT: 1: CFGScopeBegin(i)
1450 // CHECK-NEXT: 2: int i __attribute__((cleanup(cleanup_int)));
1452 // CHECK-NEXT: 4: [B3.3] (ImplicitCastExpr, LValueToRValue, int)
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
)));
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
1482 void cleanup_F(F
*f
);
1485 F f
__attribute((cleanup(cleanup_F
)));