xref: /llvm-project/clang/test/CodeGenCXX/ptrauth-thunks.cpp (revision a1d77caaabbb5279b734c061dab36b2138ec476d)
1 // RUN: %clang_cc1 -triple arm64-apple-ios   -fptrauth-calls -emit-llvm -std=c++11 %s -o - | FileCheck %s
2 // RUN: %clang_cc1 -triple aarch64-linux-gnu -fptrauth-calls -emit-llvm -std=c++11 %s -o - | FileCheck %s
3 
4 namespace Test1 {
5   struct B1 {
6     virtual void* foo1() {
7       return 0;
8     }
9   };
10   struct Pad1 {
11     virtual ~Pad1() {}
12   };
13   struct Proxy1 : Pad1, B1 {
14     virtual ~Proxy1() {}
15   };
16   struct D : virtual Proxy1 {
17     virtual ~D() {}
18     virtual void* foo1();
19   };
20   void* D::foo1() {
21     return (void*)this;
22   }
23 }
24 
25 // CHECK-LABEL: define linkonce_odr void @_ZTv0_n24_N5Test11DD0Ev(ptr noundef %this)
26 // CHECK: %[[This:.*]] = load ptr
27 // CHECK: %[[SignedVTable:.*]] = load ptr, ptr %[[This]], align 8
28 // CHECK: %[[SignedVTableAsInt:.*]] = ptrtoint ptr %[[SignedVTable]] to i64
29 // CHECK: %[[VTable:.*]] = call i64 @llvm.ptrauth.auth(i64 %[[SignedVTableAsInt]], i32 2, i64 0)
30