Debian Codegraph @

clang/test/Analysis/svalbuilder-simplify-in-evalbinop.cpp

raw
1 // RUN: %clang_analyze_cc1 %s \
2 // RUN: -analyzer-checker=core \
3 // RUN: -analyzer-checker=debug.ExprInspection \
4 // RUN: -analyzer-config eagerly-assume=false \
5 // RUN: -verify
6
7 // Here we test whether the SValBuilder is capable to simplify existing
8 // SVals based on a newly added constraints when evaluating a BinOp.
9
10 void clang_analyzer_eval(bool);
11
12 void test_evalBinOp_simplifies_lhs(int y) {
13 int x = y / 77;
14 if (y != 77)
15 return;
16
17 // Below `x` is the LHS being simplified.
18 clang_analyzer_eval(x == 1); // expected-warning{{TRUE}}
19 (void)(x * y);
20 }
21
22 void test_evalBinOp_simplifies_rhs(int y) {
23 int x = y / 77;
24 if (y != 77)
25 return;
26
27 // Below `x` is the RHS being simplified.
28 clang_analyzer_eval(1 == x); // expected-warning{{TRUE}}
29 (void)(x * y);
30 }