diff options
Diffstat (limited to 'test/Analysis/out-of-bounds.c')
-rw-r--r-- | test/Analysis/out-of-bounds.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/test/Analysis/out-of-bounds.c b/test/Analysis/out-of-bounds.c index d89a23961903..ca1e0d05006a 100644 --- a/test/Analysis/out-of-bounds.c +++ b/test/Analysis/out-of-bounds.c @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s +// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2,debug.ExprInspection -verify %s + +void clang_analyzer_eval(int); // Tests doing an out-of-bounds access after the end of an array using: // - constant integer index @@ -128,22 +130,22 @@ void test2_multi_ok(int x) { buf[0][0] = 1; // no-warning } -// *** FIXME *** -// We don't get a warning here yet because our symbolic constraint solving -// doesn't handle: (symbol * constant) < constant void test3(int x) { int buf[100]; if (x < 0) - buf[x] = 1; + buf[x] = 1; // expected-warning{{Out of bound memory access}} } -// *** FIXME *** -// We don't get a warning here yet because our symbolic constraint solving -// doesn't handle: (symbol * constant) < constant void test4(int x) { int buf[100]; if (x > 99) - buf[x] = 1; + buf[x] = 1; // expected-warning{{Out of bound memory access}} +} + +void test_assume_after_access(unsigned long x) { + int buf[100]; + buf[x] = 1; + clang_analyzer_eval(x <= 99); // expected-warning{{TRUE}} } // Don't warn when indexing below the start of a symbolic region's whose @@ -166,3 +168,9 @@ void test_extern_void() { p[1] = 42; // no-warning } +void test_assume_after_access2(unsigned long x) { + char buf[100]; + buf[x] = 1; + clang_analyzer_eval(x <= 99); // expected-warning{{TRUE}} +} + |