[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / ptrauth-ubsan-vptr.cpp
blob8045e7bdc74605da2a45009a5dee6680d47f6bab
1 // RUN: %clang_cc1 -triple arm64e-apple-ios15 -fsanitize=vptr -O0 -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple arm64e-apple-ios15 -fsanitize=vptr -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
4 // RUN: %clang_cc1 -triple aarch64-linux-gnu -fsanitize=vptr -O0 -emit-llvm -o - %s | FileCheck %s
5 // RUN: %clang_cc1 -triple aarch64-linux-gnu -fsanitize=vptr -O2 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s
7 struct S {
8 S() {}
9 ~S() {}
10 virtual int v() { return 0; }
11 int a;
14 struct T : public S {
15 virtual int v();
18 // CHECK-LABEL: foo1
19 int foo1(void* Buffer) {
20 T *p = reinterpret_cast<T*>(Buffer);
21 return p->v();
23 // CHECK-NOT: call {{.*}} @llvm.ptrauth.auth{{.*}}
24 // CHECK-NOT: call {{.*}} @llvm.ptrauth.strip{{.*}}
26 // CHECK-LABEL: foo2
27 int foo2(S* s) {
28 T *p = dynamic_cast<T*>(s);
29 return p->v();
32 // CHECK-NOT: call {{.*}} @llvm.ptrauth.auth{{.*}}
33 // CHECK-NOT: call {{.*}} @llvm.ptrauth.strip{{.*}}