From bab175ec4b075c8076ba14c762900392533f6ee4 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Mon, 2 Jan 2017 19:18:08 +0000 Subject: Vendor import of clang trunk r290819: https://llvm.org/svn/llvm-project/cfe/trunk@290819 --- test/Analysis/out-of-bounds.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'test/Analysis/out-of-bounds.c') 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}} +} + -- cgit v1.2.3