|
1 | | -// RUN: %clang_analyze_cc1 -std=c++11 -Wno-array-bounds -verify %s \ |
2 | | -// RUN: -triple=x86_64-unknown-linux-gnu \ |
3 | | -// RUN: -analyzer-checker=unix,core,security.ArrayBound,debug.ExprInspection |
4 | | - |
5 | | -void clang_analyzer_eval(bool); |
6 | | -void clang_analyzer_value(int); |
7 | | -void clang_analyzer_dump(int); |
| 1 | +// RUN: %clang_analyze_cc1 -std=c++11 -Wno-array-bounds -analyzer-checker=unix,core,security.ArrayBound -verify %s |
8 | 2 |
|
9 | 3 | // Tests doing an out-of-bounds access after the end of an array using: |
10 | 4 | // - constant integer index |
@@ -186,59 +180,3 @@ int test_reference_that_might_be_after_the_end(int idx) { |
186 | 180 | return ref; |
187 | 181 | } |
188 | 182 |
|
189 | | -// From: https://github.com/llvm/llvm-project/issues/100762 |
190 | | -extern int arrOf10[10]; |
191 | | -void using_builtin(int x) { |
192 | | - __builtin_assume(x > 101); // CallExpr |
193 | | - arrOf10[x] = 404; // expected-warning {{Out of bound access to memory}} |
194 | | -} |
195 | | - |
196 | | -void using_assume_attr(int ax) { |
197 | | - [[assume(ax > 100)]]; // NullStmt with an "assume" attribute. |
198 | | - arrOf10[ax] = 405; // expected-warning {{Out of bound access to memory}} |
199 | | -} |
200 | | - |
201 | | -void using_many_assume_attr(int yx) { |
202 | | - [[assume(yx > 104), assume(yx > 200), assume(yx < 300)]]; // NullStmt with an attribute |
203 | | - arrOf10[yx] = 406; // expected-warning{{Out of bound access to memory}} |
204 | | -} |
205 | | - |
206 | | -int using_assume_attr_has_no_sideeffects(int y) { |
207 | | - int orig_y = y; |
208 | | - clang_analyzer_value(y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
209 | | - clang_analyzer_value(orig_y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
210 | | - clang_analyzer_dump(y); // expected-warning-re {{{{^}}reg_${{[0-9]+}}<int y> [debug.ExprInspection]{{$}}}} |
211 | | - clang_analyzer_dump(orig_y); // expected-warning-re {{{{^}}reg_${{[0-9]+}}<int y> [debug.ExprInspection]{{$}}}} |
212 | | - |
213 | | - // We should not apply sideeffects of the argument of [[assume(...)]]. |
214 | | - // "y" should not get incremented; |
215 | | - [[assume(++y == 43)]]; // expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
216 | | - |
217 | | - clang_analyzer_dump(y); // expected-warning-re {{{{^}}reg_${{[0-9]+}}<int y> [debug.ExprInspection]{{$}}}} |
218 | | - clang_analyzer_dump(orig_y); // expected-warning-re {{{{^}}reg_${{[0-9]+}}<int y> [debug.ExprInspection]{{$}}}} |
219 | | - clang_analyzer_value(y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
220 | | - clang_analyzer_value(orig_y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
221 | | - clang_analyzer_eval(y == orig_y); // expected-warning {{TRUE}} Good. |
222 | | - |
223 | | - return y; |
224 | | -} |
225 | | - |
226 | | -int using_builtin_assume_has_no_sideeffects(int y) { |
227 | | - int orig_y = y; |
228 | | - clang_analyzer_value(y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
229 | | - clang_analyzer_value(orig_y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
230 | | - clang_analyzer_dump(y); // expected-warning-re {{{{^}}reg_${{[0-9]+}}<int y> [debug.ExprInspection]{{$}}}} |
231 | | - clang_analyzer_dump(orig_y); // expected-warning-re {{{{^}}reg_${{[0-9]+}}<int y> [debug.ExprInspection]{{$}}}} |
232 | | - |
233 | | - // We should not apply sideeffects of the argument of __builtin_assume(...) |
234 | | - // "u" should not get incremented; |
235 | | - __builtin_assume(++y == 43); // expected-warning {{assumption is ignored because it contains (potential) side-effects}} |
236 | | - |
237 | | - clang_analyzer_dump(y); // expected-warning-re {{{{^}}reg_${{[0-9]+}}<int y> [debug.ExprInspection]{{$}}}} |
238 | | - clang_analyzer_dump(orig_y); // expected-warning-re {{{{^}}reg_${{[0-9]+}}<int y> [debug.ExprInspection]{{$}}}} |
239 | | - clang_analyzer_value(y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
240 | | - clang_analyzer_value(orig_y); // expected-warning {{32s:{ [-2147483648, 2147483647] }}} |
241 | | - clang_analyzer_eval(y == orig_y); // expected-warning {{TRUE}} Good. |
242 | | - |
243 | | - return y; |
244 | | -} |
0 commit comments