https://github.com/DanielKristofKiss updated https://github.com/llvm/llvm-project/pull/98307
>From 4e10c95c390e519853428f424cd655379d99c61c Mon Sep 17 00:00:00 2001 From: Daniel Kiss <daniel.k...@arm.com> Date: Wed, 10 Jul 2024 13:58:52 +0200 Subject: [PATCH 1/3] [Clang][ARM] Call constructor on BranchTargetInfo. Otherwise members will be uninitialised. --- clang/lib/CodeGen/Targets/ARM.cpp | 2 +- clang/lib/Sema/SemaDeclAttr.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/Targets/ARM.cpp b/clang/lib/CodeGen/Targets/ARM.cpp index d449b97cdc685..93fea94a77248 100644 --- a/clang/lib/CodeGen/Targets/ARM.cpp +++ b/clang/lib/CodeGen/Targets/ARM.cpp @@ -141,7 +141,7 @@ class ARMTargetCodeGenInfo : public TargetCodeGenInfo { ParsedTargetAttr Attr = CGM.getTarget().parseTargetAttr(TA->getFeaturesStr()); if (!Attr.BranchProtection.empty()) { - TargetInfo::BranchProtectionInfo BPI; + TargetInfo::BranchProtectionInfo BPI{}; StringRef DiagMsg; StringRef Arch = Attr.CPU.empty() ? CGM.getTarget().getTargetOpts().CPU : Attr.CPU; diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 73a85ff39667b..f2cd46d1e7c93 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -2991,7 +2991,7 @@ bool Sema::checkTargetAttr(SourceLocation LiteralLoc, StringRef AttrStr) { << Unsupported << None << CurFeature << Target; } - TargetInfo::BranchProtectionInfo BPI; + TargetInfo::BranchProtectionInfo BPI{}; StringRef DiagMsg; if (ParsedAttrs.BranchProtection.empty()) return false; >From 4dfab4b3e6dca97ddc0348bcfbea7609170a3078 Mon Sep 17 00:00:00 2001 From: Daniel Kiss <daniel.k...@arm.com> Date: Wed, 10 Jul 2024 16:01:47 +0200 Subject: [PATCH 2/3] Initialize members from the constructor. --- clang/include/clang/Basic/TargetInfo.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 1f208b40f92cb..079c71d10525f 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1434,7 +1434,14 @@ class TargetInfo : public TransferrableTargetInfo, } public: - BranchProtectionInfo() = default; + BranchProtectionInfo() { + SignReturnAddr = LangOptions::SignReturnAddressScopeKind::None; + SignKey = LangOptions::SignReturnAddressKeyKind::AKey; + BranchTargetEnforcement = false; + BranchProtectionPAuthLR = false; + GuardedControlStack = false; + }; + BranchProtectionInfo(const LangOptions &LangOpts) { SignReturnAddr = LangOpts.hasSignReturnAddress() >From ba9ef1fd741f9213b958e299a11021c27e591c4b Mon Sep 17 00:00:00 2001 From: Daniel Kiss <daniel.k...@arm.com> Date: Wed, 10 Jul 2024 17:19:40 +0200 Subject: [PATCH 3/3] move initilizers --- clang/include/clang/Basic/TargetInfo.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index 079c71d10525f..cf7628553647c 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1434,13 +1434,11 @@ class TargetInfo : public TransferrableTargetInfo, } public: - BranchProtectionInfo() { - SignReturnAddr = LangOptions::SignReturnAddressScopeKind::None; - SignKey = LangOptions::SignReturnAddressKeyKind::AKey; - BranchTargetEnforcement = false; - BranchProtectionPAuthLR = false; - GuardedControlStack = false; - }; + BranchProtectionInfo() + : SignReturnAddr(LangOptions::SignReturnAddressScopeKind::None), + SignKey(LangOptions::SignReturnAddressKeyKind::AKey), + BranchTargetEnforcement(false), BranchProtectionPAuthLR(false), + GuardedControlStack(false) {} BranchProtectionInfo(const LangOptions &LangOpts) { SignReturnAddr = _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits