Skip to content

Commit

Permalink
[obj2yaml] - Cleanup error reporting (remove Error.cpp/.h files)
Browse files Browse the repository at this point in the history
This removes Error.cpp/.h files from obj2yaml.
These files are not needed because we are
using `Error`s instead of error codes widely and do
not need a logic related to obj2yaml specific
error codes anymore.

I had to adjust just a few lines of tool's code
to remove remaining dependencies.

Differential revision: https://reviews.llvm.org/D86536
  • Loading branch information
Georgii Rymar committed Aug 26, 2020
1 parent 8298230 commit 357dc1e
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 137 deletions.
1 change: 0 additions & 1 deletion llvm/tools/obj2yaml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ add_llvm_tool(obj2yaml
minidump2yaml.cpp
xcoff2yaml.cpp
wasm2yaml.cpp
Error.cpp
)
61 changes: 0 additions & 61 deletions llvm/tools/obj2yaml/Error.cpp

This file was deleted.

53 changes: 0 additions & 53 deletions llvm/tools/obj2yaml/Error.h

This file was deleted.

1 change: 0 additions & 1 deletion llvm/tools/obj2yaml/dwarf2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "Error.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h"
Expand Down
8 changes: 4 additions & 4 deletions llvm/tools/obj2yaml/elf2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "Error.h"
#include "obj2yaml.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
Expand Down Expand Up @@ -257,8 +256,9 @@ template <class ELFT> Expected<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
// ABI allows us to have one SHT_SYMTAB_SHNDX for each symbol table.
// We only support having the SHT_SYMTAB_SHNDX for SHT_SYMTAB now.
if (SymTabShndx)
return createStringError(obj2yaml_error::not_implemented,
"multiple SHT_SYMTAB_SHNDX sections are not supported");
return createStringError(
errc::not_supported,
"multiple SHT_SYMTAB_SHNDX sections are not supported");
SymTabShndx = &Sec;
}
}
Expand All @@ -269,7 +269,7 @@ template <class ELFT> Expected<ELFYAML::Object *> ELFDumper<ELFT>::dump() {
if (!SymTab ||
SymTabShndx->sh_link != (unsigned)(SymTab - Sections.begin()))
return createStringError(
obj2yaml_error::not_implemented,
errc::not_supported,
"only SHT_SYMTAB_SHNDX associated with SHT_SYMTAB are supported");

auto TableOrErr = Obj.getSHNDXTable(*SymTabShndx);
Expand Down
19 changes: 5 additions & 14 deletions llvm/tools/obj2yaml/macho2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "Error.h"
#include "obj2yaml.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/Object/MachOUniversal.h"
Expand Down Expand Up @@ -640,19 +639,11 @@ Error macho2yaml(raw_ostream &Out, const object::MachOUniversalBinary &Obj) {
}

Error macho2yaml(raw_ostream &Out, const object::Binary &Binary) {
if (const auto *MachOObj = dyn_cast<object::MachOUniversalBinary>(&Binary)) {
if (auto Err = macho2yaml(Out, *MachOObj)) {
return Err;
}
return Error::success();
}
if (const auto *MachOObj = dyn_cast<object::MachOUniversalBinary>(&Binary))
return macho2yaml(Out, *MachOObj);

if (const auto *MachOObj = dyn_cast<object::MachOObjectFile>(&Binary)) {
if (auto Err = macho2yaml(Out, *MachOObj)) {
return Err;
}
return Error::success();
}
if (const auto *MachOObj = dyn_cast<object::MachOObjectFile>(&Binary))
return macho2yaml(Out, *MachOObj);

return errorCodeToError(obj2yaml_error::unsupported_obj_file_format);
llvm_unreachable("unexpected Mach-O file format");
}
1 change: 0 additions & 1 deletion llvm/tools/obj2yaml/minidump2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

#include "Error.h"
#include "obj2yaml.h"
#include "llvm/Object/Minidump.h"
#include "llvm/ObjectYAML/MinidumpYAML.h"
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/obj2yaml/obj2yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
//===----------------------------------------------------------------------===//

#include "obj2yaml.h"
#include "Error.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/COFF.h"
#include "llvm/Object/Minidump.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/InitLLVM.h"

using namespace llvm;
Expand All @@ -30,7 +30,7 @@ static Error dumpObject(const ObjectFile &Obj) {
if (Obj.isWasm())
return errorCodeToError(wasm2yaml(outs(), cast<WasmObjectFile>(Obj)));

return errorCodeToError(obj2yaml_error::unsupported_obj_file_format);
llvm_unreachable("unexpected object file format");
}

static Error dumpInput(StringRef File) {
Expand Down

0 comments on commit 357dc1e

Please sign in to comment.