diff options
author | Tim Northover <tnorthover@apple.com> | 2014-06-30 10:30:00 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2014-06-30 10:30:00 +0000 |
commit | b5bf686b58a8692726e4017c734f0c6d065e5ac5 (patch) | |
tree | bc4fb3282e6882327513de77c527ae8accbe6e7b /lld/lib/ReaderWriter | |
parent | 18eb25e85b31374debe59a7036f97d2cd7614a62 (diff) | |
download | bcm5719-llvm-b5bf686b58a8692726e4017c734f0c6d065e5ac5.tar.gz bcm5719-llvm-b5bf686b58a8692726e4017c734f0c6d065e5ac5.zip |
MachO: stop iterating past the end of an array
When trying to map atom types to sections, we were iterating through an array
until we hit a sentinel value. There's no need for such dances when range-based
for loops are available.
llvm-svn: 212035
Diffstat (limited to 'lld/lib/ReaderWriter')
-rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index 5bc1b3d7060..67ed62c4f02 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -227,9 +227,8 @@ const MachOFinalSectionFromAtomType sectsToAtomType[] = { SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) { - for (const MachOFinalSectionFromAtomType *p = sectsToAtomType ; - p->atomType != DefinedAtom::typeUnknown; ++p) { - if (p->atomType != atomType) + for (auto &p : sectsToAtomType) { + if (p.atomType != atomType) continue; SectionAttr sectionAttrs = 0; switch (atomType) { @@ -243,15 +242,15 @@ SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) { // If we already have a SectionInfo with this name, re-use it. // This can happen if two ContentType map to the same mach-o section. for (auto sect : _sectionMap) { - if (sect.second->sectionName.equals(p->sectionName) && - sect.second->segmentName.equals(p->segmentName)) { + if (sect.second->sectionName.equals(p.sectionName) && + sect.second->segmentName.equals(p.segmentName)) { return sect.second; } } // Otherwise allocate new SectionInfo object. - SectionInfo *sect = new (_allocator) SectionInfo(p->segmentName, - p->sectionName, - p->sectionType, + SectionInfo *sect = new (_allocator) SectionInfo(p.segmentName, + p.sectionName, + p.sectionType, sectionAttrs); _sectionInfos.push_back(sect); _sectionMap[atomType] = sect; |