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/obj2yaml/coff2yaml.cpp | 5 ++-- tools/obj2yaml/elf2yaml.cpp | 69 ++++++++++++++++++++++---------------------- tools/obj2yaml/obj2yaml.cpp | 9 +++--- 3 files changed, 41 insertions(+), 42 deletions(-) (limited to 'tools/obj2yaml') diff --git a/tools/obj2yaml/coff2yaml.cpp b/tools/obj2yaml/coff2yaml.cpp index 816f9e65cd..48462f69fc 100644 --- a/tools/obj2yaml/coff2yaml.cpp +++ b/tools/obj2yaml/coff2yaml.cpp @@ -14,7 +14,6 @@ #include "llvm/Support/YAMLTraits.h" using namespace llvm; -using std::error_code; namespace { @@ -32,7 +31,7 @@ public: } -static void check(error_code ec) { +static void check(std::error_code ec) { if (ec) report_fatal_error(ec.message()); } @@ -211,7 +210,7 @@ COFFYAML::Object &COFFDumper::getYAMLObj() { return YAMLObj; } -error_code coff2yaml(raw_ostream &Out, const object::COFFObjectFile &Obj) { +std::error_code coff2yaml(raw_ostream &Out, const object::COFFObjectFile &Obj) { COFFDumper Dumper(Obj); yaml::Output Yout(Out); diff --git a/tools/obj2yaml/elf2yaml.cpp b/tools/obj2yaml/elf2yaml.cpp index a20ad6f3e2..c817e1526d 100644 --- a/tools/obj2yaml/elf2yaml.cpp +++ b/tools/obj2yaml/elf2yaml.cpp @@ -16,7 +16,6 @@ #include "llvm/Support/YAMLTraits.h" using namespace llvm; -using std::error_code; namespace { @@ -27,13 +26,13 @@ class ELFDumper { const object::ELFFile &Obj; - error_code dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S); - error_code dumpCommonSection(const Elf_Shdr *Shdr, ELFYAML::Section &S); - error_code dumpCommonRelocationSection(const Elf_Shdr *Shdr, - ELFYAML::RelocationSection &S); + std::error_code dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S); + std::error_code dumpCommonSection(const Elf_Shdr *Shdr, ELFYAML::Section &S); + std::error_code dumpCommonRelocationSection(const Elf_Shdr *Shdr, + ELFYAML::RelocationSection &S); template - error_code dumpRelocation(const Elf_Shdr *Shdr, const RelT *Rel, - ELFYAML::Relocation &R); + std::error_code dumpRelocation(const Elf_Shdr *Shdr, const RelT *Rel, + ELFYAML::Relocation &R); ErrorOr dumpRelSection(const Elf_Shdr *Shdr); ErrorOr dumpRelaSection(const Elf_Shdr *Shdr); @@ -75,14 +74,14 @@ ErrorOr ELFDumper::dump() { break; case ELF::SHT_RELA: { ErrorOr S = dumpRelaSection(&Sec); - if (error_code EC = S.getError()) + if (std::error_code EC = S.getError()) return EC; Y->Sections.push_back(std::unique_ptr(S.get())); break; } case ELF::SHT_REL: { ErrorOr S = dumpRelSection(&Sec); - if (error_code EC = S.getError()) + if (std::error_code EC = S.getError()) return EC; Y->Sections.push_back(std::unique_ptr(S.get())); break; @@ -90,7 +89,7 @@ ErrorOr ELFDumper::dump() { // FIXME: Support SHT_GROUP section format. default: { ErrorOr S = dumpContentSection(&Sec); - if (error_code EC = S.getError()) + if (std::error_code EC = S.getError()) return EC; Y->Sections.push_back(std::unique_ptr(S.get())); } @@ -106,7 +105,7 @@ ErrorOr ELFDumper::dump() { } ELFYAML::Symbol S; - if (error_code EC = ELFDumper::dumpSymbol(SI, S)) + if (std::error_code EC = ELFDumper::dumpSymbol(SI, S)) return EC; switch (SI->getBinding()) @@ -129,14 +128,15 @@ ErrorOr ELFDumper::dump() { } template -error_code ELFDumper::dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S) { +std::error_code ELFDumper::dumpSymbol(Elf_Sym_Iter Sym, + ELFYAML::Symbol &S) { S.Type = Sym->getType(); S.Value = Sym->st_value; S.Size = Sym->st_size; S.Visibility = Sym->st_other & 0x3; ErrorOr NameOrErr = Obj.getSymbolName(Sym); - if (error_code EC = NameOrErr.getError()) + if (std::error_code EC = NameOrErr.getError()) return EC; S.Name = NameOrErr.get(); @@ -145,7 +145,7 @@ error_code ELFDumper::dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S) { return obj2yaml_error::success; NameOrErr = Obj.getSectionName(Shdr); - if (error_code EC = NameOrErr.getError()) + if (std::error_code EC = NameOrErr.getError()) return EC; S.Section = NameOrErr.get(); @@ -154,9 +154,9 @@ error_code ELFDumper::dumpSymbol(Elf_Sym_Iter Sym, ELFYAML::Symbol &S) { template template -error_code ELFDumper::dumpRelocation(const Elf_Shdr *Shdr, - const RelT *Rel, - ELFYAML::Relocation &R) { +std::error_code ELFDumper::dumpRelocation(const Elf_Shdr *Shdr, + const RelT *Rel, + ELFYAML::Relocation &R) { R.Type = Rel->getType(Obj.isMips64EL()); R.Offset = Rel->r_offset; R.Addend = 0; @@ -167,7 +167,7 @@ error_code ELFDumper::dumpRelocation(const Elf_Shdr *Shdr, ErrorOr NameOrErr = Obj.getSymbolName(NamePair.first, NamePair.second); - if (error_code EC = NameOrErr.getError()) + if (std::error_code EC = NameOrErr.getError()) return EC; R.Symbol = NameOrErr.get(); @@ -175,22 +175,22 @@ error_code ELFDumper::dumpRelocation(const Elf_Shdr *Shdr, } template -error_code ELFDumper::dumpCommonSection(const Elf_Shdr *Shdr, - ELFYAML::Section &S) { +std::error_code ELFDumper::dumpCommonSection(const Elf_Shdr *Shdr, + ELFYAML::Section &S) { S.Type = Shdr->sh_type; S.Flags = Shdr->sh_flags; S.Address = Shdr->sh_addr; S.AddressAlign = Shdr->sh_addralign; ErrorOr NameOrErr = Obj.getSectionName(Shdr); - if (error_code EC = NameOrErr.getError()) + if (std::error_code EC = NameOrErr.getError()) return EC; S.Name = NameOrErr.get(); if (Shdr->sh_link != ELF::SHN_UNDEF) { if (const Elf_Shdr *LinkSection = Obj.getSection(Shdr->sh_link)) { NameOrErr = Obj.getSectionName(LinkSection); - if (error_code EC = NameOrErr.getError()) + if (std::error_code EC = NameOrErr.getError()) return EC; S.Link = NameOrErr.get(); } @@ -200,15 +200,15 @@ error_code ELFDumper::dumpCommonSection(const Elf_Shdr *Shdr, } template -error_code +std::error_code ELFDumper::dumpCommonRelocationSection(const Elf_Shdr *Shdr, ELFYAML::RelocationSection &S) { - if (error_code EC = dumpCommonSection(Shdr, S)) + if (std::error_code EC = dumpCommonSection(Shdr, S)) return EC; if (const Elf_Shdr *InfoSection = Obj.getSection(Shdr->sh_info)) { ErrorOr NameOrErr = Obj.getSectionName(InfoSection); - if (error_code EC = NameOrErr.getError()) + if (std::error_code EC = NameOrErr.getError()) return EC; S.Info = NameOrErr.get(); } @@ -222,13 +222,13 @@ ELFDumper::dumpRelSection(const Elf_Shdr *Shdr) { assert(Shdr->sh_type == ELF::SHT_REL && "Section type is not SHT_REL"); auto S = make_unique(); - if (error_code EC = dumpCommonRelocationSection(Shdr, *S)) + if (std::error_code EC = dumpCommonRelocationSection(Shdr, *S)) return EC; for (auto RI = Obj.begin_rel(Shdr), RE = Obj.end_rel(Shdr); RI != RE; ++RI) { ELFYAML::Relocation R; - if (error_code EC = dumpRelocation(Shdr, &*RI, R)) + if (std::error_code EC = dumpRelocation(Shdr, &*RI, R)) return EC; S->Relocations.push_back(R); } @@ -242,13 +242,13 @@ ELFDumper::dumpRelaSection(const Elf_Shdr *Shdr) { assert(Shdr->sh_type == ELF::SHT_RELA && "Section type is not SHT_RELA"); auto S = make_unique(); - if (error_code EC = dumpCommonRelocationSection(Shdr, *S)) + if (std::error_code EC = dumpCommonRelocationSection(Shdr, *S)) return EC; for (auto RI = Obj.begin_rela(Shdr), RE = Obj.end_rela(Shdr); RI != RE; ++RI) { ELFYAML::Relocation R; - if (error_code EC = dumpRelocation(Shdr, &*RI, R)) + if (std::error_code EC = dumpRelocation(Shdr, &*RI, R)) return EC; R.Addend = RI->r_addend; S->Relocations.push_back(R); @@ -262,11 +262,11 @@ ErrorOr ELFDumper::dumpContentSection(const Elf_Shdr *Shdr) { auto S = make_unique(); - if (error_code EC = dumpCommonSection(Shdr, *S)) + if (std::error_code EC = dumpCommonSection(Shdr, *S)) return EC; ErrorOr> ContentOrErr = Obj.getSectionContents(Shdr); - if (error_code EC = ContentOrErr.getError()) + if (std::error_code EC = ContentOrErr.getError()) return EC; S->Content = object::yaml::BinaryRef(ContentOrErr.get()); S->Size = S->Content.binary_size(); @@ -275,10 +275,11 @@ ELFDumper::dumpContentSection(const Elf_Shdr *Shdr) { } template -static error_code elf2yaml(raw_ostream &Out, const object::ELFFile &Obj) { +static std::error_code elf2yaml(raw_ostream &Out, + const object::ELFFile &Obj) { ELFDumper Dumper(Obj); ErrorOr YAMLOrErr = Dumper.dump(); - if (error_code EC = YAMLOrErr.getError()) + if (std::error_code EC = YAMLOrErr.getError()) return EC; std::unique_ptr YAML(YAMLOrErr.get()); @@ -288,7 +289,7 @@ static error_code elf2yaml(raw_ostream &Out, const object::ELFFile &Obj) { return object::object_error::success; } -error_code elf2yaml(raw_ostream &Out, const object::ObjectFile &Obj) { +std::error_code elf2yaml(raw_ostream &Out, const object::ObjectFile &Obj) { if (const auto *ELFObj = dyn_cast(&Obj)) return elf2yaml(Out, *ELFObj->getELFFile()); diff --git a/tools/obj2yaml/obj2yaml.cpp b/tools/obj2yaml/obj2yaml.cpp index 717c68d1c6..944314a923 100644 --- a/tools/obj2yaml/obj2yaml.cpp +++ b/tools/obj2yaml/obj2yaml.cpp @@ -18,9 +18,8 @@ using namespace llvm; using namespace llvm::object; -using std::error_code; -static error_code dumpObject(const ObjectFile &Obj) { +static std::error_code dumpObject(const ObjectFile &Obj) { if (Obj.isCOFF()) return coff2yaml(outs(), cast(Obj)); if (Obj.isELF()) @@ -29,12 +28,12 @@ static error_code dumpObject(const ObjectFile &Obj) { return obj2yaml_error::unsupported_obj_file_format; } -static error_code dumpInput(StringRef File) { +static std::error_code dumpInput(StringRef File) { if (File != "-" && !sys::fs::exists(File)) return obj2yaml_error::file_not_found; ErrorOr BinaryOrErr = createBinary(File); - if (error_code EC = BinaryOrErr.getError()) + if (std::error_code EC = BinaryOrErr.getError()) return EC; std::unique_ptr Binary(BinaryOrErr.get()); @@ -54,7 +53,7 @@ int main(int argc, char *argv[]) { PrettyStackTraceProgram X(argc, argv); llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - if (error_code EC = dumpInput(InputFilename)) { + if (std::error_code EC = dumpInput(InputFilename)) { errs() << "Error: '" << EC.message() << "'\n"; return 1; } -- cgit v1.2.3