diff options
author | Alexey Samsonov <samsonov@google.com> | 2014-03-13 14:37:36 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2014-03-13 14:37:36 +0000 |
commit | 7a2da95e44b5f537323d4fedcacf6378a8682b7d (patch) | |
tree | 504c793b5bf3ecdd8c94b0be5c17b191049bc786 /tools/llvm-size | |
parent | b920dfe02b4fb88bafa64ab85800c00faba47f5d (diff) | |
download | llvm-7a2da95e44b5f537323d4fedcacf6378a8682b7d.tar.gz llvm-7a2da95e44b5f537323d4fedcacf6378a8682b7d.tar.bz2 llvm-7a2da95e44b5f537323d4fedcacf6378a8682b7d.tar.xz |
[C++11] Use ObjectFile::sections() in commandline llvm tools
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203802 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-size')
-rw-r--r-- | tools/llvm-size/llvm-size.cpp | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/tools/llvm-size/llvm-size.cpp b/tools/llvm-size/llvm-size.cpp index 89528dc8b4..d1bd45a36b 100644 --- a/tools/llvm-size/llvm-size.cpp +++ b/tools/llvm-size/llvm-size.cpp @@ -85,10 +85,10 @@ static size_t getNumLengthAsString(uint64_t num) { return result.size(); } -/// @brief Print the size of each section in @p o. +/// @brief Print the size of each section in @p Obj. /// /// The format used is determined by @c OutputFormat and @c Radix. -static void PrintObjectSectionSizes(ObjectFile *o) { +static void PrintObjectSectionSizes(ObjectFile *Obj) { uint64_t total = 0; std::string fmtbuf; raw_string_ostream fmt(fmtbuf); @@ -111,17 +111,18 @@ 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"); - for (section_iterator i = o->section_begin(), e = o->section_end(); - i != e; ++i) { + for (const SectionRef &Section : Obj->sections()) { uint64_t size = 0; - if (error(i->getSize(size))) + if (error(Section.getSize(size))) return; total += size; StringRef name; uint64_t addr = 0; - if (error(i->getName(name))) return; - if (error(i->getAddress(addr))) return; + if (error(Section.getName(name))) + return; + if (error(Section.getAddress(addr))) + return; max_name_len = std::max(max_name_len, name.size()); max_size_len = std::max(max_size_len, getNumLengthAsString(size)); max_addr_len = std::max(max_addr_len, getNumLengthAsString(addr)); @@ -150,20 +151,19 @@ static void PrintObjectSectionSizes(ObjectFile *o) { << "%#" << max_addr_len << radix_fmt << "\n"; // Print each section. - for (section_iterator i = o->section_begin(), e = o->section_end(); - i != e; ++i) { + for (const SectionRef &Section : Obj->sections()) { StringRef name; uint64_t size = 0; uint64_t addr = 0; - if (error(i->getName(name))) return; - if (error(i->getSize(size))) return; - if (error(i->getAddress(addr))) return; + if (error(Section.getName(name))) + return; + if (error(Section.getSize(size))) + return; + if (error(Section.getAddress(addr))) + return; std::string namestr = name; - outs() << format(fmt.str().c_str(), - namestr.c_str(), - size, - addr); + outs() << format(fmt.str().c_str(), namestr.c_str(), size, addr); } // Print total. @@ -181,16 +181,19 @@ static void PrintObjectSectionSizes(ObjectFile *o) { uint64_t total_bss = 0; // Make one pass over the section table to calculate sizes. - for (section_iterator i = o->section_begin(), e = o->section_end(); - i != e; ++i) { + for (const SectionRef &Section : Obj->sections()) { uint64_t size = 0; bool isText = false; bool isData = false; bool isBSS = false; - if (error(i->getSize(size))) return; - if (error(i->isText(isText))) return; - if (error(i->isData(isData))) return; - if (error(i->isBSS(isBSS))) return; + if (error(Section.getSize(size))) + return; + if (error(Section.isText(isText))) + return; + if (error(Section.isData(isData))) + return; + if (error(Section.isBSS(isBSS))) + return; if (isText) total_text += size; else if (isData) |