xref: /llvm-project/clang/test/Analysis/symbol-simplification-reassume.cpp (revision 806329da07006b3b95b5164a2a7c8b3be0aac8de)
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 // In this test we check whether the solver's symbol simplification mechanism
8 // is capable of re-assuming simiplified symbols.
9 
10 void clang_analyzer_eval(bool);
11 void clang_analyzer_warnIfReached();
12 
test_reassume_false_range(int x,int y)13 void test_reassume_false_range(int x, int y) {
14   if (x + y != 0) // x + y == 0
15     return;
16   if (x != 1)     // x == 1
17     return;
18   clang_analyzer_eval(y == -1); // expected-warning{{TRUE}}
19 }
20 
test_reassume_true_range(int x,int y)21 void test_reassume_true_range(int x, int y) {
22   if (x + y != 1) // x + y == 1
23     return;
24   if (x != 1)     // x == 1
25     return;
26   clang_analyzer_eval(y == 0); // expected-warning{{TRUE}}
27 }
28 
test_reassume_inclusive_range(int x,int y)29 void test_reassume_inclusive_range(int x, int y) {
30   if (x + y < 0 || x + y > 1) // x + y: [0, 1]
31     return;
32   if (x != 1)                 // x == 1
33     return;
34                               // y: [-1, 0]
35   clang_analyzer_eval(y > 0); // expected-warning{{FALSE}}
36   clang_analyzer_eval(y < -1);// expected-warning{{FALSE}}
37 }
38