xref: /llvm-project/clang/test/Analysis/svalbuilder-simplify-intsym.cpp (revision ffc32efd1cd6a34659e2c559e9ba6ee923b1637a)
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 // IntSym expressions based on a newly added constraint on the sub-expression.
9 
10 void clang_analyzer_eval(bool);
11 
test_SValBuilder_simplifies_IntSym(int x,int y)12 void test_SValBuilder_simplifies_IntSym(int x, int y) {
13   // Most IntSym BinOps are transformed to SymInt in SimpleSValBuilder.
14   // Division is one exception.
15   x = 77 / y;
16   if (y != 1)
17     return;
18   clang_analyzer_eval(x == 77); // expected-warning{{TRUE}}
19   (void)(x * y);
20 }
21