[clang] [NFC][ARM][AArch64] Deduplicated code. (PR #82785)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 28 08:43:49 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)];
+    }
----------------
DanielKristofKiss wrote:

Done,
also the getSignKeyStr is added because become handy in later patches.

https://github.com/llvm/llvm-project/pull/82785


More information about the cfe-commits mailing list