From df28e8ec4145fbe407f09dc2458d42cd9f12bd99 Mon Sep 17 00:00:00 2001 From: Jordy Rose Date: Mon, 16 Aug 2010 01:15:17 +0000 Subject: - Allow making ElementRegions with complex offsets (expressions or symbols) for the purpose of bounds-checking. - Rewrite GRState::AssumeInBound to actually do that checking, and to use the normal constraint path. - Remove ConstraintManager::AssumeInBound. - Teach RegionStore and FlatStore to ignore those regions for now. llvm-svn: 111116 --- clang/test/Analysis/outofbound.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'clang/test/Analysis') diff --git a/clang/test/Analysis/outofbound.c b/clang/test/Analysis/outofbound.c index 529f0e77b26..ed51dc6ac06 100644 --- a/clang/test/Analysis/outofbound.c +++ b/clang/test/Analysis/outofbound.c @@ -79,3 +79,19 @@ void alloca_region(int a) { x[5] = 5; // expected-warning{{out-of-bound}} } } + +int symbolic_index(int a) { + int x[2] = {1, 2}; + if (a == 2) { + return x[a]; // expected-warning{{out-of-bound}} + } + return 0; +} + +int symbolic_index2(int a) { + int x[2] = {1, 2}; + if (a < 0) { + return x[a]; // expected-warning{{out-of-bound}} + } + return 0; +} -- cgit v1.2.3