Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / Analysis / unary-sym-expr.c
blob7c4774f3cca82f1d0dc20aec8f6178e5559c44aa
1 // RUN: %clang_analyze_cc1 %s \
2 // RUN: -analyzer-checker=core,debug.ExprInspection \
3 // RUN: -analyzer-config eagerly-assume=false \
4 // RUN: -verify
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>}}
13 int z = x + y;
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>)}}
18 if (-x == 0) {
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}}
23 if (~y == 0) {
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}}
28 (void)(x);
29 return 42;
32 void test_svalbuilder_simplification(int x, int y) {
33 if (x + y != 3)
34 return;
35 clang_analyzer_eval(-(x + y) == -3); // expected-warning{{TRUE}}
36 // FIXME Commutativity is not supported yet.
37 clang_analyzer_eval(-(y + x) == -3); // expected-warning{{UNKNOWN}}
40 int test_fp(int flag) {
41 int value;
42 if (flag == 0)
43 value = 1;
44 if (-flag == 0)
45 return value; // no-warning
46 return 42;