[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / cfi-mfcall.cpp
blob1ad78e7e2c12f34779ae5ec8923165d9a08cc33e
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-mfcall -fsanitize-trap=cfi-mfcall -fvisibility=hidden -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=cfi-mfcall -fsanitize-trap=cfi-mfcall -fvisibility=default -emit-llvm -o - %s | FileCheck --check-prefix=DEFAULT %s
3 // With -fwhole-program-vtables we should get the member function pointer type
4 // test, even without hidden visibility.
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux -fwhole-program-vtables -emit-llvm -o - %s | FileCheck %s --check-prefix=WPV
7 struct B1 {};
8 struct B2 {};
9 struct B3 : B2 {};
10 struct S : B1, B3 {};
12 // DEFAULT-NOT: llvm.type.test
13 // DEFAULT-NOT: llvm.public.type.test
15 void f(S *s, void (S::*p)()) {
16 // WPV: [[OFFSET:%.*]] = sub i64 {{.*}}, 1
17 // WPV: [[VFPTR:%.*]] = getelementptr i8, ptr %{{.*}}, i64 [[OFFSET]]
18 // WPV: [[TT:%.*]] = call i1 @llvm.public.type.test(ptr [[VFPTR]], metadata !"_ZTSM1SFvvE.virtual")
19 // CHECK: [[OFFSET:%.*]] = sub i64 {{.*}}, 1
20 // CHECK: [[VFPTR:%.*]] = getelementptr i8, ptr %{{.*}}, i64 [[OFFSET]]
21 // CHECK: [[TT:%.*]] = call i1 @llvm.type.test(ptr [[VFPTR]], metadata !"_ZTSM1SFvvE.virtual")
22 // CHECK: br i1 [[TT]], label {{.*}}, label %[[TRAP1:[^,]*]]
24 // CHECK: [[TRAP1]]:
25 // CHECK-NEXT: llvm.ubsantrap
27 // CHECK: [[TT1:%.*]] = call i1 @llvm.type.test(ptr {{.*}}, metadata !"_ZTSM2B1FvvE")
28 // CHECK: [[OR1:%.*]] = or i1 false, [[TT1]]
29 // CHECK: [[TT2:%.*]] = call i1 @llvm.type.test(ptr {{.*}}, metadata !"_ZTSM2B2FvvE")
30 // CHECK: [[OR2:%.*]] = or i1 [[OR1]], [[TT2]]
31 // CHECK: br i1 [[OR2]], label {{.*}}, label %[[TRAP2:[^,]*]]
33 // CHECK: [[TRAP2]]:
34 // CHECK-NEXT: llvm.ubsantrap
35 (s->*p)();