summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/cxx-crashes.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-06-16 01:28:00 +0000
committerJordan Rose <jordan_rose@apple.com>2012-06-16 01:28:00 +0000
commite42412be3948446c0c9db75a83ddcc1f1ab3bc6a (patch)
treeec5822fc109223f381d334fea7f0f55acab01369 /clang/test/Analysis/cxx-crashes.cpp
parent144a2ac89d0eb4938ea7ac388c9e70ff68977eb6 (diff)
downloadbcm5719-llvm-e42412be3948446c0c9db75a83ddcc1f1ab3bc6a.tar.gz
bcm5719-llvm-e42412be3948446c0c9db75a83ddcc1f1ab3bc6a.zip
[analyzer] Return an UnknownVal when we try to get the binding for a VLA.
This happens in C++ mode right at the declaration of a struct VLA; MallocChecker sees a bind and tries to get see if it's an escaping bind. It's likely that our handling of this is still incomplete, but it fixes a crash on valid without disturbing anything else for now. llvm-svn: 158587
Diffstat (limited to 'clang/test/Analysis/cxx-crashes.cpp')
-rw-r--r--clang/test/Analysis/cxx-crashes.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/test/Analysis/cxx-crashes.cpp b/clang/test/Analysis/cxx-crashes.cpp
index 17fc74d06f4..1ee81a20235 100644
--- a/clang/test/Analysis/cxx-crashes.cpp
+++ b/clang/test/Analysis/cxx-crashes.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(bool);
int f1(char *dst) {
char *p = dst + 4;
@@ -54,3 +56,17 @@ struct C {
void C::f() { }
}
+
+
+void vla(int n) {
+ int nums[n];
+ nums[0] = 1;
+ clang_analyzer_eval(nums[0] == 1); // expected-warning{{TRUE}}
+
+ // This used to fail with MallocChecker on, and /only/ in C++ mode.
+ // This struct is POD, though, so it should be fine to put it in a VLA.
+ struct { int x; } structs[n];
+ structs[0].x = 1;
+ clang_analyzer_eval(structs[0].x == 1); // expected-warning{{TRUE}}
+}
+
OpenPOWER on IntegriCloud