Vlad Tsyrklevich | 3f3aad2 | 2017-08-04 21:21:00 +0000 | [diff] [blame] | 1 | // STL allocators should not have unrelated-cast tests applied |
| 2 | // RUN: %clang_cc1 -flto -triple x86_64-unknown-linux -fvisibility hidden -fsanitize=cfi-unrelated-cast -emit-llvm -o - %s | FileCheck %s |
| 3 | |
| 4 | #include <stddef.h> |
| 5 | |
| 6 | template<class T> |
| 7 | class myalloc { |
| 8 | public: |
| 9 | // CHECK: define{{.*}}allocateE{{.}} |
| 10 | // CHECK-NOT: llvm.type.test |
| 11 | T *allocate(size_t sz) { |
| 12 | return (T*)::operator new(sz); |
| 13 | } |
| 14 | |
| 15 | // CHECK: define{{.*}}allocateE{{.}}PKv |
| 16 | // CHECK-NOT: llvm.type.test |
| 17 | T *allocate(size_t sz, const void *ptr) { |
| 18 | return (T*)::operator new(sz); |
| 19 | } |
| 20 | |
| 21 | // CHECK: define{{.*}}differentName |
| 22 | // CHECK: llvm.type.test |
| 23 | T *differentName(size_t sz, const void *ptr) { |
| 24 | return (T*)::operator new(sz); |
| 25 | } |
| 26 | }; |
| 27 | |
| 28 | class C1 { |
| 29 | virtual void f() {} |
| 30 | }; |
| 31 | |
| 32 | C1 *f1() { |
| 33 | myalloc<C1> allocator; |
| 34 | (void)allocator.allocate(16); |
| 35 | (void)allocator.allocate(16, 0); |
| 36 | (void)allocator.differentName(16, 0); |
| 37 | } |