Index: llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp =================================================================== --- llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp +++ llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -89,25 +89,28 @@ } if (Lazy) return; + // Find a reasonable insertion point within the vector. We skip over // (a) units from a different section, (b) units from the same section // but with lower offset-within-section. This keeps units in order // within a section, although not necessarily within the object file, // even if we do lazy parsing. - auto I = this->begin(); + auto InsertPt = this->begin(); uint32_t Offset = 0; while (Data.isValidOffset(Offset)) { - if (I != this->end() && - (&(*I)->getInfoSection() != &Section || (*I)->getOffset() == Offset)) { - ++I; - continue; + if (InsertPt != this->end()) { + if (&(*InsertPt)->getInfoSection() != &Section || + (*InsertPt)->getOffset() == Offset) { + ++InsertPt; + continue; + } } auto U = Parser(Offset, SectionKind, &Section); // If parsing failed, we're done with this section. if (!U) break; Offset = U->getNextUnitOffset(); - I = std::next(this->insert(I, std::move(U))); + InsertPt = std::next(this->insert(InsertPt, std::move(U))); } }