From 802912743ef73ea794cb3c66a8cb2211735a12c3 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 8 Oct 2014 15:28:58 +0000 Subject: 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 --- llvm/tools/llvm-objdump/llvm-objdump.cpp | 46 +++++++++----------------------- 1 file changed, 12 insertions(+), 34 deletions(-) (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp') diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 4c753da7bf4..2d1c86c618c 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -307,25 +307,17 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) { } for (const SectionRef &Section : Obj->sections()) { - bool Text; - if (error(Section.isText(Text))) - break; + bool Text = Section.isText(); if (!Text) continue; - uint64_t SectionAddr; - if (error(Section.getAddress(SectionAddr))) - break; - - uint64_t SectSize; - if (error(Section.getSize(SectSize))) - break; + uint64_t SectionAddr = Section.getAddress(); + uint64_t SectSize = Section.getSize(); // Make a list of all the symbols in this section. std::vector> Symbols; for (const SymbolRef &Symbol : Obj->symbols()) { - bool contains; - if (!error(Section.containsSymbol(Symbol, contains)) && contains) { + if (Section.containsSymbol(Symbol)) { uint64_t Address; if (error(Symbol.getAddress(Address))) break; @@ -501,19 +493,11 @@ static void PrintSectionHeaders(const ObjectFile *Obj) { StringRef Name; if (error(Section.getName(Name))) return; - uint64_t Address; - if (error(Section.getAddress(Address))) - return; - uint64_t Size; - if (error(Section.getSize(Size))) - return; - bool Text, Data, BSS; - if (error(Section.isText(Text))) - return; - if (error(Section.isData(Data))) - return; - if (error(Section.isBSS(BSS))) - return; + uint64_t Address = Section.getAddress(); + uint64_t Size = Section.getSize(); + bool Text = Section.isText(); + bool Data = Section.isData(); + bool BSS = Section.isBSS(); std::string Type = (std::string(Text ? "TEXT " : "") + (Data ? "DATA " : "") + (BSS ? "BSS" : "")); outs() << format("%3d %-13s %08" PRIx64 " %016" PRIx64 " %s\n", i, @@ -527,20 +511,14 @@ static void PrintSectionContents(const ObjectFile *Obj) { for (const SectionRef &Section : Obj->sections()) { StringRef Name; StringRef Contents; - uint64_t BaseAddr; - bool BSS; if (error(Section.getName(Name))) continue; - if (error(Section.getAddress(BaseAddr))) - continue; - if (error(Section.isBSS(BSS))) - continue; + uint64_t BaseAddr = Section.getAddress(); + bool BSS = Section.isBSS(); outs() << "Contents of section " << Name << ":\n"; if (BSS) { - uint64_t Size; - if (error(Section.getSize(Size))) - continue; + uint64_t Size = Section.getSize(); outs() << format("\n", BaseAddr, BaseAddr + Size); -- cgit v1.2.3