brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 630b5ed Raw
38 lines · cpp
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 %s4// 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 %s7 8// Check that functions generated by clang have the correct attributes9 10class Example {11public:12  Example();13  int fn();14};15 16// Initialization of var1 causes __cxx_global_var_init and __tls_init to be generated17thread_local Example var1;18extern thread_local Example var2;19extern void fn();20 21int testfn() noexcept {22  // Calling fn in a noexcept function causes __clang_call_terminate to be generated23  fn();24  // Use of var1 and var2 causes TLS wrapper functions to be generated25  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"38