Debian Codegraph @

clang/test/Preprocessor/ptrauth_feature.c

raw
1 //// Note: preprocessor features exactly match corresponding clang driver flags. However, some flags are only intended to be used in combination with other ones.
2 //// For example, -fptrauth-init-fini will not affect codegen without -fptrauth-calls, but the preprocessor feature would be set anyway.
3
4 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-intrinsics | \
5 // RUN: FileCheck %s --check-prefixes=INTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOTYPE_INFO_DISCR,NOFUNC,NOINITFINI,NOGOTOS
6
7 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-calls | \
8 // RUN: FileCheck %s --check-prefixes=NOINTRIN,CALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOTYPE_INFO_DISCR,NOFUNC,NOINITFINI,NOGOTOS
9
10 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-returns | \
11 // RUN: FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,RETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOTYPE_INFO_DISCR,NOFUNC,NOINITFINI,NOGOTOS
12
13 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-vtable-pointer-address-discrimination | \
14 // RUN: FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,VPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOTYPE_INFO_DISCR,NOFUNC,NOINITFINI,NOGOTOS
15
16 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-vtable-pointer-type-discrimination | \
17 // RUN: FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,VPTR_TYPE_DISCR,NOTYPE_INFO_DISCR,NOFUNC,NOINITFINI,NOGOTOS
18
19 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-type-info-vtable-pointer-discrimination | \
20 // RUN: FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,TYPE_INFO_DISCR,NOFUNC,NOINITFINI,NOGOTOS
21
22 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-function-pointer-type-discrimination | \
23 // RUN: FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOTYPE_INFO_DISCR,FUNC,NOINITFINI,NOGOTOS
24
25 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-init-fini | \
26 // RUN: FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOTYPE_INFO_DISCR,NOFUNC,INITFINI,NOGOTOS
27
28 // RUN: %clang_cc1 -E %s -triple=aarch64 -fptrauth-indirect-gotos | \
29 // RUN: FileCheck %s --check-prefixes=NOINTRIN,NOCALLS,NORETS,NOVPTR_ADDR_DISCR,NOVPTR_TYPE_DISCR,NOTYPE_INFO_DISCR,NOFUNC,NOINITFINI,GOTOS
30
31 #if __has_feature(ptrauth_intrinsics)
32 // INTRIN: has_ptrauth_intrinsics
33 void has_ptrauth_intrinsics() {}
34 #else
35 // NOINTRIN: no_ptrauth_intrinsics
36 void no_ptrauth_intrinsics() {}
37 #endif
38
39 #if __has_feature(ptrauth_calls)
40 // CALLS: has_ptrauth_calls
41 void has_ptrauth_calls() {}
42 #else
43 // NOCALLS: no_ptrauth_calls
44 void no_ptrauth_calls() {}
45 #endif
46
47 // This is always enabled when ptrauth_calls is enabled
48 #if __has_feature(ptrauth_member_function_pointer_type_discrimination)
49 // CALLS: has_ptrauth_member_function_pointer_type_discrimination
50 void has_ptrauth_member_function_pointer_type_discrimination() {}
51 #else
52 // NOCALLS: no_ptrauth_member_function_pointer_type_discrimination
53 void no_ptrauth_member_function_pointer_type_discrimination() {}
54 #endif
55
56 #if __has_feature(ptrauth_returns)
57 // RETS: has_ptrauth_returns
58 void has_ptrauth_returns() {}
59 #else
60 // NORETS: no_ptrauth_returns
61 void no_ptrauth_returns() {}
62 #endif
63
64 #if __has_feature(ptrauth_vtable_pointer_address_discrimination)
65 // VPTR_ADDR_DISCR: has_ptrauth_vtable_pointer_address_discrimination
66 void has_ptrauth_vtable_pointer_address_discrimination() {}
67 #else
68 // NOVPTR_ADDR_DISCR: no_ptrauth_vtable_pointer_address_discrimination
69 void no_ptrauth_vtable_pointer_address_discrimination() {}
70 #endif
71
72 #if __has_feature(ptrauth_vtable_pointer_type_discrimination)
73 // VPTR_TYPE_DISCR: has_ptrauth_vtable_pointer_type_discrimination
74 void has_ptrauth_vtable_pointer_type_discrimination() {}
75 #else
76 // NOVPTR_TYPE_DISCR: no_ptrauth_vtable_pointer_type_discrimination
77 void no_ptrauth_vtable_pointer_type_discrimination() {}
78 #endif
79
80 #if __has_feature(ptrauth_type_info_vtable_pointer_discrimination)
81 // TYPE_INFO_DISCR: has_ptrauth_type_info_vtable_pointer_discrimination
82 void has_ptrauth_type_info_vtable_pointer_discrimination() {}
83 #else
84 // NOTYPE_INFO_DISCR: no_ptrauth_type_info_vtable_pointer_discrimination
85 void no_ptrauth_type_info_vtable_pointer_discrimination() {}
86 #endif
87
88 #if __has_feature(ptrauth_function_pointer_type_discrimination)
89 // FUNC: has_ptrauth_function_pointer_type_discrimination
90 void has_ptrauth_function_pointer_type_discrimination() {}
91 #else
92 // NOFUNC: no_ptrauth_function_pointer_type_discrimination
93 void no_ptrauth_function_pointer_type_discrimination() {}
94 #endif
95
96 #if __has_feature(ptrauth_init_fini)
97 // INITFINI: has_ptrauth_init_fini
98 void has_ptrauth_init_fini() {}
99 #else
100 // NOINITFINI: no_ptrauth_init_fini
101 void no_ptrauth_init_fini() {}
102 #endif
103
104 #if __has_feature(ptrauth_indirect_gotos)
105 // GOTOS: has_ptrauth_indirect_gotos
106 void has_ptrauth_indirect_gotos() {}
107 #else
108 // NOGOTOS: no_ptrauth_indirect_gotos
109 void no_ptrauth_indirect_gotos() {}
110 #endif