[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Analysis / constraint_manager_conditions.cpp
blobc0eb73ef24705de97a9a9edc06f5df019aa7d9b3
1 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection -verify %s
3 void clang_analyzer_eval(int);
5 void comparison_lt(int x, int y) {
6 if (x < y) {
7 clang_analyzer_eval(x < y); // expected-warning{{TRUE}}
8 clang_analyzer_eval(y > x); // expected-warning{{TRUE}}
9 clang_analyzer_eval(x > y); // expected-warning{{FALSE}}
10 clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
11 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
12 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
13 clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
14 clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
15 clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
16 clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
17 clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
18 clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
19 } else {
20 clang_analyzer_eval(x < y); // expected-warning{{FALSE}}
21 clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
22 clang_analyzer_eval(x > y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
23 clang_analyzer_eval(y < x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
24 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
25 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
26 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
27 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
28 clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
29 clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
30 clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
31 clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
35 void comparison_gt(int x, int y) {
36 if (x > y) {
37 clang_analyzer_eval(x < y); // expected-warning{{FALSE}}
38 clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
39 clang_analyzer_eval(x > y); // expected-warning{{TRUE}}
40 clang_analyzer_eval(y < x); // expected-warning{{TRUE}}
41 clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
42 clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
43 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
44 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
45 clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
46 clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
47 clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
48 clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
49 } else {
50 clang_analyzer_eval(x < y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
51 clang_analyzer_eval(y > x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
52 clang_analyzer_eval(x > y); // expected-warning{{FALSE}}
53 clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
54 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
55 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
56 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
57 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
58 clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
59 clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
60 clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
61 clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
65 void comparison_le(int x, int y) {
66 if (x <= y) {
67 clang_analyzer_eval(x < y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
68 clang_analyzer_eval(y > x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
69 clang_analyzer_eval(x > y); // expected-warning{{FALSE}}
70 clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
71 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
72 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
73 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
74 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
75 clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
76 clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
77 clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
78 clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
79 } else {
80 clang_analyzer_eval(x < y); // expected-warning{{FALSE}}
81 clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
82 clang_analyzer_eval(x > y); // expected-warning{{TRUE}}
83 clang_analyzer_eval(y < x); // expected-warning{{TRUE}}
84 clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
85 clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
86 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
87 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
88 clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
89 clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
90 clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
91 clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
95 void comparison_ge(int x, int y) {
96 if (x >= y) {
97 clang_analyzer_eval(x < y); // expected-warning{{FALSE}}
98 clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
99 clang_analyzer_eval(x > y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
100 clang_analyzer_eval(y < x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
101 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
102 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
103 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
104 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
105 clang_analyzer_eval(x == y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
106 clang_analyzer_eval(y == x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
107 clang_analyzer_eval(x != y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
108 clang_analyzer_eval(y != x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
109 } else {
110 clang_analyzer_eval(x < y); // expected-warning{{TRUE}}
111 clang_analyzer_eval(y > x); // expected-warning{{TRUE}}
112 clang_analyzer_eval(x > y); // expected-warning{{FALSE}}
113 clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
114 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
115 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
116 clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
117 clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
118 clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
119 clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
120 clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
121 clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
125 void comparison_eq(int x, int y) {
126 if (x == y) {
127 clang_analyzer_eval(x < y); // expected-warning{{FALSE}}
128 clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
129 clang_analyzer_eval(x > y); // expected-warning{{FALSE}}
130 clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
131 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
132 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
133 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
134 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
135 clang_analyzer_eval(x == y); // expected-warning{{TRUE}}
136 clang_analyzer_eval(y == x); // expected-warning{{TRUE}}
137 clang_analyzer_eval(x != y); // expected-warning{{FALSE}}
138 clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
139 } else {
140 clang_analyzer_eval(x < y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
141 clang_analyzer_eval(y > x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
142 clang_analyzer_eval(x > y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
143 clang_analyzer_eval(y < x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
144 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
145 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
146 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
147 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
148 clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
149 clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
150 clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
151 clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
155 void comparison_ne(int x, int y) {
156 if (x != y) {
157 clang_analyzer_eval(x < y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
158 clang_analyzer_eval(y > x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
159 clang_analyzer_eval(x > y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
160 clang_analyzer_eval(y < x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
161 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
162 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
163 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}} expected-warning{{FALSE}}
164 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}} expected-warning{{FALSE}}
165 clang_analyzer_eval(x == y); // expected-warning{{FALSE}}
166 clang_analyzer_eval(y == x); // expected-warning{{FALSE}}
167 clang_analyzer_eval(x != y); // expected-warning{{TRUE}}
168 clang_analyzer_eval(y != x); // expected-warning{{TRUE}}
169 } else {
170 clang_analyzer_eval(x < y); // expected-warning{{FALSE}}
171 clang_analyzer_eval(y > x); // expected-warning{{FALSE}}
172 clang_analyzer_eval(x > y); // expected-warning{{FALSE}}
173 clang_analyzer_eval(y < x); // expected-warning{{FALSE}}
174 clang_analyzer_eval(x <= y); // expected-warning{{TRUE}}
175 clang_analyzer_eval(y >= x); // expected-warning{{TRUE}}
176 clang_analyzer_eval(x >= y); // expected-warning{{TRUE}}
177 clang_analyzer_eval(y <= x); // expected-warning{{TRUE}}
178 clang_analyzer_eval(x == y); // expected-warning{{TRUE}}
179 clang_analyzer_eval(y == x); // expected-warning{{TRUE}}
180 clang_analyzer_eval(x != y); // expected-warning{{FALSE}}
181 clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
185 void comparison_le_ne(int x, int y) {
186 if (x <= y)
187 if (x != y) {
188 clang_analyzer_eval(x < y); // expected-warning{{TRUE}}
189 clang_analyzer_eval(y > x); // expected-warning{{TRUE}}
190 clang_analyzer_eval(x >= y); // expected-warning{{FALSE}}
191 clang_analyzer_eval(y <= x); // expected-warning{{FALSE}}
195 void comparison_ge_ne(int x, int y) {
196 if (x >= y)
197 if (x != y) {
198 clang_analyzer_eval(x > y); // expected-warning{{TRUE}}
199 clang_analyzer_eval(y < x); // expected-warning{{TRUE}}
200 clang_analyzer_eval(x <= y); // expected-warning{{FALSE}}
201 clang_analyzer_eval(y >= x); // expected-warning{{FALSE}}
205 void comparison_le_ge(int x, int y) {
206 if (x <= y)
207 if (x >= y) {
208 clang_analyzer_eval(x == y); // expected-warning{{TRUE}}
209 clang_analyzer_eval(y == x); // expected-warning{{TRUE}}
210 clang_analyzer_eval(x != y); // expected-warning{{FALSE}}
211 clang_analyzer_eval(y != x); // expected-warning{{FALSE}}
215 // Test the logic of reaching the `Unknonw` tristate in CmpOpTable.
216 void cmp_op_table_unknownX2(int x, int y, int z) {
217 if (x >= y) {
218 // x >= y [1, 1]
219 if (x + z < y)
220 return;
221 // x + z < y [0, 0]
222 if (z != 0)
223 return;
224 // x < y [0, 0]
225 clang_analyzer_eval(x > y); // expected-warning{{TRUE}} expected-warning{{FALSE}}