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

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 10 05:55:48 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/130594.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 f8a6f46360dec..c08ed5e6fe86e 100644
--- a/llvm/lib/Support/ELFAttrParserExtended.cpp
+++ b/llvm/lib/Support/ELFAttrParserExtended.cpp
@@ -53,9 +53,9 @@ ELFExtendedAttrParser::getAttributeString(unsigned Tag) const {
 std::optional<StringRef>
 ELFExtendedAttrParser::getAttributeString(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<StringRef>(BAItem.StringValue);
       }

``````````

</details>


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


More information about the llvm-commits mailing list