1 // RUN: %clang_analyze_cc1 -std=c++14 -analyzer-checker=core,deadcode,debug.ExprInspection -verify %s
3 int clang_analyzer_eval(int);
5 void generalizedCapture() {
7 auto lambda
= [x
=v
]() {
11 int result
= lambda();
12 clang_analyzer_eval(result
== 7); // expected-warning {{TRUE}}
15 void sideEffectsInGeneralizedCapture() {
17 auto lambda
= [x
=v
++]() {
20 clang_analyzer_eval(v
== 8); // expected-warning {{TRUE}}
24 clang_analyzer_eval(r1
== 7); // expected-warning {{TRUE}}
25 clang_analyzer_eval(r2
== 7); // expected-warning {{TRUE}}
26 clang_analyzer_eval(v
== 8); // expected-warning {{TRUE}}
33 void inliningInGeneralizedCapture() {
35 auto lambda
= [x
=addOne(v
)]() {
39 int result
= lambda();
40 clang_analyzer_eval(result
== 8); // expected-warning {{TRUE}}
43 void caseSplitInGeneralizedCapture(bool p
) {
44 auto lambda
= [x
=(p
? 1 : 2)]() {
48 int result
= lambda();
49 clang_analyzer_eval(result
== 1); // expected-warning {{FALSE}} expected-warning {{TRUE}}