File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -1369,13 +1369,20 @@ class TargetInfo : public TransferrableTargetInfo,
13691369 }
13701370
13711371 struct BranchProtectionInfo {
1372- LangOptions::SignReturnAddressScopeKind SignReturnAddr =
1373- LangOptions::SignReturnAddressScopeKind::None;
1374- LangOptions::SignReturnAddressKeyKind SignKey =
1375- LangOptions::SignReturnAddressKeyKind::AKey;
1376- bool BranchTargetEnforcement = false ;
1377- bool BranchProtectionPAuthLR = false ;
1378- bool GuardedControlStack = false ;
1372+ LangOptions::SignReturnAddressScopeKind SignReturnAddr;
1373+ LangOptions::SignReturnAddressKeyKind SignKey;
1374+ bool BranchTargetEnforcement;
1375+ bool BranchProtectionPAuthLR;
1376+ bool GuardedControlStack;
1377+
1378+ BranchProtectionInfo () = default ;
1379+
1380+ const char *getSignReturnAddrStr () const {
1381+ static const char *SignReturnAddrStr[] = {" none" , " non-leaf" , " all" };
1382+ assert (static_cast <unsigned >(SignReturnAddr) <= 2 &&
1383+ " Unexpected SignReturnAddressScopeKind" );
1384+ return SignReturnAddrStr[static_cast <int >(SignReturnAddr)];
1385+ }
13791386 };
13801387
13811388 // / Determine if the Architecture in this TargetInfo supports branch
Original file line number Diff line number Diff line change @@ -125,8 +125,7 @@ class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
125125 assert (Error.empty ());
126126
127127 auto *Fn = cast<llvm::Function>(GV);
128- static const char *SignReturnAddrStr[] = {" none" , " non-leaf" , " all" };
129- Fn->addFnAttr (" sign-return-address" , SignReturnAddrStr[static_cast <int >(BPI.SignReturnAddr )]);
128+ Fn->addFnAttr (" sign-return-address" , BPI.getSignReturnAddrStr ());
130129
131130 if (BPI.SignReturnAddr != LangOptions::SignReturnAddressScopeKind::None) {
132131 Fn->addFnAttr (" sign-return-address-key" ,
Original file line number Diff line number Diff line change @@ -152,13 +152,7 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo {
152152 diag::warn_target_unsupported_branch_protection_attribute)
153153 << Arch;
154154 } else {
155- static const char *SignReturnAddrStr[] = {" none" , " non-leaf" , " all" };
156- assert (static_cast <unsigned >(BPI.SignReturnAddr ) <= 2 &&
157- " Unexpected SignReturnAddressScopeKind" );
158- Fn->addFnAttr (
159- " sign-return-address" ,
160- SignReturnAddrStr[static_cast <int >(BPI.SignReturnAddr )]);
161-
155+ Fn->addFnAttr (" sign-return-address" , BPI.getSignReturnAddrStr ());
162156 Fn->addFnAttr (" branch-target-enforcement" ,
163157 BPI.BranchTargetEnforcement ? " true" : " false" );
164158 }
You can’t perform that action at this time.
0 commit comments