summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/outofbound.c
diff options
context:
space:
mode:
authorJordy Rose <jediknil@belkadan.com>2010-08-16 01:15:17 +0000
committerJordy Rose <jediknil@belkadan.com>2010-08-16 01:15:17 +0000
commitdf28e8ec4145fbe407f09dc2458d42cd9f12bd99 (patch)
treee642a5f884f581a38c4de3ff6b190307a83bac63 /clang/test/Analysis/outofbound.c
parentcbc55d9dc0b36a49ba749cf69c38223785ffa01e (diff)
downloadbcm5719-llvm-df28e8ec4145fbe407f09dc2458d42cd9f12bd99.tar.gz
bcm5719-llvm-df28e8ec4145fbe407f09dc2458d42cd9f12bd99.zip
- 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
Diffstat (limited to 'clang/test/Analysis/outofbound.c')
-rw-r--r--clang/test/Analysis/outofbound.c16
1 files changed, 16 insertions, 0 deletions
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;
+}
OpenPOWER on IntegriCloud