summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-30 02:49:50 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-30 02:49:50 +0000
commitefdbec8b0a49fb67c3844be703548fdc6c1dded0 (patch)
tree040894fc0c18d09dfdfec8693a253bcf998cb8c5 /tools
parent6bf3966f7fd92217360877d1c04ea8ffe47c11cc (diff)
downloadllvm-efdbec8b0a49fb67c3844be703548fdc6c1dded0.tar.gz
llvm-efdbec8b0a49fb67c3844be703548fdc6c1dded0.tar.bz2
llvm-efdbec8b0a49fb67c3844be703548fdc6c1dded0.tar.xz
Simplify the handling of iterators in ObjectFile.
None of the object file formats reported error on iterator increment. In retrospect, that is not too surprising: no object format stores symbols or sections in a linked list or other structure that requires chasing pointers. As a consequence, all error checking can be done on begin() and end(). This reduces the text segment of bin/llvm-readobj in my machine from 521233 to 518526 bytes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200442 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/llvm-ar/llvm-ar.cpp3
-rw-r--r--tools/llvm-nm/llvm-nm.cpp5
-rw-r--r--tools/llvm-objdump/COFFDump.cpp23
-rw-r--r--tools/llvm-objdump/MachODump.cpp14
-rw-r--r--tools/llvm-objdump/llvm-objdump.cpp39
-rw-r--r--tools/llvm-readobj/COFFDumper.cpp52
-rw-r--r--tools/llvm-readobj/MachODumper.cpp30
-rw-r--r--tools/llvm-rtdyld/llvm-rtdyld.cpp4
-rw-r--r--tools/llvm-size/llvm-size.cpp25
-rw-r--r--tools/llvm-symbolizer/LLVMSymbolize.cpp8
-rw-r--r--tools/macho-dump/macho-dump.cpp7
-rw-r--r--tools/obj2yaml/coff2yaml.cpp10
12 files changed, 55 insertions, 165 deletions
diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp
index 8917cd3801..bb5c0da8a3 100644
--- a/tools/llvm-ar/llvm-ar.cpp
+++ b/tools/llvm-ar/llvm-ar.cpp
@@ -716,10 +716,9 @@ static void writeSymbolTable(
print32BE(Out, 0);
}
- error_code Err;
for (object::symbol_iterator I = Obj->begin_symbols(),
E = Obj->end_symbols();
- I != E; I.increment(Err), failIfError(Err)) {
+ I != E; ++I) {
uint32_t Symflags;
failIfError(I->getFlags(Symflags));
if (Symflags & object::SymbolRef::SF_FormatSpecific)
diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp
index 495a71b0e9..da221d133a 100644
--- a/tools/llvm-nm/llvm-nm.cpp
+++ b/tools/llvm-nm/llvm-nm.cpp
@@ -532,16 +532,13 @@ static char getNMTypeChar(ObjectFile *Obj, symbol_iterator I) {
}
static void dumpSymbolNamesFromObject(ObjectFile *Obj) {
- error_code EC;
symbol_iterator IBegin = Obj->begin_symbols();
symbol_iterator IEnd = Obj->end_symbols();
if (DynamicSyms) {
IBegin = Obj->begin_dynamic_symbols();
IEnd = Obj->end_dynamic_symbols();
}
- for (symbol_iterator I = IBegin; I != IEnd; I.increment(EC)) {
- if (error(EC))
- break;
+ for (symbol_iterator I = IBegin; I != IEnd; ++I) {
uint32_t SymFlags;
if (error(I->getFlags(SymFlags)))
break;
diff --git a/tools/llvm-objdump/COFFDump.cpp b/tools/llvm-objdump/COFFDump.cpp
index 7b60a5d4dc..dd2db2b037 100644
--- a/tools/llvm-objdump/COFFDump.cpp
+++ b/tools/llvm-objdump/COFFDump.cpp
@@ -241,11 +241,7 @@ static void printImportTables(const COFFObjectFile *Obj) {
if (I == E)
return;
outs() << "The Import Tables:\n";
- error_code EC;
- for (; I != E; I = I.increment(EC)) {
- if (EC)
- return;
-
+ for (; I != E; I = ++I) {
const import_directory_table_entry *Dir;
StringRef Name;
if (I->getImportTableEntry(Dir)) return;
@@ -294,10 +290,7 @@ static void printExportTable(const COFFObjectFile *Obj) {
outs() << " DLL name: " << DllName << "\n";
outs() << " Ordinal base: " << OrdinalBase << "\n";
outs() << " Ordinal RVA Name\n";
- error_code EC;
- for (; I != E; I = I.increment(EC)) {
- if (EC)
- return;
+ for (; I != E; I = ++I) {
uint32_t Ordinal;
if (I->getOrdinal(Ordinal))
return;
@@ -327,12 +320,8 @@ void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) {
const coff_section *Pdata = 0;
- error_code EC;
- for (section_iterator SI = Obj->begin_sections(),
- SE = Obj->end_sections();
- SI != SE; SI.increment(EC)) {
- if (error(EC)) return;
-
+ for (section_iterator SI = Obj->begin_sections(), SE = Obj->end_sections();
+ SI != SE; ++SI) {
StringRef Name;
if (error(SI->getName(Name))) continue;
@@ -342,10 +331,8 @@ void llvm::printCOFFUnwindInfo(const COFFObjectFile *Obj) {
std::vector<RelocationRef> Rels;
for (relocation_iterator RI = SI->begin_relocations(),
RE = SI->end_relocations();
- RI != RE; RI.increment(EC)) {
- if (error(EC)) break;
+ RI != RE; ++RI)
Rels.push_back(*RI);
- }
// Sort relocations by address.
std::sort(Rels.begin(), Rels.end(), RelocAddressLess);
diff --git a/tools/llvm-objdump/MachODump.cpp b/tools/llvm-objdump/MachODump.cpp
index 52c786f305..b8ce9c884a 100644
--- a/tools/llvm-objdump/MachODump.cpp
+++ b/tools/llvm-objdump/MachODump.cpp
@@ -154,13 +154,14 @@ getSectionsAndSymbols(const MachO::mach_header Header,
std::vector<SymbolRef> &Symbols,
SmallVectorImpl<uint64_t> &FoundFns,
uint64_t &BaseSegmentAddress) {
- error_code ec;
for (symbol_iterator SI = MachOObj->begin_symbols(),
- SE = MachOObj->end_symbols(); SI != SE; SI.increment(ec))
+ SE = MachOObj->end_symbols();
+ SI != SE; ++SI)
Symbols.push_back(*SI);
for (section_iterator SI = MachOObj->begin_sections(),
- SE = MachOObj->end_sections(); SI != SE; SI.increment(ec)) {
+ SE = MachOObj->end_sections();
+ SI != SE; ++SI) {
SectionRef SR = *SI;
StringRef SectName;
SR.getName(SectName);
@@ -270,9 +271,8 @@ static void DisassembleInputMachO2(StringRef Filename,
else
BaseAddress = BaseSegmentAddress;
DiceTable Dices;
- error_code ec;
for (dice_iterator DI = MachOOF->begin_dices(), DE = MachOOF->end_dices();
- DI != DE; DI.increment(ec)){
+ DI != DE; ++DI) {
uint32_t Offset;
DI->getOffset(Offset);
Dices.push_back(std::make_pair(BaseAddress + Offset, *DI));
@@ -329,9 +329,9 @@ static void DisassembleInputMachO2(StringRef Filename,
// Parse relocations.
std::vector<std::pair<uint64_t, SymbolRef> > Relocs;
- error_code ec;
for (relocation_iterator RI = Sections[SectIdx].begin_relocations(),
- RE = Sections[SectIdx].end_relocations(); RI != RE; RI.increment(ec)) {
+ RE = Sections[SectIdx].end_relocations();
+ RI != RE; ++RI) {
uint64_t RelocOffset, SectionAddress;
RI->getOffset(RelocOffset);
Sections[SectIdx].getAddress(SectionAddress);
diff --git a/tools/llvm-objdump/llvm-objdump.cpp b/tools/llvm-objdump/llvm-objdump.cpp
index 9a56bf9b4c..325e7006ed 100644
--- a/tools/llvm-objdump/llvm-objdump.cpp
+++ b/tools/llvm-objdump/llvm-objdump.cpp
@@ -387,18 +387,14 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
error_code EC;
std::map<SectionRef, SmallVector<SectionRef, 1> > SectionRelocMap;
for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
- I != E; I.increment(EC)) {
- if (error(EC))
- break;
+ I != E; ++I) {
section_iterator Sec2 = I->getRelocatedSection();
if (Sec2 != Obj->end_sections())
SectionRelocMap[*Sec2].push_back(*I);
}
for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
- I != E; I.increment(EC)) {
- if (error(EC))
- break;
+ I != E; ++I) {
bool Text;
if (error(I->isText(Text)))
break;
@@ -412,7 +408,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
// Make a list of all the symbols in this section.
std::vector<std::pair<uint64_t, StringRef> > Symbols;
for (symbol_iterator SI = Obj->begin_symbols(), SE = Obj->end_symbols();
- SI != SE; SI.increment(EC)) {
+ SI != SE; ++SI) {
bool contains;
if (!error(I->containsSymbol(*SI, contains)) && contains) {
uint64_t Address;
@@ -441,11 +437,8 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
RelocSec != E; ++RelocSec) {
for (relocation_iterator RI = RelocSec->begin_relocations(),
RE = RelocSec->end_relocations();
- RI != RE; RI.increment(EC)) {
- if (error(EC))
- break;
+ RI != RE; ++RI)
Rels.push_back(*RI);
- }
}
}
@@ -559,11 +552,8 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
}
static void PrintRelocations(const ObjectFile *o) {
- error_code EC;
for (section_iterator si = o->begin_sections(), se = o->end_sections();
- si != se; si.increment(EC)) {
- if (error(EC))
- return;
+ si != se; ++si) {
if (si->begin_relocations() == si->end_relocations())
continue;
StringRef secname;
@@ -571,10 +561,7 @@ static void PrintRelocations(const ObjectFile *o) {
outs() << "RELOCATION RECORDS FOR [" << secname << "]:\n";
for (relocation_iterator ri = si->begin_relocations(),
re = si->end_relocations();
- ri != re; ri.increment(EC)) {
- if (error(EC))
- return;
-
+ ri != re; ++ri) {
bool hidden;
uint64_t address;
SmallString<32> relocname;
@@ -593,12 +580,9 @@ static void PrintRelocations(const ObjectFile *o) {
static void PrintSectionHeaders(const ObjectFile *o) {
outs() << "Sections:\n"
"Idx Name Size Address Type\n";
- error_code EC;
unsigned i = 0;
for (section_iterator si = o->begin_sections(), se = o->end_sections();
- si != se; si.increment(EC)) {
- if (error(EC))
- return;
+ si != se; ++si) {
StringRef Name;
if (error(si->getName(Name)))
return;
@@ -621,9 +605,7 @@ static void PrintSectionHeaders(const ObjectFile *o) {
static void PrintSectionContents(const ObjectFile *o) {
error_code EC;
for (section_iterator si = o->begin_sections(), se = o->end_sections();
- si != se; si.increment(EC)) {
- if (error(EC))
- return;
+ si != se; ++si) {
StringRef Name;
StringRef Contents;
uint64_t BaseAddr;
@@ -714,11 +696,8 @@ static void PrintSymbolTable(const ObjectFile *o) {
if (const COFFObjectFile *coff = dyn_cast<const COFFObjectFile>(o))
PrintCOFFSymbolTable(coff);
else {
- error_code EC;
for (symbol_iterator si = o->begin_symbols(), se = o->end_symbols();
- si != se; si.increment(EC)) {
- if (error(EC))
- return;
+ si != se; ++si) {
StringRef Name;
uint64_t Address;
SymbolRef::Type Type;
diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp
index 803e3f6733..08153ebd04 100644
--- a/tools/llvm-readobj/COFFDumper.cpp
+++ b/tools/llvm-readobj/COFFDumper.cpp
@@ -541,23 +541,15 @@ error_code COFFDumper::getSection(
}
void COFFDumper::cacheRelocations() {
- error_code EC;
for (section_iterator SecI = Obj->begin_sections(),
SecE = Obj->end_sections();
- SecI != SecE; SecI.increment(EC)) {
- if (error(EC))
- break;
-
+ SecI != SecE; ++SecI) {
const coff_section *Section = Obj->getCOFFSection(SecI);
for (relocation_iterator RelI = SecI->begin_relocations(),
RelE = SecI->end_relocations();
- RelI != RelE; RelI.increment(EC)) {
- if (error(EC))
- break;
-
+ RelI != RelE; ++RelI)
RelocMap[Section].push_back(*RelI);
- }
// Sort relocations by address.
std::sort(RelocMap[Section].begin(), RelocMap[Section].end(),
@@ -824,16 +816,11 @@ void COFFDumper::printCodeViewLineTables(section_iterator SecI) {
}
void COFFDumper::printSections() {
- error_code EC;
-
ListScope SectionsD(W, "Sections");
int SectionNumber = 0;
for (section_iterator SecI = Obj->begin_sections(),
SecE = Obj->end_sections();
- SecI != SecE; SecI.increment(EC)) {
- if (error(EC))
- break;
-
+ SecI != SecE; ++SecI) {
++SectionNumber;
const coff_section *Section = Obj->getCOFFSection(SecI);
@@ -860,20 +847,15 @@ void COFFDumper::printSections() {
ListScope D(W, "Relocations");
for (relocation_iterator RelI = SecI->begin_relocations(),
RelE = SecI->end_relocations();
- RelI != RelE; RelI.increment(EC)) {
- if (error(EC)) break;
-
+ RelI != RelE; ++RelI)
printRelocation(SecI, RelI);
- }
}
if (opts::SectionSymbols) {
ListScope D(W, "Symbols");
for (symbol_iterator SymI = Obj->begin_symbols(),
SymE = Obj->end_symbols();
- SymI != SymE; SymI.increment(EC)) {
- if (error(EC)) break;
-
+ SymI != SymE; ++SymI) {
bool Contained = false;
if (SecI->containsSymbol(*SymI, Contained) || !Contained)
continue;
@@ -897,15 +879,11 @@ void COFFDumper::printSections() {
void COFFDumper::printRelocations() {
ListScope D(W, "Relocations");
- error_code EC;
int SectionNumber = 0;
for (section_iterator SecI = Obj->begin_sections(),
SecE = Obj->end_sections();
- SecI != SecE; SecI.increment(EC)) {
+ SecI != SecE; ++SecI) {
++SectionNumber;
- if (error(EC))
- break;
-
StringRef Name;
if (error(SecI->getName(Name)))
continue;
@@ -913,9 +891,7 @@ void COFFDumper::printRelocations() {
bool PrintedGroup = false;
for (relocation_iterator RelI = SecI->begin_relocations(),
RelE = SecI->end_relocations();
- RelI != RelE; RelI.increment(EC)) {
- if (error(EC)) break;
-
+ RelI != RelE; ++RelI) {
if (!PrintedGroup) {
W.startLine() << "Section (" << SectionNumber << ") " << Name << " {\n";
W.indent();
@@ -963,14 +939,9 @@ void COFFDumper::printRelocation(section_iterator SecI,
void COFFDumper::printSymbols() {
ListScope Group(W, "Symbols");
- error_code EC;
- for (symbol_iterator SymI = Obj->begin_symbols(),
- SymE = Obj->end_symbols();
- SymI != SymE; SymI.increment(EC)) {
- if (error(EC)) break;
-
+ for (symbol_iterator SymI = Obj->begin_symbols(), SymE = Obj->end_symbols();
+ SymI != SymE; ++SymI)
printSymbol(SymI);
- }
}
void COFFDumper::printDynamicSymbols() {
@@ -1116,12 +1087,9 @@ void COFFDumper::printUnwindInfo() {
}
void COFFDumper::printX64UnwindInfo() {
- error_code EC;
for (section_iterator SecI = Obj->begin_sections(),
SecE = Obj->end_sections();
- SecI != SecE; SecI.increment(EC)) {
- if (error(EC)) break;
-
+ SecI != SecE; ++SecI) {
StringRef Name;
if (error(SecI->getName(Name)))
continue;
diff --git a/tools/llvm-readobj/MachODumper.cpp b/tools/llvm-readobj/MachODumper.cpp
index 6626f4082f..af76901a3f 100644
--- a/tools/llvm-readobj/MachODumper.cpp
+++ b/tools/llvm-readobj/MachODumper.cpp
@@ -222,12 +222,9 @@ void MachODumper::printSections(const MachOObjectFile *Obj) {
ListScope Group(W, "Sections");
int SectionIndex = -1;
- error_code EC;
for (section_iterator SecI = Obj->begin_sections(),
SecE = Obj->end_sections();
- SecI != SecE; SecI.increment(EC)) {
- if (error(EC)) break;
-
+ SecI != SecE; ++SecI) {
++SectionIndex;
MachOSection Section;
@@ -263,20 +260,15 @@ void MachODumper::printSections(const MachOObjectFile *Obj) {
ListScope D(W, "Relocations");
for (relocation_iterator RelI = SecI->begin_relocations(),
RelE = SecI->end_relocations();
- RelI != RelE; RelI.increment(EC)) {
- if (error(EC)) break;
-
+ RelI != RelE; ++RelI)
printRelocation(SecI, RelI);
- }
}
if (opts::SectionSymbols) {
ListScope D(W, "Symbols");
for (symbol_iterator SymI = Obj->begin_symbols(),
SymE = Obj->end_symbols();
- SymI != SymE; SymI.increment(EC)) {
- if (error(EC)) break;
-
+ SymI != SymE; ++SymI) {
bool Contained = false;
if (SecI->containsSymbol(*SymI, Contained) || !Contained)
continue;
@@ -300,9 +292,7 @@ void MachODumper::printRelocations() {
error_code EC;
for (section_iterator SecI = Obj->begin_sections(),
SecE = Obj->end_sections();
- SecI != SecE; SecI.increment(EC)) {
- if (error(EC)) break;
-
+ SecI != SecE; ++SecI) {
StringRef Name;
if (error(SecI->getName(Name)))
continue;
@@ -310,9 +300,7 @@ void MachODumper::printRelocations() {
bool PrintedGroup = false;
for (relocation_iterator RelI = SecI->begin_relocations(),
RelE = SecI->end_relocations();
- RelI != RelE; RelI.increment(EC)) {
- if (error(EC)) break;
-
+ RelI != RelE; ++RelI) {
if (!PrintedGroup) {
W.startLine() << "Section " << Name << " {\n";
W.indent();
@@ -382,12 +370,8 @@ void MachODumper::printRelocation(const MachOObjectFile *Obj,
void MachODumper::printSymbols() {
ListScope Group(W, "Symbols");
- error_code EC;
- for (symbol_iterator SymI = Obj->begin_symbols(),
- SymE = Obj->end_symbols();
- SymI != SymE; SymI.increment(EC)) {
- if (error(EC)) break;
-
+ for (symbol_iterator SymI = Obj->begin_symbols(), SymE = Obj->end_symbols();
+ SymI != SymE; ++SymI) {
printSymbol(SymI);
}
}
diff --git a/tools/llvm-rtdyld/llvm-rtdyld.cpp b/tools/llvm-rtdyld/llvm-rtdyld.cpp
index 531595eacd..65c0ab7255 100644
--- a/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -151,11 +151,9 @@ static int printLineInfoForInput() {
OwningPtr<DIContext> Context(DIContext::getDWARFContext(LoadedObject->getObjectFile()));
// Use symbol info to iterate functions in the object.
- error_code ec;
for (object::symbol_iterator I = LoadedObject->begin_symbols(),
E = LoadedObject->end_symbols();
- I != E && !ec;
- I.increment(ec)) {
+ I != E; ++I) {
object::SymbolRef::Type SymType;
if (I->getType(SymType)) continue;
if (SymType == object::SymbolRef::ST_Function) {
diff --git a/tools/llvm-size/llvm-size.cpp b/tools/llvm-size/llvm-size.cpp
index ead853e16a..f46bf6b4a2 100644
--- a/tools/llvm-size/llvm-size.cpp
+++ b/tools/llvm-size/llvm-size.cpp
@@ -111,12 +111,8 @@ static void PrintObjectSectionSizes(ObjectFile *o) {
std::size_t max_name_len = strlen("section");
std::size_t max_size_len = strlen("size");
std::size_t max_addr_len = strlen("addr");
- error_code ec;
- for (section_iterator i = o->begin_sections(),
- e = o->end_sections(); i != e;
- i.increment(ec)) {
- if (error(ec))
- return;
+ for (section_iterator i = o->begin_sections(), e = o->end_sections();
+ i != e; ++i) {
uint64_t size = 0;
if (error(i->getSize(size)))
return;
@@ -154,12 +150,8 @@ static void PrintObjectSectionSizes(ObjectFile *o) {
<< "%#" << max_addr_len << radix_fmt << "\n";
// Print each section.
- for (section_iterator i = o->begin_sections(),
- e = o->end_sections(); i != e;
- i.increment(ec)) {
- if (error(ec))
- return;
-
+ for (section_iterator i = o->begin_sections(), e = o->end_sections();
+ i != e; ++i) {
StringRef name;
uint64_t size = 0;
uint64_t addr = 0;
@@ -189,13 +181,8 @@ static void PrintObjectSectionSizes(ObjectFile *o) {
uint64_t total_bss = 0;
// Make one pass over the section table to calculate sizes.
- error_code ec;
- for (section_iterator i = o->begin_sections(),
- e = o->end_sections(); i != e;
- i.increment(ec)) {
- if (error(ec))
- return;
-
+ for (section_iterator i = o->begin_sections(), e = o->end_sections();
+ i != e; ++i) {
uint64_t size = 0;
bool isText = false;
bool isData = false;
diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp
index 71588e171f..4075199857 100644
--- a/tools/llvm-symbolizer/LLVMSymbolize.cpp
+++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp
@@ -52,11 +52,8 @@ static void patchFunctionNameInDILineInfo(const std::string &NewFunctionName,
ModuleInfo::ModuleInfo(ObjectFile *Obj, DIContext *DICtx)
: Module(Obj), DebugInfoContext(DICtx) {
- error_code ec;
for (symbol_iterator si = Module->begin_symbols(), se = Module->end_symbols();
- si != se; si.increment(ec)) {
- if (error(ec))
- return;
+ si != se; ++si) {
SymbolRef::Type SymbolType;
if (error(si->getType(SymbolType)))
continue;
@@ -268,9 +265,8 @@ static bool getGNUDebuglinkContents(const Binary *Bin, std::string &DebugName,
const ObjectFile *Obj = dyn_cast<ObjectFile>(Bin);
if (!Obj)
return false;
- error_code EC;
for (section_iterator I = Obj->begin_sections(), E = Obj->end_sections();
- I != E; I.increment(EC)) {
+ I != E; ++I) {
StringRef Name;
I->getName(Name);
Name = Name.substr(Name.find_first_not_of("._"));
diff --git a/tools/macho-dump/macho-dump.cpp b/tools/macho-dump/macho-dump.cpp
index 4e7a0b875f..f2f4b8c70f 100644
--- a/tools/macho-dump/macho-dump.cpp
+++ b/tools/macho-dump/macho-dump.cpp
@@ -96,9 +96,9 @@ static int DumpSectionData(const MachOObjectFile &Obj, unsigned Index,
// Dump the relocation entries.
outs() << " ('_relocations', [\n";
unsigned RelNum = 0;
- error_code EC;
for (relocation_iterator I = Obj.section_rel_begin(Index),
- E = Obj.section_rel_end(Index); I != E; I.increment(EC), ++RelNum) {
+ E = Obj.section_rel_end(Index);
+ I != E; ++I, ++RelNum) {
MachO::any_relocation_info RE = Obj.getRelocation(I->getRawDataRefImpl());
outs() << " # Relocation " << RelNum << "\n";
outs() << " (('word-0', " << format("0x%x", RE.r_word0) << "),\n";
@@ -201,10 +201,9 @@ static int DumpSymtabCommand(const MachOObjectFile &Obj) {
// Dump the symbol table.
outs() << " ('_symbols', [\n";
- error_code EC;
unsigned SymNum = 0;
for (symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E;
- I.increment(EC), ++SymNum) {
+ ++I, ++SymNum) {
DataRefImpl DRI = I->getRawDataRefImpl();
if (Obj.is64Bit()) {
MachO::nlist_64 STE = Obj.getSymbol64TableEntry(DRI);
diff --git a/tools/obj2yaml/coff2yaml.cpp b/tools/obj2yaml/coff2yaml.cpp
index 02d7ebf774..47ccfb7700 100644
--- a/tools/obj2yaml/coff2yaml.cpp
+++ b/tools/obj2yaml/coff2yaml.cpp
@@ -51,10 +51,8 @@ void COFFDumper::dumpHeader(const object::coff_file_header *Header) {
void COFFDumper::dumpSections(unsigned NumSections) {
std::vector<COFFYAML::Section> &Sections = YAMLObj.Sections;
- error_code ec;
for (object::section_iterator iter = Obj.begin_sections();
- iter != Obj.end_sections(); iter.increment(ec)) {
- check(ec);
+ iter != Obj.end_sections(); ++iter) {
const object::coff_section *Sect = Obj.getCOFFSection(iter);
COFFYAML::Section Sec;
Sec.Name = Sect->Name; // FIXME: check the null termination!
@@ -68,7 +66,7 @@ void COFFDumper::dumpSections(unsigned NumSections) {
std::vector<COFFYAML::Relocation> Relocations;
for (object::relocation_iterator rIter = iter->begin_relocations();
- rIter != iter->end_relocations(); rIter.increment(ec)) {
+ rIter != iter->end_relocations(); ++rIter) {
const object::coff_relocation *reloc = Obj.getCOFFRelocation(rIter);
COFFYAML::Relocation Rel;
object::symbol_iterator Sym = rIter->getSymbol();
@@ -83,11 +81,9 @@ void COFFDumper::dumpSections(unsigned NumSections) {
}
void COFFDumper::dumpSymbols(unsigned NumSymbols) {
- error_code ec;
std::vector<COFFYAML::Symbol> &Symbols = YAMLObj.Symbols;
for (object::symbol_iterator iter = Obj.begin_symbols();
- iter != Obj.end_symbols(); iter.increment(ec)) {
- check(ec);
+ iter != Obj.end_symbols(); ++iter) {
const object::coff_symbol *Symbol = Obj.getCOFFSymbol(iter);
COFFYAML::Symbol Sym;
Obj.getSymbolName(Symbol, Sym.Name);