diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -267,8 +267,9 @@ // We don't take a reference to cachedFile here because the // loadArchiveMember() call below may recursively call addFile() and // invalidate this reference. - if (ArchiveFile *cachedFile = loadedArchives[path]) - return cachedFile; + auto entry = loadedArchives.find(path); + if (entry != loadedArchives.end()) + return entry->second; std::unique_ptr archive = CHECK( object::Archive::create(mbref), path + ": failed to parse archive"); diff --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h --- a/lld/MachO/InputSection.h +++ b/lld/MachO/InputSection.h @@ -21,6 +21,8 @@ #include "llvm/ADT/TinyPtrVector.h" #include "llvm/BinaryFormat/MachO.h" +#include + namespace lld { namespace macho { @@ -62,7 +64,7 @@ bool isFinal = false; ArrayRef data; - std::vector relocs; + std::list relocs; // The symbols that belong to this InputSection, sorted by value. With // .subsections_via_symbols, there is typically only one element here. llvm::TinyPtrVector symbols; diff --git a/lld/MachO/InputSection.cpp b/lld/MachO/InputSection.cpp --- a/lld/MachO/InputSection.cpp +++ b/lld/MachO/InputSection.cpp @@ -139,13 +139,14 @@ memcpy(buf, data.data(), data.size()); - for (size_t i = 0; i < relocs.size(); i++) { - const Reloc &r = relocs[i]; + for (auto it = relocs.begin(); it != relocs.end(); ++it) { + const Reloc &r = *it; uint8_t *loc = buf + r.offset; uint64_t referentVA = 0; if (target->hasAttr(r.type, RelocAttrBits::SUBTRAHEND)) { const Symbol *fromSym = r.referent.get(); - const Reloc &minuend = relocs[++i]; + ++it; + const Reloc &minuend = *it; uint64_t minuendVA; if (const Symbol *toSym = minuend.referent.dyn_cast()) minuendVA = toSym->getVA() + minuend.addend; diff --git a/lld/MachO/UnwindInfoSection.cpp b/lld/MachO/UnwindInfoSection.cpp --- a/lld/MachO/UnwindInfoSection.cpp +++ b/lld/MachO/UnwindInfoSection.cpp @@ -198,8 +198,7 @@ // work. But since there are usually just few personality functions // that are referenced from many places, at least some of them likely // live, it wouldn't reduce number of got entries. - for (size_t i = 0; i < isec->relocs.size(); ++i) { - Reloc &r = isec->relocs[i]; + for (Reloc &r : isec->relocs) { assert(target->hasAttr(r.type, RelocAttrBits::UNSIGNED)); // Functions and LSDA entries always reside in the same object file as the