diff options
| author | Alexey Samsonov <vonosmas@gmail.com> | 2014-07-10 22:34:19 +0000 |
|---|---|---|
| committer | Alexey Samsonov <vonosmas@gmail.com> | 2014-07-10 22:34:19 +0000 |
| commit | 848560125db5a2d8924dfbfc19adb0234d080c13 (patch) | |
| tree | ae6017631bf4fdd1b1a842bcb4df9fa15156d674 /clang/test/CodeGen | |
| parent | f34b454219d0c6e0bc18904136d3b80bd6691be3 (diff) | |
| download | bcm5719-llvm-848560125db5a2d8924dfbfc19adb0234d080c13.tar.gz bcm5719-llvm-848560125db5a2d8924dfbfc19adb0234d080c13.zip | |
[UBSan] Introduce type-based blacklisting.
Teach UBSan vptr checker to ignore technically invalud down-casts on
blacklisted types.
Based on http://reviews.llvm.org/D4407 by Byoungyoung Lee!
llvm-svn: 212770
Diffstat (limited to 'clang/test/CodeGen')
| -rw-r--r-- | clang/test/CodeGen/ubsan-type-blacklist.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/test/CodeGen/ubsan-type-blacklist.cpp b/clang/test/CodeGen/ubsan-type-blacklist.cpp new file mode 100644 index 00000000000..7dc6fe159b5 --- /dev/null +++ b/clang/test/CodeGen/ubsan-type-blacklist.cpp @@ -0,0 +1,25 @@ +// Verify ubsan vptr does not check down-casts on blacklisted types. +// RUN: echo "type:_ZTI3Foo" > %t-type.blacklist +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=vptr -emit-llvm %s -o - | FileCheck %s --check-prefix=DEFAULT +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=vptr -fsanitize-blacklist=%t-type.blacklist -emit-llvm %s -o - | FileCheck %s --check-prefix=TYPE + +// REQUIRES: shell + +class Bar { +public: + virtual ~Bar() {} +}; +class Foo : public Bar {}; + +Bar bar; + +// DEFAULT: @_Z7checkmev +// TYPE: @_Z7checkmev +void checkme() { +// DEFAULT: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}} (%class.Bar* @bar to +// TYPE-NOT: @__ubsan_handle_dynamic_type_cache_miss + Foo* foo = static_cast<Foo*>(&bar); // down-casting +// DEFAULT: ret void +// TYPE: ret void + return; +} |

