Don't import error_category into the llvm namespace.
[oota-llvm.git] / lib / ProfileData / InstrProf.cpp
index 329abf84e6e468490b29c8250ffa0d23a067236c..628edfb86cd989d06aea48086da761399151b921 100644 (file)
 using namespace llvm;
 
 namespace {
-class InstrProfErrorCategoryType : public error_category {
-  const char *name() const override { return "llvm.instrprof"; }
+class InstrProfErrorCategoryType : public std::error_category {
+  const char *name() const LLVM_NOEXCEPT 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";
@@ -29,8 +29,12 @@ class InstrProfErrorCategoryType : public error_category {
       return "End of File";
     case instrprof_error::bad_magic:
       return "Invalid file format (bad magic)";
+    case instrprof_error::bad_header:
+      return "Invalid header";
     case instrprof_error::unsupported_version:
       return "Unsupported format version";
+    case instrprof_error::unsupported_hash_type:
+      return "Unsupported hash function";
     case instrprof_error::too_large:
       return "Too much profile data";
     case instrprof_error::truncated:
@@ -39,18 +43,25 @@ class InstrProfErrorCategoryType : public error_category {
       return "Malformed profile data";
     case instrprof_error::unknown_function:
       return "No profile data available for function";
+    case instrprof_error::hash_mismatch:
+      return "Function hash mismatch";
+    case instrprof_error::count_mismatch:
+      return "Function count mismatch";
+    case instrprof_error::counter_overflow:
+      return "Counter overflow";
     }
     llvm_unreachable("A value of instrprof_error has no message.");
   }
-  error_condition default_error_condition(int EV) const {
-    if (EV == instrprof_error::success)
-      return errc::success;
-    return errc::invalid_argument;
+  std::error_condition
+  default_error_condition(int EV) const LLVM_NOEXCEPT override {
+    if (static_cast<instrprof_error>(EV) == instrprof_error::success)
+      return std::error_condition();
+    return std::errc::invalid_argument;
   }
 };
 }
 
-const error_category &llvm::instrprof_category() {
+const std::error_category &llvm::instrprof_category() {
   static InstrProfErrorCategoryType C;
   return C;
 }