[all-commits] [llvm/llvm-project] 5bddaf: [llvm-readobj] - Fix a warning.

Georgii Rymar via All-commits all-commits at lists.llvm.org
Thu Sep 24 03:18:52 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 5bddaf6dbf77085863346d3171023e30972b7323
      https://github.com/llvm/llvm-project/commit/5bddaf6dbf77085863346d3171023e30972b7323
  Author: Georgii Rymar <grimar at accesssoftek.com>
  Date:   2020-09-24 (Thu, 24 Sep 2020)

  Changed paths:
    M llvm/tools/llvm-readobj/ELFDumper.cpp

  Log Message:
  -----------
  [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.




More information about the All-commits mailing list