From de60ad33b37e19cbf73b53feed6428886d358f02 Mon Sep 17 00:00:00 2001 From: Chris Bieneman Date: Thu, 12 May 2016 01:52:33 +0000 Subject: [obj2yaml] Adding Error/Expected to macho2yaml I figure if I'm adding Mach support I may as well use the new fancy Error model. llvm-svn: 269264 --- llvm/tools/obj2yaml/Error.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'llvm/tools/obj2yaml/Error.h') diff --git a/llvm/tools/obj2yaml/Error.h b/llvm/tools/obj2yaml/Error.h index 7be92e9aace..f4e191c872c 100644 --- a/llvm/tools/obj2yaml/Error.h +++ b/llvm/tools/obj2yaml/Error.h @@ -10,6 +10,8 @@ #ifndef LLVM_TOOLS_OBJ2YAML_ERROR_H #define LLVM_TOOLS_OBJ2YAML_ERROR_H +#include "llvm/Support/Error.h" + #include namespace llvm { @@ -27,6 +29,22 @@ inline std::error_code make_error_code(obj2yaml_error e) { return std::error_code(static_cast(e), obj2yaml_category()); } +class Obj2YamlError : public ErrorInfo { +public: + static char ID; + Obj2YamlError(obj2yaml_error C) : Code(C) {} + Obj2YamlError(const std::string &ErrMsg) : ErrMsg(std::move(ErrMsg)) {} + Obj2YamlError(obj2yaml_error C, std::string ErrMsg) + : ErrMsg(std::move(ErrMsg)), Code(C) {} + void log(raw_ostream &OS) const override; + const std::string &getErrorMessage() const { return ErrMsg; } + std::error_code convertToErrorCode() const override; + +private: + std::string ErrMsg; + obj2yaml_error Code; +}; + } // namespace llvm namespace std { -- cgit v1.2.3