1 // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -analyze -analyzer-checker=debug.DumpCFG %s > %t 2>&1
2 // RUN: FileCheck --input-file=%t %s
3 
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
A()10   A() {}
11 
12 // CHECK:      [B1 (ENTRY)]
13 // CHECK-NEXT:   Succs (1): B0
14 // CHECK:      [B0 (EXIT)]
15 // CHECK-NEXT:   Preds (1): B1
~A()16   ~A() {}
17 
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
operator int() const27   operator int() const { return 1; }
28 };
29 
30 extern const bool UV;
31 
32 // CHECK:      [B2 (ENTRY)]
33 // CHECK-NEXT:   Succs (1): B1
34 // CHECK:      [B1]
35 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
36 // CHECK-NEXT:   2: A a;
37 // CHECK-NEXT:   3: a
38 // CHECK-NEXT:   4: [B1.3] (ImplicitCastExpr, NoOp, const class A)
39 // CHECK-NEXT:   5: const A &b = a;
40 // CHECK-NEXT:   6: A() (CXXConstructExpr, class A)
41 // CHECK-NEXT:   7: [B1.6] (BindTemporary)
42 // CHECK-NEXT:   8: [B1.7] (ImplicitCastExpr, NoOp, const class A)
43 // CHECK-NEXT:   9: [B1.8]
44 // CHECK:       10: const A &c = A();
45 // CHECK:       11: [B1.10].~A() (Implicit destructor)
46 // CHECK:       12: [B1.2].~A() (Implicit destructor)
47 // CHECK-NEXT:   Preds (1): B2
48 // CHECK-NEXT:   Succs (1): B0
49 // CHECK:      [B0 (EXIT)]
50 // CHECK-NEXT:   Preds (1): B1
test_const_ref()51 void test_const_ref() {
52   A a;
53   const A& b = a;
54   const A& c = A();
55 }
56 
57 // CHECK:      [B2 (ENTRY)]
58 // CHECK-NEXT:   Succs (1): B1
59 // CHECK:      [B1]
60 // CHECK-NEXT:   1:  (CXXConstructExpr, class A [2])
61 // CHECK-NEXT:   2: A a[2];
62 // CHECK-NEXT:   3:  (CXXConstructExpr, class A [0])
63 // CHECK-NEXT:   4: A b[0];
64 // CHECK-NEXT:   5: [B1.2].~A() (Implicit destructor)
65 // CHECK-NEXT:   Preds (1): B2
66 // CHECK-NEXT:   Succs (1): B0
67 // CHECK:      [B0 (EXIT)]
68 // CHECK-NEXT:   Preds (1): B1
test_array()69 void test_array() {
70   A a[2];
71   A b[0];
72 }
73 
74 // CHECK:      [B2 (ENTRY)]
75 // CHECK-NEXT:   Succs (1): B1
76 // CHECK:      [B1]
77 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
78 // CHECK-NEXT:   2: A a;
79 // CHECK-NEXT:   3:  (CXXConstructExpr, class A)
80 // CHECK-NEXT:   4: A c;
81 // CHECK-NEXT:   5:  (CXXConstructExpr, class A)
82 // CHECK-NEXT:   6: A d;
83 // CHECK-NEXT:   7: [B1.6].~A() (Implicit destructor)
84 // CHECK-NEXT:   8: [B1.4].~A() (Implicit destructor)
85 // CHECK-NEXT:   9:  (CXXConstructExpr, class A)
86 // CHECK:       10: A b;
87 // CHECK:       11: [B1.10].~A() (Implicit destructor)
88 // CHECK:       12: [B1.2].~A() (Implicit destructor)
89 // CHECK-NEXT:   Preds (1): B2
90 // CHECK-NEXT:   Succs (1): B0
91 // CHECK:      [B0 (EXIT)]
92 // CHECK-NEXT:   Preds (1): B1
test_scope()93 void test_scope() {
94   A a;
95   { A c;
96     A d;
97   }
98   A b;
99 }
100 
101 // CHECK:      [B4 (ENTRY)]
102 // CHECK-NEXT:   Succs (1): B3
103 // CHECK:      [B1]
104 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
105 // CHECK-NEXT:   2: A c;
106 // CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
107 // CHECK-NEXT:   4: [B3.4].~A() (Implicit destructor)
108 // CHECK-NEXT:   5: [B3.2].~A() (Implicit destructor)
109 // CHECK-NEXT:   Preds (1): B3
110 // CHECK-NEXT:   Succs (1): B0
111 // CHECK:      [B2]
112 // CHECK-NEXT:   1: return;
113 // CHECK-NEXT:   2: [B3.4].~A() (Implicit destructor)
114 // CHECK-NEXT:   3: [B3.2].~A() (Implicit destructor)
115 // CHECK-NEXT:   Preds (1): B3
116 // CHECK-NEXT:   Succs (1): B0
117 // CHECK:      [B3]
118 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
119 // CHECK-NEXT:   2: A a;
120 // CHECK-NEXT:   3:  (CXXConstructExpr, class A)
121 // CHECK-NEXT:   4: A b;
122 // CHECK-NEXT:   5: UV
123 // CHECK-NEXT:   6: [B3.5] (ImplicitCastExpr, LValueToRValue, _Bool)
124 // CHECK-NEXT:   T: if [B3.6]
125 // CHECK-NEXT:   Preds (1): B4
126 // CHECK-NEXT:   Succs (2): B2 B1
127 // CHECK:      [B0 (EXIT)]
128 // CHECK-NEXT:   Preds (2): B1 B2
test_return()129 void test_return() {
130   A a;
131   A b;
132   if (UV) return;
133   A c;
134 }
135 
136 // CHECK:      [B8 (ENTRY)]
137 // CHECK-NEXT:   Succs (1): B7
138 // CHECK:      [B1]
139 // CHECK:       l1:
140 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
141 // CHECK-NEXT:   2: A c;
142 // CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
143 // CHECK-NEXT:   4: [B6.2].~A() (Implicit destructor)
144 // CHECK-NEXT:   5: [B7.2].~A() (Implicit destructor)
145 // CHECK-NEXT:   Preds (2): B2 B3
146 // CHECK-NEXT:   Succs (1): B0
147 // CHECK:      [B2]
148 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
149 // CHECK-NEXT:   2: A b;
150 // CHECK-NEXT:   3: [B2.2].~A() (Implicit destructor)
151 // CHECK-NEXT:   4: [B6.4].~A() (Implicit destructor)
152 // CHECK-NEXT:   Preds (1): B4
153 // CHECK-NEXT:   Succs (1): B1
154 // CHECK:      [B3]
155 // CHECK-NEXT:   1: [B6.4].~A() (Implicit destructor)
156 // CHECK-NEXT:   T: goto l1;
157 // CHECK:        Preds (1): B4
158 // CHECK-NEXT:   Succs (1): B1
159 // CHECK:      [B4]
160 // CHECK-NEXT:   1: UV
161 // CHECK-NEXT:   2: [B4.1] (ImplicitCastExpr, LValueToRValue, _Bool)
162 // CHECK-NEXT:   T: if [B4.2]
163 // CHECK-NEXT:   Preds (1): B6
164 // CHECK-NEXT:   Succs (2): B3 B2
165 // CHECK:      [B5]
166 // CHECK-NEXT:   1: [B6.4].~A() (Implicit destructor)
167 // CHECK-NEXT:   2: [B6.2].~A() (Implicit destructor)
168 // CHECK-NEXT:   T: goto l0;
169 // CHECK:        Preds (1): B6
170 // CHECK-NEXT:   Succs (1): B6
171 // CHECK:      [B6]
172 // CHECK:       l0:
173 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
174 // CHECK-NEXT:   2: A b;
175 // CHECK-NEXT:   3:  (CXXConstructExpr, class A)
176 // CHECK-NEXT:   4: A a;
177 // CHECK-NEXT:   5: UV
178 // CHECK-NEXT:   6: [B6.5] (ImplicitCastExpr, LValueToRValue, _Bool)
179 // CHECK-NEXT:   T: if [B6.6]
180 // CHECK-NEXT:   Preds (2): B7 B5
181 // CHECK-NEXT:   Succs (2): B5 B4
182 // CHECK:      [B7]
183 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
184 // CHECK-NEXT:   2: A a;
185 // CHECK-NEXT:   Preds (1): B8
186 // CHECK-NEXT:   Succs (1): B6
187 // CHECK:      [B0 (EXIT)]
188 // CHECK-NEXT:   Preds (1): B1
test_goto()189 void test_goto() {
190   A a;
191 l0:
192   A b;
193   { A a;
194     if (UV) goto l0;
195     if (UV) goto l1;
196     A b;
197   }
198 l1:
199   A c;
200 }
201 
202 // CHECK:      [B5 (ENTRY)]
203 // CHECK-NEXT:   Succs (1): B4
204 // CHECK:      [B1]
205 // CHECK-NEXT:   1: [B4.6].~A() (Implicit destructor)
206 // CHECK-NEXT:   2: [B4.2].~A() (Implicit destructor)
207 // CHECK-NEXT:   Preds (2): B2 B3
208 // CHECK-NEXT:   Succs (1): B0
209 // CHECK:      [B2]
210 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
211 // CHECK-NEXT:   2: A c;
212 // CHECK-NEXT:   3: [B2.2].~A() (Implicit destructor)
213 // CHECK-NEXT:   Preds (1): B4
214 // CHECK-NEXT:   Succs (1): B1
215 // CHECK:      [B3]
216 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
217 // CHECK-NEXT:   2: A c;
218 // CHECK-NEXT:   3: [B3.2].~A() (Implicit destructor)
219 // CHECK-NEXT:   Preds (1): B4
220 // CHECK-NEXT:   Succs (1): B1
221 // CHECK:      [B4]
222 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
223 // CHECK-NEXT:   2: A a;
224 // CHECK-NEXT:   3: a
225 // CHECK-NEXT:   4: [B4.3] (ImplicitCastExpr, NoOp, const class A)
226 // CHECK-NEXT:   5: [B4.4] (CXXConstructExpr, class A)
227 // CHECK-NEXT:   6: A b = a;
228 // CHECK-NEXT:   7: b
229 // CHECK-NEXT:   8: [B4.7] (ImplicitCastExpr, NoOp, const class A)
230 // CHECK-NEXT:   9: [B4.8].operator int
231 // CHECK:       10: [B4.8]
232 // CHECK:       11: [B4.10] (ImplicitCastExpr, UserDefinedConversion, int)
233 // CHECK:       12: [B4.11] (ImplicitCastExpr, IntegralToBoolean, _Bool)
234 // CHECK-NEXT:   T: if [B4.12]
235 // CHECK-NEXT:   Preds (1): B5
236 // CHECK-NEXT:   Succs (2): B3 B2
237 // CHECK:      [B0 (EXIT)]
238 // CHECK-NEXT:   Preds (1): B1
test_if_implicit_scope()239 void test_if_implicit_scope() {
240   A a;
241   if (A b = a)
242     A c;
243   else A c;
244 }
245 
246 // CHECK:      [B9 (ENTRY)]
247 // CHECK-NEXT:   Succs (1): B8
248 // CHECK:      [B1]
249 // CHECK-NEXT:   1: [B8.6].~A() (Implicit destructor)
250 // CHECK-NEXT:   2:  (CXXConstructExpr, class A)
251 // CHECK-NEXT:   3: A e;
252 // CHECK-NEXT:   4: [B1.3].~A() (Implicit destructor)
253 // CHECK-NEXT:   5: [B8.2].~A() (Implicit destructor)
254 // CHECK-NEXT:   Preds (2): B2 B5
255 // CHECK-NEXT:   Succs (1): B0
256 // CHECK:      [B2]
257 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
258 // CHECK-NEXT:   2: A d;
259 // CHECK-NEXT:   3: [B2.2].~A() (Implicit destructor)
260 // CHECK-NEXT:   4: [B4.2].~A() (Implicit destructor)
261 // CHECK-NEXT:   Preds (1): B4
262 // CHECK-NEXT:   Succs (1): B1
263 // CHECK:      [B3]
264 // CHECK-NEXT:   1: return;
265 // CHECK-NEXT:   2: [B4.2].~A() (Implicit destructor)
266 // CHECK-NEXT:   3: [B8.6].~A() (Implicit destructor)
267 // CHECK-NEXT:   4: [B8.2].~A() (Implicit destructor)
268 // CHECK-NEXT:   Preds (1): B4
269 // CHECK-NEXT:   Succs (1): B0
270 // CHECK:      [B4]
271 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
272 // CHECK-NEXT:   2: A c;
273 // CHECK-NEXT:   3: UV
274 // CHECK-NEXT:   4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
275 // CHECK-NEXT:   T: if [B4.4]
276 // CHECK-NEXT:   Preds (1): B8
277 // CHECK-NEXT:   Succs (2): B3 B2
278 // CHECK:      [B5]
279 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
280 // CHECK-NEXT:   2: A d;
281 // CHECK-NEXT:   3: [B5.2].~A() (Implicit destructor)
282 // CHECK-NEXT:   4: [B7.2].~A() (Implicit destructor)
283 // CHECK-NEXT:   Preds (1): B7
284 // CHECK-NEXT:   Succs (1): B1
285 // CHECK:      [B6]
286 // CHECK-NEXT:   1: return;
287 // CHECK-NEXT:   2: [B7.2].~A() (Implicit destructor)
288 // CHECK-NEXT:   3: [B8.6].~A() (Implicit destructor)
289 // CHECK-NEXT:   4: [B8.2].~A() (Implicit destructor)
290 // CHECK-NEXT:   Preds (1): B7
291 // CHECK-NEXT:   Succs (1): B0
292 // CHECK:      [B7]
293 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
294 // CHECK-NEXT:   2: A c;
295 // CHECK-NEXT:   3: UV
296 // CHECK-NEXT:   4: [B7.3] (ImplicitCastExpr, LValueToRValue, _Bool)
297 // CHECK-NEXT:   T: if [B7.4]
298 // CHECK-NEXT:   Preds (1): B8
299 // CHECK-NEXT:   Succs (2): B6 B5
300 // CHECK:      [B8]
301 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
302 // CHECK-NEXT:   2: A a;
303 // CHECK-NEXT:   3: a
304 // CHECK-NEXT:   4: [B8.3] (ImplicitCastExpr, NoOp, const class A)
305 // CHECK-NEXT:   5: [B8.4] (CXXConstructExpr, class A)
306 // CHECK-NEXT:   6: A b = a;
307 // CHECK-NEXT:   7: b
308 // CHECK-NEXT:   8: [B8.7] (ImplicitCastExpr, NoOp, const class A)
309 // CHECK-NEXT:   9: [B8.8].operator int
310 // CHECK:       10: [B8.8]
311 // CHECK:       11: [B8.10] (ImplicitCastExpr, UserDefinedConversion, int)
312 // CHECK:       12: [B8.11] (ImplicitCastExpr, IntegralToBoolean, _Bool)
313 // CHECK-NEXT:   T: if [B8.12]
314 // CHECK-NEXT:   Preds (1): B9
315 // CHECK-NEXT:   Succs (2): B7 B4
316 // CHECK:      [B0 (EXIT)]
317 // CHECK-NEXT:   Preds (3): B1 B3 B6
test_if_jumps()318 void test_if_jumps() {
319   A a;
320   if (A b = a) {
321     A c;
322     if (UV) return;
323     A d;
324   } else {
325     A c;
326     if (UV) return;
327     A d;
328   }
329   A e;
330 }
331 
332 // CHECK:      [B6 (ENTRY)]
333 // CHECK-NEXT:   Succs (1): B5
334 // CHECK:      [B1]
335 // CHECK-NEXT:   1: [B4.4].~A() (Implicit destructor)
336 // CHECK-NEXT:   2: [B5.2].~A() (Implicit destructor)
337 // CHECK-NEXT:   Preds (1): B4
338 // CHECK-NEXT:   Succs (1): B0
339 // CHECK:      [B2]
340 // CHECK-NEXT:   Preds (1): B3
341 // CHECK-NEXT:   Succs (1): B4
342 // CHECK:      [B3]
343 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
344 // CHECK-NEXT:   2: A c;
345 // CHECK-NEXT:   3: [B3.2].~A() (Implicit destructor)
346 // CHECK-NEXT:   4: [B4.4].~A() (Implicit destructor)
347 // CHECK-NEXT:   Preds (1): B4
348 // CHECK-NEXT:   Succs (1): B2
349 // CHECK:      [B4]
350 // CHECK-NEXT:   1: a
351 // CHECK-NEXT:   2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
352 // CHECK-NEXT:   3: [B4.2] (CXXConstructExpr, class A)
353 // CHECK-NEXT:   4: A b = a;
354 // CHECK-NEXT:   5: b
355 // CHECK-NEXT:   6: [B4.5] (ImplicitCastExpr, NoOp, const class A)
356 // CHECK-NEXT:   7: [B4.6].operator int
357 // CHECK-NEXT:   8: [B4.6]
358 // CHECK-NEXT:   9: [B4.8] (ImplicitCastExpr, UserDefinedConversion, int)
359 // CHECK:       10: [B4.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
360 // CHECK-NEXT:   T: while [B4.10]
361 // CHECK-NEXT:   Preds (2): B2 B5
362 // CHECK-NEXT:   Succs (2): B3 B1
363 // CHECK:      [B5]
364 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
365 // CHECK-NEXT:   2: A a;
366 // CHECK-NEXT:   Preds (1): B6
367 // CHECK-NEXT:   Succs (1): B4
368 // CHECK:      [B0 (EXIT)]
369 // CHECK-NEXT:   Preds (1): B1
test_while_implicit_scope()370 void test_while_implicit_scope() {
371   A a;
372   while (A b = a)
373     A c;
374 }
375 
376 // CHECK:      [B12 (ENTRY)]
377 // CHECK-NEXT:   Succs (1): B11
378 // CHECK:      [B1]
379 // CHECK-NEXT:   1: [B10.4].~A() (Implicit destructor)
380 // CHECK-NEXT:   2:  (CXXConstructExpr, class A)
381 // CHECK-NEXT:   3: A e;
382 // CHECK-NEXT:   4: [B1.3].~A() (Implicit destructor)
383 // CHECK-NEXT:   5: [B11.2].~A() (Implicit destructor)
384 // CHECK-NEXT:   Preds (2): B8 B10
385 // CHECK-NEXT:   Succs (1): B0
386 // CHECK:      [B2]
387 // CHECK-NEXT:   Preds (2): B3 B6
388 // CHECK-NEXT:   Succs (1): B10
389 // CHECK:      [B3]
390 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
391 // CHECK-NEXT:   2: A d;
392 // CHECK-NEXT:   3: [B3.2].~A() (Implicit destructor)
393 // CHECK-NEXT:   4: [B9.2].~A() (Implicit destructor)
394 // CHECK-NEXT:   5: [B10.4].~A() (Implicit destructor)
395 // CHECK-NEXT:   Preds (1): B5
396 // CHECK-NEXT:   Succs (1): B2
397 // CHECK:      [B4]
398 // CHECK-NEXT:   1: return;
399 // CHECK-NEXT:   2: [B9.2].~A() (Implicit destructor)
400 // CHECK-NEXT:   3: [B10.4].~A() (Implicit destructor)
401 // CHECK-NEXT:   4: [B11.2].~A() (Implicit destructor)
402 // CHECK-NEXT:   Preds (1): B5
403 // CHECK-NEXT:   Succs (1): B0
404 // CHECK:      [B5]
405 // CHECK-NEXT:   1: UV
406 // CHECK-NEXT:   2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
407 // CHECK-NEXT:   T: if [B5.2]
408 // CHECK-NEXT:   Preds (1): B7
409 // CHECK-NEXT:   Succs (2): B4 B3
410 // CHECK:      [B6]
411 // CHECK-NEXT:   1: [B9.2].~A() (Implicit destructor)
412 // CHECK-NEXT:   2: [B10.4].~A() (Implicit destructor)
413 // CHECK-NEXT:   T: continue;
414 // CHECK:        Preds (1): B7
415 // CHECK-NEXT:   Succs (1): B2
416 // CHECK:      [B7]
417 // CHECK-NEXT:   1: UV
418 // CHECK-NEXT:   2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
419 // CHECK-NEXT:   T: if [B7.2]
420 // CHECK-NEXT:   Preds (1): B9
421 // CHECK-NEXT:   Succs (2): B6 B5
422 // CHECK:      [B8]
423 // CHECK-NEXT:   1: [B9.2].~A() (Implicit destructor)
424 // CHECK-NEXT:   T: break;
425 // CHECK:        Preds (1): B9
426 // CHECK-NEXT:   Succs (1): B1
427 // CHECK:      [B9]
428 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
429 // CHECK-NEXT:   2: A c;
430 // CHECK-NEXT:   3: UV
431 // CHECK-NEXT:   4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool)
432 // CHECK-NEXT:   T: if [B9.4]
433 // CHECK-NEXT:   Preds (1): B10
434 // CHECK-NEXT:   Succs (2): B8 B7
435 // CHECK:      [B10]
436 // CHECK-NEXT:   1: a
437 // CHECK-NEXT:   2: [B10.1] (ImplicitCastExpr, NoOp, const class A)
438 // CHECK-NEXT:   3: [B10.2] (CXXConstructExpr, class A)
439 // CHECK-NEXT:   4: A b = a;
440 // CHECK-NEXT:   5: b
441 // CHECK-NEXT:   6: [B10.5] (ImplicitCastExpr, NoOp, const class A)
442 // CHECK-NEXT:   7: [B10.6].operator int
443 // CHECK-NEXT:   8: [B10.6]
444 // CHECK-NEXT:   9: [B10.8] (ImplicitCastExpr, UserDefinedConversion, int)
445 // CHECK:       10: [B10.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
446 // CHECK-NEXT:   T: while [B10.10]
447 // CHECK-NEXT:   Preds (2): B2 B11
448 // CHECK-NEXT:   Succs (2): B9 B1
449 // CHECK:      [B11]
450 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
451 // CHECK-NEXT:   2: A a;
452 // CHECK-NEXT:   Preds (1): B12
453 // CHECK-NEXT:   Succs (1): B10
454 // CHECK:      [B0 (EXIT)]
455 // CHECK-NEXT:   Preds (2): B1 B4
test_while_jumps()456 void test_while_jumps() {
457   A a;
458   while (A b = a) {
459     A c;
460     if (UV) break;
461     if (UV) continue;
462     if (UV) return;
463     A d;
464   }
465   A e;
466 }
467 
468 // CHECK:      [B4 (ENTRY)]
469 // CHECK-NEXT:   Succs (1): B2
470 // CHECK:      [B1]
471 // CHECK-NEXT:   1: UV
472 // CHECK-NEXT:   2: [B1.1] (ImplicitCastExpr, LValueToRValue, _Bool)
473 // CHECK-NEXT:   T: do ... while [B1.2]
474 // CHECK-NEXT:   Preds (1): B2
475 // CHECK-NEXT:   Succs (2): B3 B0
476 // CHECK:      [B2]
477 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
478 // CHECK-NEXT:   2: A a;
479 // CHECK-NEXT:   3: [B2.2].~A() (Implicit destructor)
480 // CHECK-NEXT:   Preds (2): B3 B4
481 // CHECK-NEXT:   Succs (1): B1
482 // CHECK:      [B3]
483 // CHECK-NEXT:   Preds (1): B1
484 // CHECK-NEXT:   Succs (1): B2
485 // CHECK:      [B0 (EXIT)]
486 // CHECK-NEXT:   Preds (1): B1
test_do_implicit_scope()487 void test_do_implicit_scope() {
488   do A a;
489   while (UV);
490 }
491 
492 // CHECK:      [B12 (ENTRY)]
493 // CHECK-NEXT:   Succs (1): B11
494 // CHECK:      [B1]
495 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
496 // CHECK-NEXT:   2: A d;
497 // CHECK-NEXT:   3: [B1.2].~A() (Implicit destructor)
498 // CHECK-NEXT:   4: [B11.2].~A() (Implicit destructor)
499 // CHECK-NEXT:   Preds (2): B8 B2
500 // CHECK-NEXT:   Succs (1): B0
501 // CHECK:      [B2]
502 // CHECK-NEXT:   1: UV
503 // CHECK-NEXT:   2: [B2.1] (ImplicitCastExpr, LValueToRValue, _Bool)
504 // CHECK-NEXT:   T: do ... while [B2.2]
505 // CHECK-NEXT:   Preds (2): B3 B6
506 // CHECK-NEXT:   Succs (2): B10 B1
507 // CHECK:      [B3]
508 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
509 // CHECK-NEXT:   2: A c;
510 // CHECK-NEXT:   3: [B3.2].~A() (Implicit destructor)
511 // CHECK-NEXT:   4: [B9.2].~A() (Implicit destructor)
512 // CHECK-NEXT:   Preds (1): B5
513 // CHECK-NEXT:   Succs (1): B2
514 // CHECK:      [B4]
515 // CHECK-NEXT:   1: return;
516 // CHECK-NEXT:   2: [B9.2].~A() (Implicit destructor)
517 // CHECK-NEXT:   3: [B11.2].~A() (Implicit destructor)
518 // CHECK-NEXT:   Preds (1): B5
519 // CHECK-NEXT:   Succs (1): B0
520 // CHECK:      [B5]
521 // CHECK-NEXT:   1: UV
522 // CHECK-NEXT:   2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
523 // CHECK-NEXT:   T: if [B5.2]
524 // CHECK-NEXT:   Preds (1): B7
525 // CHECK-NEXT:   Succs (2): B4 B3
526 // CHECK:      [B6]
527 // CHECK-NEXT:   1: [B9.2].~A() (Implicit destructor)
528 // CHECK-NEXT:   T: continue;
529 // CHECK:        Preds (1): B7
530 // CHECK-NEXT:   Succs (1): B2
531 // CHECK:      [B7]
532 // CHECK-NEXT:   1: UV
533 // CHECK-NEXT:   2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
534 // CHECK-NEXT:   T: if [B7.2]
535 // CHECK-NEXT:   Preds (1): B9
536 // CHECK-NEXT:   Succs (2): B6 B5
537 // CHECK:      [B8]
538 // CHECK-NEXT:   1: [B9.2].~A() (Implicit destructor)
539 // CHECK-NEXT:   T: break;
540 // CHECK:        Preds (1): B9
541 // CHECK-NEXT:   Succs (1): B1
542 // CHECK:      [B9]
543 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
544 // CHECK-NEXT:   2: A b;
545 // CHECK-NEXT:   3: UV
546 // CHECK-NEXT:   4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool)
547 // CHECK-NEXT:   T: if [B9.4]
548 // CHECK-NEXT:   Preds (2): B10 B11
549 // CHECK-NEXT:   Succs (2): B8 B7
550 // CHECK:      [B10]
551 // CHECK-NEXT:   Preds (1): B2
552 // CHECK-NEXT:   Succs (1): B9
553 // CHECK:      [B11]
554 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
555 // CHECK-NEXT:   2: A a;
556 // CHECK-NEXT:   Preds (1): B12
557 // CHECK-NEXT:   Succs (1): B9
558 // CHECK:      [B0 (EXIT)]
559 // CHECK-NEXT:   Preds (2): B1 B4
test_do_jumps()560 void test_do_jumps() {
561   A a;
562   do {
563     A b;
564     if (UV) break;
565     if (UV) continue;
566     if (UV) return;
567     A c;
568   } while (UV);
569   A d;
570 }
571 
572 // CHECK:      [B4 (ENTRY)]
573 // CHECK-NEXT:   Succs (1): B2
574 // CHECK:      [B1]
575 // CHECK-NEXT:   1: [B2.6].~A() (Implicit destructor)
576 // CHECK-NEXT:   2: [B2.2].~A() (Implicit destructor)
577 // CHECK-NEXT:   Preds (2): B3 B2
578 // CHECK-NEXT:   Succs (1): B0
579 // CHECK:      [B2]
580 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
581 // CHECK-NEXT:   2: A a;
582 // CHECK-NEXT:   3: a
583 // CHECK-NEXT:   4: [B2.3] (ImplicitCastExpr, NoOp, const class A)
584 // CHECK-NEXT:   5: [B2.4] (CXXConstructExpr, class A)
585 // CHECK-NEXT:   6: A b = a;
586 // CHECK-NEXT:   7: b
587 // CHECK-NEXT:   8: [B2.7] (ImplicitCastExpr, NoOp, const class A)
588 // CHECK-NEXT:   9: [B2.8].operator int
589 // CHECK:       10: [B2.8]
590 // CHECK:       11: [B2.10] (ImplicitCastExpr, UserDefinedConversion, int)
591 // CHECK-NEXT:   T: switch [B2.11]
592 // CHECK-NEXT:   Preds (1): B4
593 // CHECK-NEXT:   Succs (1): B1
594 // CHECK:      [B3]
595 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
596 // CHECK-NEXT:   2: A c;
597 // CHECK-NEXT:   3: [B3.2].~A() (Implicit destructor)
598 // CHECK-NEXT:   Succs (1): B1
599 // CHECK:      [B0 (EXIT)]
600 // CHECK-NEXT:   Preds (1): B1
test_switch_implicit_scope()601 void test_switch_implicit_scope() {
602   A a;
603   switch (A b = a)
604     A c;
605 }
606 
607 // CHECK:      [B9 (ENTRY)]
608 // CHECK-NEXT:   Succs (1): B2
609 // CHECK:      [B1]
610 // CHECK-NEXT:   1: [B2.6].~A() (Implicit destructor)
611 // CHECK-NEXT:   2:  (CXXConstructExpr, class A)
612 // CHECK-NEXT:   3: A g;
613 // CHECK-NEXT:   4: [B1.3].~A() (Implicit destructor)
614 // CHECK-NEXT:   5: [B2.2].~A() (Implicit destructor)
615 // CHECK-NEXT:   Preds (3): B3 B7 B2
616 // CHECK-NEXT:   Succs (1): B0
617 // CHECK:      [B2]
618 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
619 // CHECK-NEXT:   2: A a;
620 // CHECK-NEXT:   3: a
621 // CHECK-NEXT:   4: [B2.3] (ImplicitCastExpr, NoOp, const class A)
622 // CHECK-NEXT:   5: [B2.4] (CXXConstructExpr, class A)
623 // CHECK-NEXT:   6: A b = a;
624 // CHECK-NEXT:   7: b
625 // CHECK-NEXT:   8: [B2.7] (ImplicitCastExpr, NoOp, const class A)
626 // CHECK-NEXT:   9: [B2.8].operator int
627 // CHECK:       10: [B2.8]
628 // CHECK:       11: [B2.10] (ImplicitCastExpr, UserDefinedConversion, int)
629 // CHECK-NEXT:   T: switch [B2.11]
630 // CHECK-NEXT:   Preds (1): B9
631 // CHECK-NEXT:   Succs (3): B3 B8 B1
632 // CHECK:      [B3]
633 // CHECK:       case 1:
634 // CHECK-NEXT:   T: break;
635 // CHECK:        Preds (2): B2 B4
636 // CHECK-NEXT:   Succs (1): B1
637 // CHECK:      [B4]
638 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
639 // CHECK-NEXT:   2: A f;
640 // CHECK-NEXT:   3: [B4.2].~A() (Implicit destructor)
641 // CHECK-NEXT:   4: [B8.2].~A() (Implicit destructor)
642 // CHECK-NEXT:   Preds (1): B6
643 // CHECK-NEXT:   Succs (1): B3
644 // CHECK:      [B5]
645 // CHECK-NEXT:   1: return;
646 // CHECK-NEXT:   2: [B8.2].~A() (Implicit destructor)
647 // CHECK-NEXT:   3: [B2.6].~A() (Implicit destructor)
648 // CHECK-NEXT:   4: [B2.2].~A() (Implicit destructor)
649 // CHECK-NEXT:   Preds (1): B6
650 // CHECK-NEXT:   Succs (1): B0
651 // CHECK:      [B6]
652 // CHECK-NEXT:   1: UV
653 // CHECK-NEXT:   2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool)
654 // CHECK-NEXT:   T: if [B6.2]
655 // CHECK-NEXT:   Preds (1): B8
656 // CHECK-NEXT:   Succs (2): B5 B4
657 // CHECK:      [B7]
658 // CHECK-NEXT:   1: [B8.2].~A() (Implicit destructor)
659 // CHECK-NEXT:   T: break;
660 // CHECK:        Preds (1): B8
661 // CHECK-NEXT:   Succs (1): B1
662 // CHECK:      [B8]
663 // CHECK:       case 0:
664 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
665 // CHECK-NEXT:   2: A c;
666 // CHECK-NEXT:   3: UV
667 // CHECK-NEXT:   4: [B8.3] (ImplicitCastExpr, LValueToRValue, _Bool)
668 // CHECK-NEXT:   T: if [B8.4]
669 // CHECK-NEXT:   Preds (1): B2
670 // CHECK-NEXT:   Succs (2): B7 B6
671 // CHECK:      [B0 (EXIT)]
672 // CHECK-NEXT:   Preds (2): B1 B5
test_switch_jumps()673 void test_switch_jumps() {
674   A a;
675   switch (A b = a) {
676   case 0: {
677     A c;
678     if (UV) break;
679     if (UV) return;
680     A f;
681   }
682   case 1:
683     break;
684   }
685   A g;
686 }
687 
688 // CHECK:      [B6 (ENTRY)]
689 // CHECK-NEXT:   Succs (1): B5
690 // CHECK:      [B1]
691 // CHECK-NEXT:   1: [B4.4].~A() (Implicit destructor)
692 // CHECK-NEXT:   2: [B5.2].~A() (Implicit destructor)
693 // CHECK-NEXT:   Preds (1): B4
694 // CHECK-NEXT:   Succs (1): B0
695 // CHECK:      [B2]
696 // CHECK-NEXT:   Preds (1): B3
697 // CHECK-NEXT:   Succs (1): B4
698 // CHECK:      [B3]
699 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
700 // CHECK-NEXT:   2: A c;
701 // CHECK-NEXT:   3: [B3.2].~A() (Implicit destructor)
702 // CHECK-NEXT:   4: [B4.4].~A() (Implicit destructor)
703 // CHECK-NEXT:   Preds (1): B4
704 // CHECK-NEXT:   Succs (1): B2
705 // CHECK:      [B4]
706 // CHECK-NEXT:   1: a
707 // CHECK-NEXT:   2: [B4.1] (ImplicitCastExpr, NoOp, const class A)
708 // CHECK-NEXT:   3: [B4.2] (CXXConstructExpr, class A)
709 // CHECK-NEXT:   4: A b = a;
710 // CHECK-NEXT:   5: b
711 // CHECK-NEXT:   6: [B4.5] (ImplicitCastExpr, NoOp, const class A)
712 // CHECK-NEXT:   7: [B4.6].operator int
713 // CHECK-NEXT:   8: [B4.6]
714 // CHECK-NEXT:   9: [B4.8] (ImplicitCastExpr, UserDefinedConversion, int)
715 // CHECK:       10: [B4.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
716 // CHECK-NEXT:   T: for (...; [B4.10]; )
717 // CHECK-NEXT:   Preds (2): B2 B5
718 // CHECK-NEXT:   Succs (2): B3 B1
719 // CHECK:      [B5]
720 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
721 // CHECK-NEXT:   2: A a;
722 // CHECK-NEXT:   Preds (1): B6
723 // CHECK-NEXT:   Succs (1): B4
724 // CHECK:      [B0 (EXIT)]
725 // CHECK-NEXT:   Preds (1): B1
test_for_implicit_scope()726 void test_for_implicit_scope() {
727   for (A a; A b = a; )
728     A c;
729 }
730 
731 // CHECK:      [B12 (ENTRY)]
732 // CHECK-NEXT:   Succs (1): B11
733 // CHECK:      [B1]
734 // CHECK-NEXT:   1: [B10.4].~A() (Implicit destructor)
735 // CHECK-NEXT:   2: [B11.4].~A() (Implicit destructor)
736 // CHECK-NEXT:   3:  (CXXConstructExpr, class A)
737 // CHECK-NEXT:   4: A f;
738 // CHECK-NEXT:   5: [B1.4].~A() (Implicit destructor)
739 // CHECK-NEXT:   6: [B11.2].~A() (Implicit destructor)
740 // CHECK-NEXT:   Preds (2): B8 B10
741 // CHECK-NEXT:   Succs (1): B0
742 // CHECK:      [B2]
743 // CHECK-NEXT:   Preds (2): B3 B6
744 // CHECK-NEXT:   Succs (1): B10
745 // CHECK:      [B3]
746 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
747 // CHECK-NEXT:   2: A e;
748 // CHECK-NEXT:   3: [B3.2].~A() (Implicit destructor)
749 // CHECK-NEXT:   4: [B9.2].~A() (Implicit destructor)
750 // CHECK-NEXT:   5: [B10.4].~A() (Implicit destructor)
751 // CHECK-NEXT:   Preds (1): B5
752 // CHECK-NEXT:   Succs (1): B2
753 // CHECK:      [B4]
754 // CHECK-NEXT:   1: return;
755 // CHECK-NEXT:   2: [B9.2].~A() (Implicit destructor)
756 // CHECK-NEXT:   3: [B10.4].~A() (Implicit destructor)
757 // CHECK-NEXT:   4: [B11.4].~A() (Implicit destructor)
758 // CHECK-NEXT:   5: [B11.2].~A() (Implicit destructor)
759 // CHECK-NEXT:   Preds (1): B5
760 // CHECK-NEXT:   Succs (1): B0
761 // CHECK:      [B5]
762 // CHECK-NEXT:   1: UV
763 // CHECK-NEXT:   2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool)
764 // CHECK-NEXT:   T: if [B5.2]
765 // CHECK-NEXT:   Preds (1): B7
766 // CHECK-NEXT:   Succs (2): B4 B3
767 // CHECK:      [B6]
768 // CHECK-NEXT:   1: [B9.2].~A() (Implicit destructor)
769 // CHECK-NEXT:   T: continue;
770 // CHECK:        Preds (1): B7
771 // CHECK-NEXT:   Succs (1): B2
772 // CHECK:      [B7]
773 // CHECK-NEXT:   1: UV
774 // CHECK-NEXT:   2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool)
775 // CHECK-NEXT:   T: if [B7.2]
776 // CHECK-NEXT:   Preds (1): B9
777 // CHECK-NEXT:   Succs (2): B6 B5
778 // CHECK:      [B8]
779 // CHECK-NEXT:   1: [B9.2].~A() (Implicit destructor)
780 // CHECK-NEXT:   T: break;
781 // CHECK:        Preds (1): B9
782 // CHECK-NEXT:   Succs (1): B1
783 // CHECK:      [B9]
784 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
785 // CHECK-NEXT:   2: A d;
786 // CHECK-NEXT:   3: UV
787 // CHECK-NEXT:   4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool)
788 // CHECK-NEXT:   T: if [B9.4]
789 // CHECK-NEXT:   Preds (1): B10
790 // CHECK-NEXT:   Succs (2): B8 B7
791 // CHECK:      [B10]
792 // CHECK-NEXT:   1: b
793 // CHECK-NEXT:   2: [B10.1] (ImplicitCastExpr, NoOp, const class A)
794 // CHECK-NEXT:   3: [B10.2] (CXXConstructExpr, class A)
795 // CHECK-NEXT:   4: A c = b;
796 // CHECK-NEXT:   5: c
797 // CHECK-NEXT:   6: [B10.5] (ImplicitCastExpr, NoOp, const class A)
798 // CHECK-NEXT:   7: [B10.6].operator int
799 // CHECK-NEXT:   8: [B10.6]
800 // CHECK-NEXT:   9: [B10.8] (ImplicitCastExpr, UserDefinedConversion, int)
801 // CHECK:       10: [B10.9] (ImplicitCastExpr, IntegralToBoolean, _Bool)
802 // CHECK-NEXT:   T: for (...; [B10.10]; )
803 // CHECK-NEXT:   Preds (2): B2 B11
804 // CHECK-NEXT:   Succs (2): B9 B1
805 // CHECK:      [B11]
806 // CHECK-NEXT:   1:  (CXXConstructExpr, class A)
807 // CHECK-NEXT:   2: A a;
808 // CHECK-NEXT:   3:  (CXXConstructExpr, class A)
809 // CHECK-NEXT:   4: A b;
810 // CHECK-NEXT:   Preds (1): B12
811 // CHECK-NEXT:   Succs (1): B10
812 // CHECK:      [B0 (EXIT)]
813 // CHECK-NEXT:   Preds (2): B1 B4
test_for_jumps()814 void test_for_jumps() {
815   A a;
816   for (A b; A c = b; ) {
817     A d;
818     if (UV) break;
819     if (UV) continue;
820     if (UV) return;
821     A e;
822   }
823   A f;
824 }
825 
826 // CHECK:      [B3 (ENTRY)]
827 // CHECK-NEXT:   Succs (1): B0
828 // CHECK:      [B1]
829 // CHECK-NEXT:   T: try ...
830 // CHECK-NEXT:   Succs (2): B2 B0
831 // CHECK:      [B2]
832 // CHECK-NEXT:  catch (const A &e):
833 // CHECK-NEXT:   1: catch (const A &e) {
834 // CHECK-NEXT:  }
835 // CHECK-NEXT:   Preds (1): B1
836 // CHECK-NEXT:   Succs (1): B0
837 // CHECK:      [B0 (EXIT)]
838 // CHECK-NEXT:   Preds (3): B2 B1 B3
test_catch_const_ref()839 void test_catch_const_ref() {
840   try {
841   } catch (const A& e) {
842   }
843 }
844 
845 // CHECK:      [B3 (ENTRY)]
846 // CHECK-NEXT:   Succs (1): B0
847 // CHECK:      [B1]
848 // CHECK-NEXT:   T: try ...
849 // CHECK-NEXT:   Succs (2): B2 B0
850 // CHECK:      [B2]
851 // CHECK-NEXT:  catch (A e):
852 // CHECK-NEXT:   1: catch (A e) {
853 // CHECK-NEXT:  }
854 // CHECK-NEXT:   2: [B2.1].~A() (Implicit destructor)
855 // CHECK-NEXT:   Preds (1): B1
856 // CHECK-NEXT:   Succs (1): B0
857 // CHECK:      [B0 (EXIT)]
858 // CHECK-NEXT:   Preds (3): B2 B1 B3
test_catch_copy()859 void test_catch_copy() {
860   try {
861   } catch (A e) {
862   }
863 }
864