summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/dtor.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-12-12 19:13:44 +0000
committerJordan Rose <jordan_rose@apple.com>2012-12-12 19:13:44 +0000
commit4cfdbff3c74f797eb837b39f976e229215f40973 (patch)
tree29c7d03fbe3d6f09701cf8757db6f2fa45e26950 /clang/test/Analysis/dtor.cpp
parenta87ecb43ab4c88d53990be34e6efbd41f3dd43a7 (diff)
downloadbcm5719-llvm-4cfdbff3c74f797eb837b39f976e229215f40973.tar.gz
bcm5719-llvm-4cfdbff3c74f797eb837b39f976e229215f40973.zip
[analyzer] Don't crash running destructors for multidimensional arrays.
We don't handle array destructors correctly yet, but we now apply the same hack (explicitly destroy the first element, implicitly invalidate the rest) for multidimensional arrays that we already use for linear arrays. <rdar://problem/12858542> llvm-svn: 170000
Diffstat (limited to 'clang/test/Analysis/dtor.cpp')
-rw-r--r--clang/test/Analysis/dtor.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/test/Analysis/dtor.cpp b/clang/test/Analysis/dtor.cpp
index f46194599d4..40407ea5b63 100644
--- a/clang/test/Analysis/dtor.cpp
+++ b/clang/test/Analysis/dtor.cpp
@@ -301,3 +301,30 @@ namespace ExplicitDestructorCall {
obj->VirtualDtor::~VirtualDtor();
}
}
+
+
+namespace MultidimensionalArrays {
+ void testArrayInvalidation() {
+ int i = 42;
+ int j = 42;
+
+ {
+ IntWrapper arr[2][2];
+
+ // There should be no undefined value warnings here.
+ // Eventually these should be TRUE as well, but right now
+ // we can't handle array constructors.
+ clang_analyzer_eval(arr[0][0].x == 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(arr[1][1].x == 0); // expected-warning{{UNKNOWN}}
+
+ arr[0][0].x = &i;
+ arr[1][1].x = &j;
+ clang_analyzer_eval(*arr[0][0].x == 42); // expected-warning{{TRUE}}
+ clang_analyzer_eval(*arr[1][1].x == 42); // expected-warning{{TRUE}}
+ }
+
+ // The destructors should have invalidated i and j.
+ clang_analyzer_eval(i == 42); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(j == 42); // expected-warning{{UNKNOWN}}
+ }
+}
OpenPOWER on IntegriCloud