[AMDGPU][AsmParser][NFC] Get rid of custom default operand handlers.
[llvm-project.git] / clang / test / Analysis / lambdas-generalized-capture.cpp
blobfeaf55d6c84eee5071bb1ffc04f6f26c22a16bdd
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() {
6 int v = 7;
7 auto lambda = [x=v]() {
8 return x;
9 };
11 int result = lambda();
12 clang_analyzer_eval(result == 7); // expected-warning {{TRUE}}
15 void sideEffectsInGeneralizedCapture() {
16 int v = 7;
17 auto lambda = [x=v++]() {
18 return x;
20 clang_analyzer_eval(v == 8); // expected-warning {{TRUE}}
22 int r1 = lambda();
23 int r2 = lambda();
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}}
29 int addOne(int p) {
30 return p + 1;
33 void inliningInGeneralizedCapture() {
34 int v = 7;
35 auto lambda = [x=addOne(v)]() {
36 return x;
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)]() {
45 return x;
48 int result = lambda();
49 clang_analyzer_eval(result == 1); // expected-warning {{FALSE}} expected-warning {{TRUE}}