[C++11] Introduce SectionRef::relocations() to use range-based loops
Reviewers: rafael
Reviewed By: rafael
CC: llvm-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D3077
llvm-svn: 203927
diff --git a/llvm/tools/llvm-objdump/COFFDump.cpp b/llvm/tools/llvm-objdump/COFFDump.cpp
index 3df4431..e2d65a4 100644
--- a/llvm/tools/llvm-objdump/COFFDump.cpp
+++ b/llvm/tools/llvm-objdump/COFFDump.cpp
@@ -390,10 +390,8 @@
continue;
const coff_section *Pdata = Obj->getCOFFSection(SI);
- for (relocation_iterator RI = SI->relocation_begin(),
- RE = SI->relocation_end();
- RI != RE; ++RI)
- Rels.push_back(*RI);
+ for (const RelocationRef &Reloc : SI->relocations())
+ Rels.push_back(Reloc);
// Sort relocations by address.
std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp
index 087fb40..e5247a6 100644
--- a/llvm/tools/llvm-objdump/MachODump.cpp
+++ b/llvm/tools/llvm-objdump/MachODump.cpp
@@ -325,16 +325,14 @@
bool symbolTableWorked = false;
// Parse relocations.
- std::vector<std::pair<uint64_t, SymbolRef> > Relocs;
- for (relocation_iterator RI = Sections[SectIdx].relocation_begin(),
- RE = Sections[SectIdx].relocation_end();
- RI != RE; ++RI) {
+ std::vector<std::pair<uint64_t, SymbolRef>> Relocs;
+ for (const RelocationRef &Reloc : Sections[SectIdx].relocations()) {
uint64_t RelocOffset, SectionAddress;
- RI->getOffset(RelocOffset);
+ Reloc.getOffset(RelocOffset);
Sections[SectIdx].getAddress(SectionAddress);
RelocOffset -= SectionAddress;
- symbol_iterator RelocSym = RI->getSymbol();
+ symbol_iterator RelocSym = Reloc.getSymbol();
Relocs.push_back(std::make_pair(RelocOffset, *RelocSym));
}
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 7fa01f7..9f6ea35 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -435,14 +435,10 @@
// Make a list of all the relocations for this section.
std::vector<RelocationRef> Rels;
if (InlineRelocs) {
- SmallVectorImpl<SectionRef> *RelocSecs = &SectionRelocMap[Section];
- for (SmallVectorImpl<SectionRef>::iterator RelocSec = RelocSecs->begin(),
- E = RelocSecs->end();
- RelocSec != E; ++RelocSec) {
- for (relocation_iterator RI = RelocSec->relocation_begin(),
- RE = RelocSec->relocation_end();
- RI != RE; ++RI)
- Rels.push_back(*RI);
+ for (const SectionRef &RelocSec : SectionRelocMap[Section]) {
+ for (const RelocationRef &Reloc : RelocSec.relocations()) {
+ Rels.push_back(Reloc);
+ }
}
}
@@ -560,18 +556,21 @@
if (error(Section.getName(secname)))
continue;
outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
- for (relocation_iterator ri = Section.relocation_begin(),
- re = Section.relocation_end();
- ri != re; ++ri) {
+ for (const RelocationRef &Reloc : Section.relocations()) {
bool hidden;
uint64_t address;
SmallString<32> relocname;
SmallString<32> valuestr;
- if (error(ri->getHidden(hidden))) continue;
- if (hidden) continue;
- if (error(ri->getTypeName(relocname))) continue;
- if (error(ri->getOffset(address))) continue;
- if (error(ri->getValueString(valuestr))) continue;
+ if (error(Reloc.getHidden(hidden)))
+ continue;
+ if (hidden)
+ continue;
+ if (error(Reloc.getTypeName(relocname)))
+ continue;
+ if (error(Reloc.getOffset(address)))
+ continue;
+ if (error(Reloc.getValueString(valuestr)))
+ continue;
outs() << address << " " << relocname << " " << valuestr << "\n";
}
outs() << "\n";