OSDN Git Service

Update LLVM for 3.5 rebase (r209712).
[android-x86/external-llvm.git] / include / llvm / Support / system_error.h
index e5306ec..aa5e9f7 100644 (file)
@@ -1,4 +1,4 @@
-//===---------------------------- system_error ----------------------------===//
+//===---------------------------- system_error ------------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_SYSTEM_SYSTEM_ERROR_H
-#define LLVM_SYSTEM_SYSTEM_ERROR_H
+#ifndef LLVM_SUPPORT_SYSTEM_ERROR_H
+#define LLVM_SUPPORT_SYSTEM_ERROR_H
+
+#include "llvm/Support/Compiler.h"
 
 /*
     system_error synopsis
@@ -46,10 +48,10 @@ const error_category& generic_category();
 const error_category& system_category();
 
 template <class T> struct is_error_code_enum
-    : public false_type {};
+    : public std::false_type {};
 
 template <class T> struct is_error_condition_enum
-    : public false_type {};
+    : public std::false_type {};
 
 class error_code
 {
@@ -201,7 +203,7 @@ enum class errc
     wrong_protocol_type                 // EPROTOTYPE
 };
 
-template <> struct is_error_condition_enum<errc> : true_type { }
+template <> struct is_error_condition_enum<errc> : std::true_type { }
 
 error_code make_error_code(errc e);
 error_condition make_error_condition(errc e);
@@ -222,8 +224,7 @@ template <> struct hash<std::error_code>;
 
 */
 
-#include "llvm/Config/config.h"
-#include "llvm/Support/type_traits.h"
+#include "llvm/Config/llvm-config.h"
 #include <cerrno>
 #include <string>
 
@@ -470,24 +471,13 @@ template <> struct hash<std::error_code>;
 
 namespace llvm {
 
-template <class T, T v>
-struct integral_constant {
-  typedef T value_type;
-  static const value_type value = v;
-  typedef integral_constant<T,v> type;
-  operator value_type() { return value; }
-};
-
-typedef integral_constant<bool, true> true_type;
-typedef integral_constant<bool, false> false_type;
-
 // is_error_code_enum
 
-template <class Tp> struct is_error_code_enum : public false_type {};
+template <class Tp> struct is_error_code_enum : public std::false_type {};
 
 // is_error_condition_enum
 
-template <class Tp> struct is_error_condition_enum : public false_type {};
+template <class Tp> struct is_error_condition_enum : public std::false_type {};
 
 // Some error codes are not present on all platforms, so we provide equivalents
 // for them:
@@ -622,9 +612,9 @@ enum _ {
   operator int() const {return v_;}
 };
 
-template <> struct is_error_condition_enum<errc> : true_type { };
+template <> struct is_error_condition_enum<errc> : std::true_type { };
 
-template <> struct is_error_condition_enum<errc::_> : true_type { };
+template <> struct is_error_condition_enum<errc::_> : std::true_type { };
 
 class error_condition;
 class error_code;
@@ -638,10 +628,10 @@ class error_category
 public:
   virtual ~error_category();
 
-private:
   error_category();
-  error_category(const error_category&);// = delete;
-  error_category& operator=(const error_category&);// = delete;
+private:
+  error_category(const error_category&) LLVM_DELETED_FUNCTION;
+  error_category& operator=(const error_category&) LLVM_DELETED_FUNCTION;
 
 public:
   virtual const char* name() const = 0;
@@ -662,14 +652,14 @@ public:
 class _do_message : public error_category
 {
 public:
-  virtual std::string message(int ev) const;
+  std::string message(int ev) const override;
 };
 
 const error_category& generic_category();
 const error_category& system_category();
 
 /// Get the error_category used for errno values from POSIX functions. This is
-/// the same as the system_category on POISIX systems, but is the same as the
+/// the same as the system_category on POSIX systems, but is the same as the
 /// generic_category on Windows.
 const error_category& posix_category();
 
@@ -684,7 +674,7 @@ public:
     : _val_(_val), _cat_(&_cat) {}
 
   template <class E>
-  error_condition(E _e, typename enable_if_c<
+  error_condition(E _e, typename std::enable_if<
                           is_error_condition_enum<E>::value
                         >::type* = 0)
     {*this = make_error_condition(_e);}
@@ -695,13 +685,12 @@ public:
   }
 
   template <class E>
-    typename enable_if_c
-    <
-      is_error_condition_enum<E>::value,
-      error_condition&
-    >::type
-    operator=(E _e)
-      {*this = make_error_condition(_e); return *this;}
+  typename std::enable_if<is_error_condition_enum<E>::value,
+                          error_condition &>::type
+  operator=(E _e) {
+    *this = make_error_condition(_e);
+    return *this;
+  }
 
   void clear() {
     _val_ = 0;
@@ -717,7 +706,7 @@ public:
   static void unspecified_bool_true() {}
 
   operator unspecified_bool_type() const { // true if error
-    return _val_ == 0 ? 0 : unspecified_bool_true;
+    return _val_ == 0 ? nullptr : unspecified_bool_true;
   }
 };
 
@@ -738,11 +727,15 @@ class error_code {
 public:
   error_code() : _val_(0), _cat_(&system_category()) {}
 
+  static error_code success() {
+    return error_code();
+  }
+
   error_code(int _val, const error_category& _cat)
     : _val_(_val), _cat_(&_cat) {}
 
   template <class E>
-  error_code(E _e, typename enable_if_c<
+  error_code(E _e, typename std::enable_if<
                      is_error_code_enum<E>::value
                    >::type* = 0) {
     *this = make_error_code(_e);
@@ -754,13 +747,11 @@ public:
   }
 
   template <class E>
-    typename enable_if_c
-    <
-      is_error_code_enum<E>::value,
-      error_code&
-    >::type
-    operator=(E _e)
-      {*this = make_error_code(_e); return *this;}
+  typename std::enable_if<is_error_code_enum<E>::value, error_code &>::type
+  operator=(E _e) {
+    *this = make_error_code(_e);
+    return *this;
+  }
 
   void clear() {
     _val_ = 0;
@@ -780,7 +771,7 @@ public:
   static void unspecified_bool_true() {}
 
   operator unspecified_bool_type() const { // true if error
-    return _val_ == 0 ? 0 : unspecified_bool_true;
+    return _val_ == 0 ? nullptr : unspecified_bool_true;
   }
 };
 
@@ -897,9 +888,9 @@ enum _ {
 };
 
 
-template <> struct is_error_code_enum<windows_error> : true_type { };
+template <> struct is_error_code_enum<windows_error> : std::true_type { };
 
-template <> struct is_error_code_enum<windows_error::_> : true_type { };
+template <> struct is_error_code_enum<windows_error::_> : std::true_type { };
 
 inline error_code make_error_code(windows_error e) {
   return error_code(static_cast<int>(e), system_category());