From e869d888432a02cb524d712ed1e3d64dbc3d0a85 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 11 Jun 2014 01:22:20 +0000 Subject: [PATCH] Use an enum class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210623 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llvm-readobj/Error.cpp | 13 ++++++------- tools/llvm-readobj/Error.h | 22 +++++++--------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/tools/llvm-readobj/Error.cpp b/tools/llvm-readobj/Error.cpp index 424dfbea06b..a68ebeb58e7 100644 --- a/tools/llvm-readobj/Error.cpp +++ b/tools/llvm-readobj/Error.cpp @@ -29,8 +29,8 @@ const char *_readobj_error_category::name() const { return "llvm.readobj"; } -std::string _readobj_error_category::message(int ev) const { - switch (ev) { +std::string _readobj_error_category::message(int EV) const { + switch (static_cast(EV)) { case readobj_error::success: return "Success"; case readobj_error::file_not_found: return "No such file."; @@ -42,14 +42,13 @@ std::string _readobj_error_category::message(int ev) const { return "Unsupported object file format."; case readobj_error::unknown_symbol: return "Unknown symbol."; - default: - llvm_unreachable("An enumerator of readobj_error does not have a message " - "defined."); } + llvm_unreachable("An enumerator of readobj_error does not have a message " + "defined."); } -error_condition _readobj_error_category::default_error_condition(int ev) const { - if (ev == readobj_error::success) +error_condition _readobj_error_category::default_error_condition(int EV) const { + if (static_cast(EV) == readobj_error::success) return error_condition(); return errc::invalid_argument; } diff --git a/tools/llvm-readobj/Error.h b/tools/llvm-readobj/Error.h index 5129b4e57cd..ebf652e9a18 100644 --- a/tools/llvm-readobj/Error.h +++ b/tools/llvm-readobj/Error.h @@ -20,20 +20,13 @@ namespace llvm { const error_category &readobj_category(); -struct readobj_error { - enum _ { - success = 0, - file_not_found, - unsupported_file_format, - unrecognized_file_format, - unsupported_obj_file_format, - unknown_symbol - }; - _ v_; - - readobj_error(_ v) : v_(v) {} - explicit readobj_error(int v) : v_(_(v)) {} - operator int() const {return v_;} +enum class readobj_error { + success = 0, + file_not_found, + unsupported_file_format, + unrecognized_file_format, + unsupported_obj_file_format, + unknown_symbol }; inline error_code make_error_code(readobj_error e) { @@ -41,7 +34,6 @@ inline error_code make_error_code(readobj_error e) { } template <> struct is_error_code_enum : std::true_type { }; -template <> struct is_error_code_enum : std::true_type { }; } // namespace llvm -- 2.34.1