1 // RUN: %clang_analyze_cc1 %s \
2 // RUN: -analyzer-checker=core,debug.ExprInspection \
3 // RUN: -analyzer-config eagerly-assume=false \
6 void clang_analyzer_eval(int);
7 void clang_analyzer_dump(int);
9 int test(int x
, int y
) {
11 clang_analyzer_dump(-x
); // expected-warning{{-reg_$0<int x>}}
12 clang_analyzer_dump(~x
); // expected-warning{{~reg_$0<int x>}}
14 clang_analyzer_dump(-z
); // expected-warning{{-((reg_$0<int x>) + (reg_$1<int y>))}}
15 clang_analyzer_dump(-(x
+ y
)); // expected-warning{{-((reg_$0<int x>) + (reg_$1<int y>))}}
16 clang_analyzer_dump(-x
+ y
); // expected-warning{{(-reg_$0<int x>) + (reg_$1<int y>)}}
19 clang_analyzer_eval(-x
== 0); // expected-warning{{TRUE}}
20 clang_analyzer_eval(-x
> 0); // expected-warning{{FALSE}}
21 clang_analyzer_eval(-x
< 0); // expected-warning{{FALSE}}
24 clang_analyzer_eval(~y
== 0); // expected-warning{{TRUE}}
25 clang_analyzer_eval(~y
> 0); // expected-warning{{FALSE}}
26 clang_analyzer_eval(~y
< 0); // expected-warning{{FALSE}}
32 void test_svalbuilder_simplification_add(int x
, int y
) {
35 clang_analyzer_eval(-(x
+ y
) == -3); // expected-warning{{TRUE}}
36 clang_analyzer_eval(-(y
+ x
) == -3); // expected-warning{{TRUE}}
39 void test_svalbuilder_simplification_mul(int x
, int y
) {
42 clang_analyzer_eval(-(x
* y
) == -3); // expected-warning{{TRUE}}
43 clang_analyzer_eval(-(y
* x
) == -3); // expected-warning{{TRUE}}
46 void test_svalbuilder_simplification_and(int x
, int y
) {
49 clang_analyzer_eval(-(x
& y
) == -3); // expected-warning{{TRUE}}
50 clang_analyzer_eval(-(y
& x
) == -3); // expected-warning{{TRUE}}
53 void test_svalbuilder_simplification_or(int x
, int y
) {
56 clang_analyzer_eval(-(x
| y
) == -3); // expected-warning{{TRUE}}
57 clang_analyzer_eval(-(y
| x
) == -3); // expected-warning{{TRUE}}
60 void test_svalbuilder_simplification_xor(int x
, int y
) {
63 clang_analyzer_eval(-(x
^ y
) == -3); // expected-warning{{TRUE}}
64 clang_analyzer_eval(-(y
^ x
) == -3); // expected-warning{{TRUE}}
67 int test_fp(int flag
) {
72 return value
; // no-warning