[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:🧝:ThunkSection *, unsigned int> &') to prevent copying
        for (const std::pair<ThunkSection *, uint32_t> ts : isd->thunkSections)

It is not changed in this commit.
This commit is contained in:
Fangrui Song 2020-01-01 15:28:48 -08:00
parent 92b68c1937
commit 681b1be774
5 changed files with 5 additions and 14 deletions

View File

@ -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() +

View File

@ -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() +

View File

@ -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);

View File

@ -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;

View File

@ -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() +