aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-readobj/MachODumper.cpp
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
commit5e812afaeb3db56db706e81e448db46c08298abd (patch)
tree86d091fea3f71879287f607d9f616e410866099c /llvm/tools/llvm-readobj/MachODumper.cpp
parent980f2dc4fc9a27fa950f6f9c6baf554aa7cef351 (diff)
downloadllvm-5e812afaeb3db56db706e81e448db46c08298abd.zip
llvm-5e812afaeb3db56db706e81e448db46c08298abd.tar.gz
llvm-5e812afaeb3db56db706e81e448db46c08298abd.tar.bz2
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. llvm-svn: 200442
Diffstat (limited to 'llvm/tools/llvm-readobj/MachODumper.cpp')
-rw-r--r--llvm/tools/llvm-readobj/MachODumper.cpp30
1 files changed, 7 insertions, 23 deletions
diff --git a/llvm/tools/llvm-readobj/MachODumper.cpp b/llvm/tools/llvm-readobj/MachODumper.cpp
index 6626f40..af76901 100644
--- a/llvm/tools/llvm-readobj/MachODumper.cpp
+++ b/llvm/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);
}
}