[llvm] r210078 - Use an enum class.

Rafael Espindola rafael.espindola at gmail.com
Mon Jun 2 22:26:13 PDT 2014


Author: rafael
Date: Tue Jun  3 00:26:12 2014
New Revision: 210078

URL: http://llvm.org/viewvc/llvm-project?rev=210078&view=rev
Log:
Use an enum class.

Modified:
    llvm/trunk/include/llvm/Object/Error.h
    llvm/trunk/lib/Object/Error.cpp

Modified: llvm/trunk/include/llvm/Object/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Error.h?rev=210078&r1=210077&r2=210078&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Error.h (original)
+++ llvm/trunk/include/llvm/Object/Error.h Tue Jun  3 00:26:12 2014
@@ -21,18 +21,12 @@ namespace object {
 
 const error_category &object_category();
 
-struct object_error {
-  enum Impl {
-    success = 0,
-    arch_not_found,
-    invalid_file_type,
-    parse_failed,
-    unexpected_eof
-  };
-  Impl V;
-
-  object_error(Impl V) : V(V) {}
-  operator Impl() const { return V; }
+enum class object_error {
+  success = 0,
+  arch_not_found,
+  invalid_file_type,
+  parse_failed,
+  unexpected_eof
 };
 
 inline error_code make_error_code(object_error e) {
@@ -43,9 +37,6 @@ inline error_code make_error_code(object
 
 template <> struct is_error_code_enum<object::object_error> : std::true_type {};
 
-template <>
-struct is_error_code_enum<object::object_error::Impl> : std::true_type {};
-
 } // end namespace llvm.
 
 #endif

Modified: llvm/trunk/lib/Object/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Error.cpp?rev=210078&r1=210077&r2=210078&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Error.cpp (original)
+++ llvm/trunk/lib/Object/Error.cpp Tue Jun  3 00:26:12 2014
@@ -30,8 +30,8 @@ const char *_object_error_category::name
   return "llvm.object";
 }
 
-std::string _object_error_category::message(int ev) const {
-  object_error::Impl E = static_cast<object_error::Impl>(ev);
+std::string _object_error_category::message(int EV) const {
+  object_error E = static_cast<object_error>(EV);
   switch (E) {
   case object_error::success: return "Success";
   case object_error::arch_not_found:
@@ -47,8 +47,8 @@ std::string _object_error_category::mess
                    "defined.");
 }
 
-error_condition _object_error_category::default_error_condition(int ev) const {
-  if (ev == object_error::success)
+error_condition _object_error_category::default_error_condition(int EV) const {
+  if (static_cast<object_error>(EV) == object_error::success)
     return error_condition();
   return errc::invalid_argument;
 }





More information about the llvm-commits mailing list