1// RUN: %clang_analyze_cc1 -w -fblocks %s \
2// RUN:   -analyzer-checker=debug.DumpLiveExprs \
3// RUN:   2>&1 | FileCheck %s
4
5@interface Item
6// ...
7@end
8
9@interface Collection
10// ...
11@end
12
13typedef void (^Blk)();
14
15struct RAII {
16  Blk blk;
17
18public:
19  RAII(Blk blk): blk(blk) {}
20
21// CHECK: [ B0 (live expressions at block exit) ]
22// CHECK-EMPTY:
23// CHECK-EMPTY:
24// CHECK-NEXT: [ B1 (live expressions at block exit) ]
25// CHECK-EMPTY:
26// CHECK-EMPTY:
27// CHECK-NEXT: [ B2 (live expressions at block exit) ]
28// CHECK-EMPTY:
29// CHECK-EMPTY:
30
31  ~RAII() { blk(); }
32
33// CHECK-NEXT: [ B0 (live expressions at block exit) ]
34// CHECK-EMPTY:
35// CHECK-EMPTY:
36// CHECK-NEXT: [ B1 (live expressions at block exit) ]
37// CHECK-EMPTY:
38// CHECK-EMPTY:
39// CHECK-NEXT: [ B2 (live expressions at block exit) ]
40// CHECK-EMPTY:
41// CHECK-EMPTY:
42};
43
44void foo(Collection *coll) {
45  RAII raii(^{});
46  for (Item *item in coll) {}
47}
48// CHECK-NEXT: [ B0 (live expressions at block exit) ]
49// CHECK-EMPTY:
50// CHECK-EMPTY:
51// CHECK-NEXT: [ B1 (live expressions at block exit) ]
52// CHECK-EMPTY:
53// CHECK-EMPTY:
54// CHECK-NEXT: [ B2 (live expressions at block exit) ]
55// CHECK-EMPTY:
56// CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' <LValueToRValue>
57// CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 'coll' 'Collection *'
58// CHECK-EMPTY:
59// CHECK-EMPTY:
60// CHECK-NEXT: [ B3 (live expressions at block exit) ]
61// CHECK-EMPTY:
62// CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' <LValueToRValue>
63// CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 'coll' 'Collection *'
64// CHECK-EMPTY:
65// CHECK-EMPTY:
66// CHECK-NEXT: [ B4 (live expressions at block exit) ]
67// CHECK-EMPTY:
68// CHECK-NEXT: ImplicitCastExpr {{.*}} 'Collection *' <LValueToRValue>
69// CHECK-NEXT: `-DeclRefExpr {{.*}} 'Collection *' lvalue ParmVar {{.*}} 'coll' 'Collection *'
70// CHECK-EMPTY:
71// CHECK-EMPTY:
72// CHECK-NEXT: [ B5 (live expressions at block exit) ]
73// CHECK-EMPTY:
74// CHECK-EMPTY:
75// CHECK-NEXT: [ B0 (live expressions at block exit) ]
76// CHECK-EMPTY:
77// CHECK-EMPTY:
78// CHECK-NEXT: [ B1 (live expressions at block exit) ]
79// CHECK-EMPTY:
80// CHECK-EMPTY:
81
82