summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2017-12-28 12:45:41 +0000
committerStephan Bergmann <sbergman@redhat.com>2017-12-28 12:45:41 +0000
commitbd4a5c665b0983aaed3e6c0a1f2e02b89808691e (patch)
tree04ea6ca4de922cc26248c9e721b5f15da15774c8 /test
parent857a79ea1b59c13a72feb827e8293a35e8792f77 (diff)
-fsanitize=vptr warnings on bad static types in dynamic_cast and typeid
...when such an operation is done on an object during con-/destruction. This is the cfe part of a patch covering both cfe and compiler-rt. Differential Revision: https://reviews.llvm.org/D40295 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321519 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGenCXX/ubsan-vtable-checks.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/CodeGenCXX/ubsan-vtable-checks.cpp b/test/CodeGenCXX/ubsan-vtable-checks.cpp
index 5e17913a2c..090707c29d 100644
--- a/test/CodeGenCXX/ubsan-vtable-checks.cpp
+++ b/test/CodeGenCXX/ubsan-vtable-checks.cpp
@@ -38,3 +38,15 @@ void delete_it(T *t) {
// CHECK-VPTR: load {{.*}} (%struct.T*{{.*}})**, {{.*}} (%struct.T*{{.*}})***
delete t;
}
+
+// ITANIUM: define %struct.U* @_Z7dyncastP1T
+// MSABI: define %struct.U* @"\01?dyncast
+U* dyncast(T *t) {
+ // First, we check that dynamic_cast is not called before a type check.
+ // CHECK-VPTR-NOT: call i8* @__{{dynamic_cast|RTDynamicCast}}
+ // CHECK-VPTR: br i1 {{.*}} label %{{.*}}
+ // CHECK-VPTR: call void @__ubsan_handle_dynamic_type_cache_miss_abort
+ // Second, we check that dynamic_cast is actually called once the type check is done.
+ // CHECK-VPTR: call i8* @__{{dynamic_cast|RTDynamicCast}}
+ return dynamic_cast<U*>(t);
+}