diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-10-08 15:28:58 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-10-08 15:28:58 +0000 |
commit | 802912743ef73ea794cb3c66a8cb2211735a12c3 (patch) | |
tree | 783b34f5407b2fb86acbd48216621d09c45d41dc /llvm/tools/llvm-size/llvm-size.cpp | |
parent | 14fc1c0240930563b8692e8c29c76c9a7fbde32d (diff) | |
download | bcm5719-llvm-802912743ef73ea794cb3c66a8cb2211735a12c3.tar.gz bcm5719-llvm-802912743ef73ea794cb3c66a8cb2211735a12c3.zip |
Remove bogus std::error_code returns form SectionRef.
There are two methods in SectionRef that can fail:
* getName: The index into the string table can be invalid.
* getContents: The section might point to invalid contents.
Every other method will always succeed and returning and std::error_code just
complicates the code. For example, a section can have an invalid alignment,
but if we are able to get to the section structure at all and create a
SectionRef, we will always be able to read that invalid alignment.
llvm-svn: 219314
Diffstat (limited to 'llvm/tools/llvm-size/llvm-size.cpp')
-rw-r--r-- | llvm/tools/llvm-size/llvm-size.cpp | 32 |
1 files changed, 8 insertions, 24 deletions
diff --git a/llvm/tools/llvm-size/llvm-size.cpp b/llvm/tools/llvm-size/llvm-size.cpp index 1e88183df92..59a5f20a9c7 100644 --- a/llvm/tools/llvm-size/llvm-size.cpp +++ b/llvm/tools/llvm-size/llvm-size.cpp @@ -297,17 +297,13 @@ static void PrintObjectSectionSizes(ObjectFile *Obj) { std::size_t max_size_len = strlen("size"); std::size_t max_addr_len = strlen("addr"); for (const SectionRef &Section : Obj->sections()) { - uint64_t size = 0; - if (error(Section.getSize(size))) - return; + uint64_t size = Section.getSize(); total += size; StringRef name; - uint64_t addr = 0; if (error(Section.getName(name))) return; - if (error(Section.getAddress(addr))) - return; + uint64_t addr = Section.getAddress(); 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)); @@ -337,14 +333,10 @@ static void PrintObjectSectionSizes(ObjectFile *Obj) { // Print each section. for (const SectionRef &Section : Obj->sections()) { StringRef name; - uint64_t size = 0; - uint64_t addr = 0; if (error(Section.getName(name))) return; - if (error(Section.getSize(size))) - return; - if (error(Section.getAddress(addr))) - return; + uint64_t size = Section.getSize(); + uint64_t addr = Section.getAddress(); std::string namestr = name; outs() << format(fmt.str().c_str(), namestr.c_str(), size, addr); @@ -365,18 +357,10 @@ static void PrintObjectSectionSizes(ObjectFile *Obj) { // Make one pass over the section table to calculate sizes. for (const SectionRef &Section : Obj->sections()) { - uint64_t size = 0; - bool isText = false; - bool isData = false; - bool isBSS = false; - if (error(Section.getSize(size))) - return; - if (error(Section.isText(isText))) - return; - if (error(Section.isData(isData))) - return; - if (error(Section.isBSS(isBSS))) - return; + uint64_t size = Section.getSize(); + bool isText = Section.isText(); + bool isData = Section.isData(); + bool isBSS = Section.isBSS(); if (isText) total_text += size; else if (isData) |