diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-30 02:49:50 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-01-30 02:49:50 +0000 |
| commit | 5e812afaeb3db56db706e81e448db46c08298abd (patch) | |
| tree | 86d091fea3f71879287f607d9f616e410866099c /llvm/tools/llvm-size/llvm-size.cpp | |
| parent | 980f2dc4fc9a27fa950f6f9c6baf554aa7cef351 (diff) | |
| download | llvm-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-size/llvm-size.cpp')
| -rw-r--r-- | llvm/tools/llvm-size/llvm-size.cpp | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp index ead853e..f46bf6b 100644 --- a/llvm/tools/llvm-size/llvm-size.cpp +++ b/llvm/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; |
