[lld] 681b1be - [lld] Fix -Wrange-loop-analysis warnings
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 1 15:42:57 PST 2020
Author: Fangrui Song
Date: 2020-01-01T15:41:20-08:00
New Revision: 681b1be774964a804beabfb7c5e3bdab8f979e4a
URL: https://github.com/llvm/llvm-project/commit/681b1be774964a804beabfb7c5e3bdab8f979e4a
DIFF: https://github.com/llvm/llvm-project/commit/681b1be774964a804beabfb7c5e3bdab8f979e4a.diff
LOG: [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<ThunkSection *, uint32_t> &' (aka 'cons
t pair<lld::elf::ThunkSection *, unsigned int> &') to prevent copying
for (const std::pair<ThunkSection *, uint32_t> ts : isd->thunkSections)
It is not changed in this commit.
Added:
Modified:
lld/COFF/InputFiles.cpp
lld/ELF/Driver.cpp
lld/ELF/SyntheticSections.cpp
lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
lld/wasm/Driver.cpp
Removed:
################################################################################
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index ff59f4cee3ec..d884201ba31b 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -124,10 +124,7 @@ void ArchiveFile::addMember(const Archive::Symbol &sym) {
std::vector<MemoryBufferRef> getArchiveMembers(Archive *file) {
std::vector<MemoryBufferRef> v;
Error err = Error::success();
- for (const ErrorOr<Archive::Child> &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 c721e872e12e..19598f52cd48 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -165,10 +165,7 @@ std::vector<std::pair<MemoryBufferRef, uint64_t>> static getArchiveMembers(
std::vector<std::pair<MemoryBufferRef, uint64_t>> v;
Error err = Error::success();
bool addToTar = file->isThin() && tar;
- for (const ErrorOr<Archive::Child> &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 2c66f54a6e15..fa581e4802a7 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<const Symbol *, size_t> &p : g.global)
+ for (const std::pair<Symbol *, size_t> &p : g.global)
write(p.second, p.first, 0);
for (const std::pair<Symbol *, size_t> &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 1a4603be77c0..db11f73748d8 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<DefinedAtom>(ref->target());
if (da == nullptr)
return;
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 80a717a533c7..6628ecd7904f 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -197,10 +197,7 @@ std::vector<MemoryBufferRef> static getArchiveMembers(MemoryBufferRef mb) {
std::vector<MemoryBufferRef> v;
Error err = Error::success();
- for (const ErrorOr<Archive::Child> &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() +
More information about the llvm-commits
mailing list