1 // RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveExprs %s 2>&1\
7 int testThatDumperWorks(int x
, int y
, int z
) {
14 // [B4 (x)] ? [B2 (y)] : [B3 (z)]
18 // [B1] --> [B0 (EXIT)]
21 // CHECK: [ B0 (live expressions at block exit) ]
24 // CHECK: [ B1 (live expressions at block exit) ]
27 // CHECK: [ B2 (live expressions at block exit) ]
29 // CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
31 // CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
33 // CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
34 // CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
35 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
38 // CHECK: [ B3 (live expressions at block exit) ]
40 // CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
42 // CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
44 // CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
45 // CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
46 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
47 // CHECK: [ B4 (live expressions at block exit) ]
49 // CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
51 // CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
53 // CHECK-NEXT: ImplicitCastExpr {{.*}} <IntegralToBoolean>
54 // CHECK-NEXT: `-ImplicitCastExpr {{.*}} <LValueToRValue>
55 // CHECK-NEXT: `-DeclRefExpr {{.*}} 'x' 'int'
58 // CHECK: [ B5 (live expressions at block exit) ]
60 // CHECK-NEXT: DeclRefExpr {{.*}} 'y' 'int'
62 // CHECK-NEXT: DeclRefExpr {{.*}} 'z' 'int'
67 void testIfBranchExpression(bool flag
) {
68 // No expressions should be carried over from one block to another here.
75 // CHECK: [ B0 (live expressions at block exit) ]
78 // CHECK: [ B1 (live expressions at block exit) ]
81 // CHECK: [ B2 (live expressions at block exit) ]
84 // CHECK: [ B3 (live expressions at block exit) ]
87 // CHECK: [ B4 (live expressions at block exit) ]
90 // CHECK: [ B5 (live expressions at block exit) ]
95 void testWhileBodyExpression(bool flag
) {
96 // No expressions should be carried over from one block to another here.
103 // CHECK: [ B0 (live expressions at block exit) ]
106 // CHECK: [ B1 (live expressions at block exit) ]
109 // CHECK: [ B2 (live expressions at block exit) ]
112 // CHECK: [ B3 (live expressions at block exit) ]
115 // CHECK: [ B4 (live expressions at block exit) ]
118 // CHECK: [ B5 (live expressions at block exit) ]
123 void testDoWhileBodyExpression(bool flag
) {
124 // No expressions should be carried over from one block to another here.
132 // CHECK: [ B0 (live expressions at block exit) ]
135 // CHECK: [ B1 (live expressions at block exit) ]
138 // CHECK: [ B2 (live expressions at block exit) ]
141 // CHECK: [ B3 (live expressions at block exit) ]
144 // CHECK: [ B4 (live expressions at block exit) ]
147 // CHECK: [ B5 (live expressions at block exit) ]
152 void testForBodyExpression(bool flag
) {
153 // No expressions should be carried over from one block to another here.
160 // CHECK: [ B0 (live expressions at block exit) ]
163 // CHECK: [ B1 (live expressions at block exit) ]
166 // CHECK: [ B2 (live expressions at block exit) ]
169 // CHECK: [ B3 (live expressions at block exit) ]
172 // CHECK: [ B4 (live expressions at block exit) ]
175 // CHECK: [ B5 (live expressions at block exit) ]
179 void clang_analyzer_eval(bool);
181 void test_lambda_refcapture() {
183 [&](int &a
) { a
= 42; }(a
);
184 clang_analyzer_eval(a
== 42); // expected-warning{{TRUE}}
187 // CHECK: [ B0 (live expressions at block exit) ]
190 // CHECK-NEXT: [ B1 (live expressions at block exit) ]
193 // CHECK-NEXT: [ B2 (live expressions at block exit) ]