Skip to content

[AArch64][ELF Parser] Fix out-of-scope variable usage #130576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2025

Conversation

sivan-shani
Copy link
Contributor

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

Return a reference to a persistent variable instead of a temporary copy.
@llvmbot
Copy link
Member

llvmbot commented Mar 10, 2025

@llvm/pr-subscribers-llvm-support

Author: SivanShani-Arm (sivan-shani)

Changes

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 --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);
       }

@sivan-shani
Copy link
Contributor Author

This is a fix for failing sanitizers on commit:
b1ebfac

failing sanitizers:
https://lab.llvm.org/buildbot/#/builders/51/builds/12245

Copy link
Contributor

@eleanor-arm eleanor-arm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sivan-shani sivan-shani merged commit 4508d6a into llvm:main Mar 10, 2025
13 checks passed
@sivan-shani sivan-shani deleted the fixsan branch March 10, 2025 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants