[llvm] [AArch64][ELF Parser] Fix out-of-scope variable usage (PR #130576)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 10 03:47:12 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: SivanShani-Arm (sivan-shani)

<details>
<summary>Changes</summary>

Return a reference to a persistent variable instead of a temporary copy.

---
Full diff: https://github.com/llvm/llvm-project/pull/130576.diff


1 Files Affected:

- (modified) llvm/lib/Support/ELFAttrParserExtended.cpp (+2-2) 


``````````diff
diff --git a/llvm/lib/Support/ELFAttrParserExtended.cpp b/llvm/lib/Support/ELFAttrParserExtended.cpp
index 44f86a38ef8c2..f8a6f46360dec 100644
--- a/llvm/lib/Support/ELFAttrParserExtended.cpp
+++ b/llvm/lib/Support/ELFAttrParserExtended.cpp
@@ -32,9 +32,9 @@ ELFExtendedAttrParser::getAttributeValue(unsigned Tag) const {
 std::optional<unsigned>
 ELFExtendedAttrParser::getAttributeValue(StringRef BuildAttrSubsectionName,
                                          unsigned Tag) const {
-  for (auto SubSection : SubSectionVec) {
+  for (const auto &SubSection : SubSectionVec) {
     if (BuildAttrSubsectionName == SubSection.Name)
-      for (auto BAItem : SubSection.Content) {
+      for (const auto &BAItem : SubSection.Content) {
         if (Tag == BAItem.Tag)
           return std::optional<unsigned>(BAItem.IntValue);
       }

``````````

</details>


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


More information about the llvm-commits mailing list