[llvm] r210077 - Use an enum class.

Rafael Espindola rafael.espindola at gmail.com
Mon Jun 2 22:12:33 PDT 2014


Author: rafael
Date: Tue Jun  3 00:12:33 2014
New Revision: 210077

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

Might also fix the windows build.

Modified:
    llvm/trunk/include/llvm/ProfileData/InstrProf.h
    llvm/trunk/lib/ProfileData/InstrProf.cpp

Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=210077&r1=210076&r2=210077&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Tue Jun  3 00:12:33 2014
@@ -22,8 +22,7 @@ namespace llvm {
 
 const error_category &instrprof_category();
 
-struct instrprof_error {
-  enum ErrorType {
+enum class instrprof_error {
     success = 0,
     eof,
     bad_magic,
@@ -37,11 +36,6 @@ struct instrprof_error {
     hash_mismatch,
     count_mismatch,
     counter_overflow
-  };
-  ErrorType V;
-
-  instrprof_error(ErrorType V) : V(V) {}
-  operator ErrorType() const { return V; }
 };
 
 inline error_code make_error_code(instrprof_error E) {
@@ -49,8 +43,6 @@ inline error_code make_error_code(instrp
 }
 
 template <> struct is_error_code_enum<instrprof_error> : std::true_type {};
-template <> struct is_error_code_enum<instrprof_error::ErrorType>
-  : std::true_type {};
 
 } // end namespace llvm
 

Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=210077&r1=210076&r2=210077&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Tue Jun  3 00:12:33 2014
@@ -21,7 +21,7 @@ namespace {
 class InstrProfErrorCategoryType : public error_category {
   const char *name() const override { return "llvm.instrprof"; }
   std::string message(int IE) const override {
-    instrprof_error::ErrorType E = static_cast<instrprof_error::ErrorType>(IE);
+    instrprof_error E = static_cast<instrprof_error>(IE);
     switch (E) {
     case instrprof_error::success:
       return "Success";
@@ -53,7 +53,7 @@ class InstrProfErrorCategoryType : publi
     llvm_unreachable("A value of instrprof_error has no message.");
   }
   error_condition default_error_condition(int EV) const override {
-    if (EV == instrprof_error::success)
+    if (static_cast<instrprof_error>(EV) == instrprof_error::success)
       return error_condition();
     return errc::invalid_argument;
   }





More information about the llvm-commits mailing list