[llvm] r210623 - Use an enum class.
Rafael Espindola
rafael.espindola at gmail.com
Tue Jun 10 18:22:21 PDT 2014
Author: rafael
Date: Tue Jun 10 20:22:20 2014
New Revision: 210623
URL: http://llvm.org/viewvc/llvm-project?rev=210623&view=rev
Log:
Use an enum class.
Modified:
llvm/trunk/tools/llvm-readobj/Error.cpp
llvm/trunk/tools/llvm-readobj/Error.h
Modified: llvm/trunk/tools/llvm-readobj/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/Error.cpp?rev=210623&r1=210622&r2=210623&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/Error.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/Error.cpp Tue Jun 10 20:22:20 2014
@@ -29,8 +29,8 @@ const char *_readobj_error_category::nam
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<readobj_error>(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::mes
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<readobj_error>(EV) == readobj_error::success)
return error_condition();
return errc::invalid_argument;
}
Modified: llvm/trunk/tools/llvm-readobj/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/Error.h?rev=210623&r1=210622&r2=210623&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/Error.h (original)
+++ llvm/trunk/tools/llvm-readobj/Error.h Tue Jun 10 20:22:20 2014
@@ -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(readob
}
template <> struct is_error_code_enum<readobj_error> : std::true_type { };
-template <> struct is_error_code_enum<readobj_error::_> : std::true_type { };
} // namespace llvm
More information about the llvm-commits
mailing list