[clang] [NFC][ARM][AArch64] Deduplicated code. (PR #82785)
Tomas Matheson via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 28 07:42:53 PST 2024
================
@@ -1369,13 +1369,20 @@ class TargetInfo : public TransferrableTargetInfo,
}
struct BranchProtectionInfo {
- LangOptions::SignReturnAddressScopeKind SignReturnAddr =
- LangOptions::SignReturnAddressScopeKind::None;
- LangOptions::SignReturnAddressKeyKind SignKey =
- LangOptions::SignReturnAddressKeyKind::AKey;
- bool BranchTargetEnforcement = false;
- bool BranchProtectionPAuthLR = false;
- bool GuardedControlStack = false;
+ LangOptions::SignReturnAddressScopeKind SignReturnAddr;
+ LangOptions::SignReturnAddressKeyKind SignKey;
+ bool BranchTargetEnforcement;
+ bool BranchProtectionPAuthLR;
+ bool GuardedControlStack;
+
+ BranchProtectionInfo() = default;
+
+ const char *getSignReturnAddrStr() const {
+ static const char *SignReturnAddrStr[] = {"none", "non-leaf", "all"};
+ assert(static_cast<unsigned>(SignReturnAddr) <= 2 &&
+ "Unexpected SignReturnAddressScopeKind");
+ return SignReturnAddrStr[static_cast<int>(SignReturnAddr)];
+ }
----------------
tmatheson-arm wrote:
```suggestion
const char *getSignReturnAddrStr() const {
switch (SignReturnAddr) {
case None:
return "none";
case NonLeaf:
return "non-leaf";
case All:
return "all";
}
assert(false && "Unexpected SignReturnAddressScopeKind");
}
```
https://github.com/llvm/llvm-project/pull/82785
More information about the cfe-commits
mailing list