summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/dtor.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2019-08-20 21:41:17 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2019-08-20 21:41:17 +0000
commit8eb7a74b7808584e017673d5046db867fb873e60 (patch)
treed9979d2871961e1ee936c074dc4e68c9084b31fa /clang/test/Analysis/dtor.cpp
parentd3971fe97b64785c079d64bf4c8c3e2b5e1f85a1 (diff)
downloadbcm5719-llvm-8eb7a74b7808584e017673d5046db867fb873e60.tar.gz
bcm5719-llvm-8eb7a74b7808584e017673d5046db867fb873e60.zip
[analyzer] Fix a crash when destroying a non-region.
Add defensive check that prevents a crash when we try to evaluate a destructor whose this-value is a concrete integer that isn't a null. Differential Revision: https://reviews.llvm.org/D65349 llvm-svn: 369450
Diffstat (limited to 'clang/test/Analysis/dtor.cpp')
-rw-r--r--clang/test/Analysis/dtor.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/Analysis/dtor.cpp b/clang/test/Analysis/dtor.cpp
index d843f03aada..1c625178154 100644
--- a/clang/test/Analysis/dtor.cpp
+++ b/clang/test/Analysis/dtor.cpp
@@ -540,3 +540,33 @@ void f() {
clang_analyzer_eval(__alignof(NonTrivial) > 0); // expected-warning{{TRUE}}
}
}
+
+namespace dtor_over_loc_concrete_int {
+struct A {
+ ~A() {}
+};
+
+struct B {
+ A a;
+ ~B() {}
+};
+
+struct C : A {
+ ~C() {}
+};
+
+void testB() {
+ B *b = (B *)-1;
+ b->~B(); // no-crash
+}
+
+void testC() {
+ C *c = (C *)-1;
+ c->~C(); // no-crash
+}
+
+void testAutoDtor() {
+ const A &a = *(A *)-1;
+ // no-crash
+}
+} // namespace dtor_over_loc_concrete_int
OpenPOWER on IntegriCloud