Debian Codegraph @

clang/test/CodeGenCXX/arm64-generated-fn-attr.cpp

raw
1 // RUN: %clang_cc1 -triple aarch64 -mbranch-target-enforce -msign-return-address=all \
2 // RUN: -fcxx-exceptions -fexceptions -emit-llvm %s -o - \
3 // RUN: | FileCheck --check-prefixes=CHECK,BTE-SIGNRA %s
4 // RUN: %clang_cc1 -triple aarch64 -fptrauth-calls -fptrauth-returns -fptrauth-auth-traps -fptrauth-indirect-gotos \
5 // RUN: -fcxx-exceptions -fexceptions -emit-llvm %s -o - \
6 // RUN: | FileCheck --check-prefixes=CHECK,PAUTHTEST %s
7
8 // Check that functions generated by clang have the correct attributes
9
10 class Example {
11 public:
12 Example();
13 int fn();
14 };
15
16 // Initialization of var1 causes __cxx_global_var_init and __tls_init to be generated
17 thread_local Example var1;
18 extern thread_local Example var2;
19 extern void fn();
20
21 int testfn() noexcept {
22 // Calling fn in a noexcept function causes __clang_call_terminate to be generated
23 fn();
24 // Use of var1 and var2 causes TLS wrapper functions to be generated
25 return var1.fn() + var2.fn();
26 }
27
28 // CHECK: define {{.*}} @__cxx_global_var_init() [[ATTR1:#[0-9]+]]
29 // CHECK: define {{.*}} @__clang_call_terminate({{.*}}) [[ATTR2:#[0-9]+]]
30 // CHECK: define {{.*}} @_ZTW4var1() [[ATTR1]]
31 // CHECK: define {{.*}} @_ZTW4var2() [[ATTR1]]
32 // CHECK: define {{.*}} @__tls_init() [[ATTR1]]
33
34 // BTE-SIGNRA: attributes [[ATTR1]] = { {{.*}}"branch-target-enforcement" {{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"
35 // BTE-SIGNRA: attributes [[ATTR2]] = { {{.*}}"branch-target-enforcement" {{.*}}"sign-return-address"="all" "sign-return-address-key"="a_key"
36 // PAUTHTEST: attributes [[ATTR1]] = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" "ptrauth-indirect-gotos" "ptrauth-returns"
37 // PAUTHTEST: attributes [[ATTR2]] = { {{.*}}"ptrauth-auth-traps" "ptrauth-calls" "ptrauth-indirect-gotos" "ptrauth-returns"