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-symbolizer/LLVMSymbolize.cpp b/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp
index 71588e1..4075199 100644
--- a/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp
+++ b/llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp
@@ -52,11 +52,8 @@
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 @@
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("._"));