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
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp
index 9a56bf9..325e700 100644
--- a/llvm/tools/llvm-objdump/llvm-objdump.cpp
+++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp
@@ -387,18 +387,14 @@
   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 @@
     // 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 @@
            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 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 @@
     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 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 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 @@
   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;