diff options
author | Vlad Tsyrklevich <vlad@tsyrklevich.net> | 2017-08-04 21:21:00 +0000 |
---|---|---|
committer | Vlad Tsyrklevich <vlad@tsyrklevich.net> | 2017-08-04 21:21:00 +0000 |
commit | 09806664665f289bf8eb2512fa445ab68a0b27c7 (patch) | |
tree | fb24487161ad0a70f07e5fe95110fad3a8c26eea /test/CodeGen/cfi-unrelated-cast.cpp | |
parent | 04faf0908936010c690ae7f866a92dce915823b9 (diff) | |
download | clang-09806664665f289bf8eb2512fa445ab68a0b27c7.tar.gz |
Reland "CFI: blacklist STL allocate() from unrelated-casts"
Reland r310097 with a fix for a debug assertion in NamedDecl.getName()
Differential Revision: https://reviews.llvm.org/D36294
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310132 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/cfi-unrelated-cast.cpp')
-rw-r--r-- | test/CodeGen/cfi-unrelated-cast.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/CodeGen/cfi-unrelated-cast.cpp b/test/CodeGen/cfi-unrelated-cast.cpp new file mode 100644 index 0000000000..d01cdf00b7 --- /dev/null +++ b/test/CodeGen/cfi-unrelated-cast.cpp @@ -0,0 +1,37 @@ +// STL allocators should not have unrelated-cast tests applied +// RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-unrelated-cast -emit-llvm -o - %s | FileCheck %s + +#include <stddef.h> + +template<class T> +class myalloc { + public: + // CHECK: define{{.*}}allocateE{{.}} + // CHECK-NOT: llvm.type.test + T *allocate(size_t sz) { + return (T*)::operator new(sz); + } + + // CHECK: define{{.*}}allocateE{{.}}PKv + // CHECK-NOT: llvm.type.test + T *allocate(size_t sz, const void *ptr) { + return (T*)::operator new(sz); + } + + // CHECK: define{{.*}}differentName + // CHECK: llvm.type.test + T *differentName(size_t sz, const void *ptr) { + return (T*)::operator new(sz); + } +}; + +class C1 { + virtual void f() {} +}; + +C1 *f1() { + myalloc<C1> allocator; + (void)allocator.allocate(16); + (void)allocator.allocate(16, 0); + (void)allocator.differentName(16, 0); +} |