diff options
| author | Stephan Bergmann <sbergman@redhat.com> | 2017-12-28 12:45:41 +0000 |
|---|---|---|
| committer | Stephan Bergmann <sbergman@redhat.com> | 2017-12-28 12:45:41 +0000 |
| commit | d71ad177eb186eee445c3843699c53ad4619240e (patch) | |
| tree | f93b3981b3f51fe2394acf18d615f59434023219 /clang/test/CodeGenCXX/ubsan-vtable-checks.cpp | |
| parent | 703478ae6e529de9ec346f79961d980c604c299e (diff) | |
| download | bcm5719-llvm-d71ad177eb186eee445c3843699c53ad4619240e.tar.gz bcm5719-llvm-d71ad177eb186eee445c3843699c53ad4619240e.zip | |
-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
llvm-svn: 321519
Diffstat (limited to 'clang/test/CodeGenCXX/ubsan-vtable-checks.cpp')
| -rw-r--r-- | clang/test/CodeGenCXX/ubsan-vtable-checks.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp b/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp index 5e17913a2c8..090707c29d7 100644 --- a/clang/test/CodeGenCXX/ubsan-vtable-checks.cpp +++ b/clang/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); +} |

