From 1ad45020ec8518a5c9bea7ec1007798a456bff56 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 13 Jun 2014 03:07:50 +0000 Subject: Remove 'using std::error_code' from tools. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210876 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-readobj/COFFDumper.cpp | 56 +++++++++++++++++++----------------- tools/llvm-readobj/ELFDumper.cpp | 12 ++++---- tools/llvm-readobj/MachODumper.cpp | 9 +++--- tools/llvm-readobj/Win64EHDumper.cpp | 18 ++++++------ tools/llvm-readobj/llvm-readobj.cpp | 16 +++++------ 5 files changed, 55 insertions(+), 56 deletions(-) (limited to 'tools/llvm-readobj') diff --git a/tools/llvm-readobj/COFFDumper.cpp b/tools/llvm-readobj/COFFDumper.cpp index 0a14c42fe3..8b0dcb3e2c 100644 --- a/tools/llvm-readobj/COFFDumper.cpp +++ b/tools/llvm-readobj/COFFDumper.cpp @@ -38,7 +38,6 @@ using namespace llvm; using namespace llvm::object; using namespace llvm::Win64EH; -using std::error_code; namespace { @@ -70,10 +69,10 @@ private: void cacheRelocations(); - error_code resolveSymbol(const coff_section *Section, uint64_t Offset, - SymbolRef &Sym); - error_code resolveSymbolName(const coff_section *Section, uint64_t Offset, - StringRef &Name); + std::error_code resolveSymbol(const coff_section *Section, uint64_t Offset, + SymbolRef &Sym); + std::error_code resolveSymbolName(const coff_section *Section, + uint64_t Offset, StringRef &Name); typedef DenseMap > RelocMapTy; @@ -86,8 +85,9 @@ private: namespace llvm { -error_code createCOFFDumper(const object::ObjectFile *Obj, StreamWriter &Writer, - std::unique_ptr &Result) { +std::error_code createCOFFDumper(const object::ObjectFile *Obj, + StreamWriter &Writer, + std::unique_ptr &Result) { const COFFObjectFile *COFFObj = dyn_cast(Obj); if (!COFFObj) return readobj_error::unsupported_obj_file_format; @@ -100,12 +100,12 @@ error_code createCOFFDumper(const object::ObjectFile *Obj, StreamWriter &Writer, // Given a a section and an offset into this section the function returns the // symbol used for the relocation at the offset. -error_code COFFDumper::resolveSymbol(const coff_section *Section, - uint64_t Offset, SymbolRef &Sym) { +std::error_code COFFDumper::resolveSymbol(const coff_section *Section, + uint64_t Offset, SymbolRef &Sym) { const auto &Relocations = RelocMap[Section]; for (const auto &Relocation : Relocations) { uint64_t RelocationOffset; - if (error_code EC = Relocation.getOffset(RelocationOffset)) + if (std::error_code EC = Relocation.getOffset(RelocationOffset)) return EC; if (RelocationOffset == Offset) { @@ -118,12 +118,13 @@ error_code COFFDumper::resolveSymbol(const coff_section *Section, // Given a section and an offset into this section the function returns the name // of the symbol used for the relocation at the offset. -error_code COFFDumper::resolveSymbolName(const coff_section *Section, - uint64_t Offset, StringRef &Name) { +std::error_code COFFDumper::resolveSymbolName(const coff_section *Section, + uint64_t Offset, + StringRef &Name) { SymbolRef Symbol; - if (error_code EC = resolveSymbol(Section, Offset, Symbol)) + if (std::error_code EC = resolveSymbol(Section, Offset, Symbol)) return EC; - if (error_code EC = Symbol.getName(Name)) + if (std::error_code EC = Symbol.getName(Name)) return EC; return object_error::success; } @@ -308,9 +309,10 @@ WeakExternalCharacteristics[] = { { "Alias" , COFF::IMAGE_WEAK_EXTERN_SEARCH_ALIAS } }; -template -static error_code getSymbolAuxData(const COFFObjectFile *Obj, - const coff_symbol *Symbol, const T* &Aux) { +template +static std::error_code getSymbolAuxData(const COFFObjectFile *Obj, + const coff_symbol *Symbol, + const T *&Aux) { ArrayRef AuxData = Obj->getSymbolAuxData(Symbol); Aux = reinterpret_cast(AuxData.data()); return readobj_error::success; @@ -720,7 +722,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) { const coff_symbol *Symbol = Obj->getCOFFSymbol(Sym); const coff_section *Section; - if (error_code EC = Obj->getSection(Symbol->SectionNumber, Section)) { + if (std::error_code EC = Obj->getSection(Symbol->SectionNumber, Section)) { W.startLine() << "Invalid section number: " << EC.message() << "\n"; W.flush(); return; @@ -764,7 +766,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) { const coff_symbol *Linked; StringRef LinkedName; - error_code EC; + std::error_code EC; if ((EC = Obj->getSymbol(Aux->TagIndex, Linked)) || (EC = Obj->getSymbolName(Linked, LinkedName))) { LinkedName = ""; @@ -806,7 +808,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) { && Aux->Selection == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE) { const coff_section *Assoc; StringRef AssocName; - error_code EC; + std::error_code EC; if ((EC = Obj->getSection(Aux->Number, Assoc)) || (EC = Obj->getSectionName(Assoc, AssocName))) { AssocName = ""; @@ -822,7 +824,7 @@ void COFFDumper::printSymbol(const SymbolRef &Sym) { const coff_symbol *ReferredSym; StringRef ReferredName; - error_code EC; + std::error_code EC; if ((EC = Obj->getSymbol(Aux->SymbolTableIndex, ReferredSym)) || (EC = Obj->getSymbolName(ReferredSym, ReferredName))) { ReferredName = ""; @@ -850,12 +852,12 @@ void COFFDumper::printUnwindInfo() { switch (Header->Machine) { case COFF::IMAGE_FILE_MACHINE_AMD64: { Win64EH::Dumper Dumper(W); - Win64EH::Dumper::SymbolResolver Resolver = - [](const object::coff_section *Section, uint64_t Offset, - SymbolRef &Symbol, void *user_data) -> error_code { - COFFDumper *Dumper = reinterpret_cast(user_data); - return Dumper->resolveSymbol(Section, Offset, Symbol); - }; + Win64EH::Dumper::SymbolResolver + Resolver = [](const object::coff_section *Section, uint64_t Offset, + SymbolRef &Symbol, void *user_data) -> std::error_code { + COFFDumper *Dumper = reinterpret_cast(user_data); + return Dumper->resolveSymbol(Section, Offset, Symbol); + }; Win64EH::Dumper::Context Ctx(*Obj, Resolver, this); Dumper.printData(Ctx); break; diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 8ec59bec00..f13b300d6d 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -30,7 +30,6 @@ using namespace llvm; using namespace llvm::object; using namespace ELF; -using std::error_code; #define LLVM_READOBJ_ENUM_CASE(ns, enum) \ case ns::enum: return #enum; @@ -82,15 +81,16 @@ template T errorOrDefault(ErrorOr Val, T Default = T()) { namespace llvm { template -static error_code createELFDumper(const ELFFile *Obj, - StreamWriter &Writer, - std::unique_ptr &Result) { +static std::error_code createELFDumper(const ELFFile *Obj, + StreamWriter &Writer, + std::unique_ptr &Result) { Result.reset(new ELFDumper(Obj, Writer)); return readobj_error::success; } -error_code createELFDumper(const object::ObjectFile *Obj, StreamWriter &Writer, - std::unique_ptr &Result) { +std::error_code createELFDumper(const object::ObjectFile *Obj, + StreamWriter &Writer, + std::unique_ptr &Result) { // Little-endian 32-bit if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) return createELFDumper(ELFObj->getELFFile(), Writer, Result); diff --git a/tools/llvm-readobj/MachODumper.cpp b/tools/llvm-readobj/MachODumper.cpp index 0c31bec993..d168030a27 100644 --- a/tools/llvm-readobj/MachODumper.cpp +++ b/tools/llvm-readobj/MachODumper.cpp @@ -21,7 +21,6 @@ using namespace llvm; using namespace object; -using std::error_code; namespace { @@ -55,9 +54,9 @@ private: namespace llvm { -error_code createMachODumper(const object::ObjectFile *Obj, - StreamWriter &Writer, - std::unique_ptr &Result) { +std::error_code createMachODumper(const object::ObjectFile *Obj, + StreamWriter &Writer, + std::unique_ptr &Result) { const MachOObjectFile *MachOObj = dyn_cast(Obj); if (!MachOObj) return readobj_error::unsupported_obj_file_format; @@ -278,7 +277,7 @@ void MachODumper::printSections(const MachOObjectFile *Obj) { void MachODumper::printRelocations() { ListScope D(W, "Relocations"); - error_code EC; + std::error_code EC; for (const SectionRef &Section : Obj->sections()) { StringRef Name; if (error(Section.getName(Name))) diff --git a/tools/llvm-readobj/Win64EHDumper.cpp b/tools/llvm-readobj/Win64EHDumper.cpp index f3749fc36c..f058632a8c 100644 --- a/tools/llvm-readobj/Win64EHDumper.cpp +++ b/tools/llvm-readobj/Win64EHDumper.cpp @@ -16,7 +16,6 @@ using namespace llvm; using namespace llvm::object; using namespace llvm::Win64EH; -using std::error_code; static const EnumEntry UnwindFlags[] = { { "ExceptionHandler", UNW_ExceptionHandler }, @@ -135,20 +134,21 @@ static std::string formatSymbol(const Dumper::Context &Ctx, return OS.str(); } -static error_code resolveRelocation(const Dumper::Context &Ctx, - const coff_section *Section, - uint64_t Offset, - const coff_section *&ResolvedSection, - uint64_t &ResolvedAddress) { +static std::error_code resolveRelocation(const Dumper::Context &Ctx, + const coff_section *Section, + uint64_t Offset, + const coff_section *&ResolvedSection, + uint64_t &ResolvedAddress) { SymbolRef Symbol; - if (error_code EC = Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData)) + if (std::error_code EC = + Ctx.ResolveSymbol(Section, Offset, Symbol, Ctx.UserData)) return EC; - if (error_code EC = Symbol.getAddress(ResolvedAddress)) + if (std::error_code EC = Symbol.getAddress(ResolvedAddress)) return EC; section_iterator SI = Ctx.COFF.section_begin(); - if (error_code EC = Symbol.getSection(SI)) + if (std::error_code EC = Symbol.getSection(SI)) return EC; ResolvedSection = Ctx.COFF.getCOFFSection(*SI); diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp index 70af4dc4cb..d66c02f413 100644 --- a/tools/llvm-readobj/llvm-readobj.cpp +++ b/tools/llvm-readobj/llvm-readobj.cpp @@ -41,7 +41,6 @@ using namespace llvm; using namespace llvm::object; -using std::error_code; namespace opts { cl::list InputFilenames(cl::Positional, @@ -142,7 +141,7 @@ static int ReturnValue = EXIT_SUCCESS; namespace llvm { -bool error(error_code EC) { +bool error(std::error_code EC) { if (!EC) return false; @@ -161,8 +160,7 @@ bool relocAddressLess(RelocationRef a, RelocationRef b) { } // namespace llvm - -static void reportError(StringRef Input, error_code EC) { +static void reportError(StringRef Input, std::error_code EC) { if (Input == "-") Input = ""; @@ -180,8 +178,8 @@ static void reportError(StringRef Input, StringRef Message) { } /// @brief Creates an format-specific object file dumper. -static error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer, - std::unique_ptr &Result) { +static std::error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer, + std::unique_ptr &Result) { if (!Obj) return readobj_error::unsupported_file_format; @@ -200,7 +198,7 @@ static error_code createDumper(const ObjectFile *Obj, StreamWriter &Writer, static void dumpObject(const ObjectFile *Obj) { StreamWriter Writer(outs()); std::unique_ptr Dumper; - if (error_code EC = createDumper(Obj, Writer, Dumper)) { + if (std::error_code EC = createDumper(Obj, Writer, Dumper)) { reportError(Obj->getFileName(), EC); return; } @@ -245,7 +243,7 @@ static void dumpArchive(const Archive *Arc) { ArcE = Arc->child_end(); ArcI != ArcE; ++ArcI) { std::unique_ptr child; - if (error_code EC = ArcI->getAsBinary(child)) { + if (std::error_code EC = ArcI->getAsBinary(child)) { // Ignore non-object files. if (EC != object_error::invalid_file_type) reportError(Arc->getFileName(), EC.message()); @@ -270,7 +268,7 @@ static void dumpInput(StringRef File) { // Attempt to open the binary. ErrorOr BinaryOrErr = createBinary(File); - if (error_code EC = BinaryOrErr.getError()) { + if (std::error_code EC = BinaryOrErr.getError()) { reportError(File, EC); return; } -- cgit v1.2.3