From 681b1be774964a804beabfb7c5e3bdab8f979e4a Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 1 Jan 2020 15:28:48 -0800 Subject: [PATCH] [lld] Fix -Wrange-loop-analysis warnings One instance looks like a false positive: lld/ELF/Relocations.cpp:1622:14: note: use reference type 'const std::pair &' (aka 'cons t pair &') to prevent copying for (const std::pair ts : isd->thunkSections) It is not changed in this commit. --- lld/COFF/InputFiles.cpp | 5 +---- lld/ELF/Driver.cpp | 5 +---- lld/ELF/SyntheticSections.cpp | 2 +- lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 2 +- lld/wasm/Driver.cpp | 5 +---- 5 files changed, 5 insertions(+), 14 deletions(-) diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp index ff59f4c..d884201 100644 --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -124,10 +124,7 @@ void ArchiveFile::addMember(const Archive::Symbol &sym) { std::vector getArchiveMembers(Archive *file) { std::vector v; Error err = Error::success(); - for (const ErrorOr &cOrErr : file->children(err)) { - Archive::Child c = - CHECK(cOrErr, - file->getFileName() + ": could not get the child of the archive"); + for (const Archive::Child &c : file->children(err)) { MemoryBufferRef mbref = CHECK(c.getMemoryBufferRef(), file->getFileName() + diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index c721e87..19598f52c 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -165,10 +165,7 @@ std::vector> static getArchiveMembers( std::vector> v; Error err = Error::success(); bool addToTar = file->isThin() && tar; - for (const ErrorOr &cOrErr : file->children(err)) { - Archive::Child c = - CHECK(cOrErr, mb.getBufferIdentifier() + - ": could not get the child of the archive"); + for (const Archive::Child &c : file->children(err)) { MemoryBufferRef mbref = CHECK(c.getMemoryBufferRef(), mb.getBufferIdentifier() + diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 2c66f54..fa581e4 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -1055,7 +1055,7 @@ void MipsGotSection::writeTo(uint8_t *buf) { // Write VA to the primary GOT only. For secondary GOTs that // will be done by REL32 dynamic relocations. if (&g == &gots.front()) - for (const std::pair &p : g.global) + for (const std::pair &p : g.global) write(p.second, p.first, 0); for (const std::pair &p : g.relocs) write(p.second, p.first, 0); diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index 1a4603b..db11f73 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -1491,7 +1491,7 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile, void Util::fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset, NormalizedFile &file) { - for (const auto &ref : *atom) { + for (const Reference *ref : *atom) { const DefinedAtom *da = dyn_cast(ref->target()); if (da == nullptr) return; diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp index 80a717a..6628ecd 100644 --- a/lld/wasm/Driver.cpp +++ b/lld/wasm/Driver.cpp @@ -197,10 +197,7 @@ std::vector static getArchiveMembers(MemoryBufferRef mb) { std::vector v; Error err = Error::success(); - for (const ErrorOr &cOrErr : file->children(err)) { - Archive::Child c = - CHECK(cOrErr, mb.getBufferIdentifier() + - ": could not get the child of the archive"); + for (const Archive::Child &c : file->children(err)) { MemoryBufferRef mbref = CHECK(c.getMemoryBufferRef(), mb.getBufferIdentifier() + -- 2.7.4