[llvm] a5c33e6 - [AArch64][ELF Parser] Fix out-of-scope variable usage (#130594)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 10 05:56:49 PDT 2025
Author: SivanShani-Arm
Date: 2025-03-10T12:56:46Z
New Revision: a5c33e634b912586fe6bfbb2f63cb27d74adc13d
URL: https://github.com/llvm/llvm-project/commit/a5c33e634b912586fe6bfbb2f63cb27d74adc13d
DIFF: https://github.com/llvm/llvm-project/commit/a5c33e634b912586fe6bfbb2f63cb27d74adc13d.diff
LOG: [AArch64][ELF Parser] Fix out-of-scope variable usage (#130594)
Return a reference to a persistent variable instead of a temporary copy.
Added:
Modified:
llvm/lib/Support/ELFAttrParserExtended.cpp
Removed:
################################################################################
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);
}
More information about the llvm-commits
mailing list