[llvm] 5bddaf6 - [llvm-readobj] - Fix a warning.
Georgii Rymar via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 24 03:18:39 PDT 2020
Author: Georgii Rymar
Date: 2020-09-24T13:18:01+03:00
New Revision: 5bddaf6dbf77085863346d3171023e30972b7323
URL: https://github.com/llvm/llvm-project/commit/5bddaf6dbf77085863346d3171023e30972b7323
DIFF: https://github.com/llvm/llvm-project/commit/5bddaf6dbf77085863346d3171023e30972b7323.diff
LOG: [llvm-readobj] - Fix a warning.
In a post review comments for D88097 it was mentioned that code
triggers bunch of warnings of the form:
llvm/tools/llvm-readobj/ELFDumper.cpp:5299:28: warning: loop variable 'Note' is always a copy because
the range of type 'iterator_range<llvm::object::ELFFile<llvm::object::ELFType<llvm::support::big, true> >::Elf_Note_Iterator>'
(aka 'iterator_range<Elf_Note_Iterator_Impl<ELFType<(llvm::support::endianness)0U, true> > >') does not return a reference [-Wrange-loop-analysis]
for (const Elf_Note &Note : this->Obj.notes(P, Err))
It happens because Elf_Note is always copied here:
Elf_Note_Impl<ELFT> operator*() const {
assert(Nhdr && "dereferenced ELF note end iterator");
return Elf_Note_Impl<ELFT>(*Nhdr);
}
This patch fixes the issue by removing a reference.
Added:
Modified:
llvm/tools/llvm-readobj/ELFDumper.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index b5393314436e..b04f99308814 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -5277,7 +5277,7 @@ template <class ELFT> void GNUStyle<ELFT>::printNotes() {
PrintHeader(expectedToOptional(this->Obj.getSectionName(S)), S.sh_offset,
S.sh_size);
Error Err = Error::success();
- for (const Elf_Note &Note : this->Obj.notes(S, Err))
+ for (const Elf_Note Note : this->Obj.notes(S, Err))
ProcessNote(Note);
if (Err)
reportError(std::move(Err), this->FileName);
@@ -5296,7 +5296,7 @@ template <class ELFT> void GNUStyle<ELFT>::printNotes() {
continue;
PrintHeader(/*SecName=*/None, P.p_offset, P.p_filesz);
Error Err = Error::success();
- for (const Elf_Note &Note : this->Obj.notes(P, Err))
+ for (const Elf_Note Note : this->Obj.notes(P, Err))
ProcessNote(Note);
if (Err)
reportError(std::move(Err), this->FileName);
More information about the llvm-commits
mailing list