From 55e6d896ad333f07bb3b1ba487df214fc268a4ab Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Thu, 28 Dec 2017 21:23:03 +0000 Subject: Vendor import of clang trunk r321530: https://llvm.org/svn/llvm-project/cfe/trunk@321530 --- test/CodeGenCXX/ubsan-vtable-checks.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test/CodeGenCXX') diff --git a/test/CodeGenCXX/ubsan-vtable-checks.cpp b/test/CodeGenCXX/ubsan-vtable-checks.cpp index 5e17913a2c89a..090707c29d746 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(t); +} -- cgit v1.2.3