|
1 | 1 | // RUN: %clang_analyze_cc1 -std=c++11 -Wno-array-bounds -verify %s \ |
| 2 | +// RUN: -triple=x86_64-unknown-linux-gnu \ |
2 | 3 | // RUN: -analyzer-checker=unix,core,security.ArrayBound,debug.ExprInspection |
3 | 4 |
|
4 | 5 | void clang_analyzer_eval(bool); |
| 6 | +void clang_analyzer_value(int); |
5 | 7 |
|
6 | 8 | // Tests doing an out-of-bounds access after the end of an array using: |
7 | 9 | // - constant integer index |
@@ -200,41 +202,34 @@ void using_many_assume_attr(int yx) { |
200 | 202 | arrOf10[yx] = 406; // expected-warning{{Out of bound access to memory}} |
201 | 203 | } |
202 | 204 |
|
203 | | - |
204 | | -int using_builtin_assume_has_no_sideeffects(int y) { |
205 | | - // We should not apply sideeffects of the argument of [[assume(...)]]. |
206 | | - // "y" should not get incremented; |
207 | | - __builtin_assume(++y == 43); // expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
208 | | - clang_analyzer_eval(y == 42); // expected-warning {{FALSE}} |
209 | | - return y; |
210 | | -} |
211 | | - |
212 | | - |
213 | | - |
214 | 205 | int using_assume_attr_has_no_sideeffects(int y) { |
| 206 | + int orig_y = y; |
| 207 | + clang_analyzer_value(y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
| 208 | + clang_analyzer_value(orig_y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
215 | 209 |
|
216 | 210 | // We should not apply sideeffects of the argument of [[assume(...)]]. |
217 | 211 | // "y" should not get incremented; |
218 | 212 | [[assume(++y == 43)]]; // expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
219 | 213 |
|
220 | | - clang_analyzer_eval(y == 42); // expected-warning {{TRUE}} expected-warning {{FALSE}} FIXME: This should be only TRUE. |
221 | | - |
222 | | - clang_analyzer_eval(y == 43); // expected-warning {{FALSE}} expected-warning {{TRUE}} FIXME: This should be only FALSE. |
| 214 | + clang_analyzer_value(y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
| 215 | + clang_analyzer_value(orig_y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
| 216 | + clang_analyzer_eval(y == orig_y); // expected-warning {{TRUE}} Good. |
223 | 217 |
|
224 | 218 | return y; |
225 | 219 | } |
226 | 220 |
|
| 221 | +int using_builtin_assume_has_no_sideeffects(int y) { |
| 222 | + int orig_y = y; |
| 223 | + clang_analyzer_value(y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
| 224 | + clang_analyzer_value(orig_y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
227 | 225 |
|
228 | | -int using_builtinassume_has_no_sideeffects(int u) { |
229 | 226 | // We should not apply sideeffects of the argument of __builtin_assume(...) |
230 | 227 | // "u" should not get incremented; |
231 | | - __builtin_assume(++u == 43); // expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
| 228 | + __builtin_assume(++y == 43); // expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
232 | 229 |
|
233 | | - // FIXME: evaluate this to true |
234 | | - clang_analyzer_eval(u == 42); // expected-warning {{FALSE}} current behavior |
235 | | - |
236 | | - // FIXME: evaluate this to false |
237 | | - clang_analyzer_eval(u == 43); // expected-warning {{TRUE}} current behavior |
| 230 | + clang_analyzer_value(y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
| 231 | + clang_analyzer_value(orig_y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
| 232 | + clang_analyzer_eval(y == orig_y); // expected-warning {{TRUE}} Good. |
238 | 233 |
|
239 | | - return u; |
| 234 | + return y; |
240 | 235 | } |
0 commit comments