Hi mclow.lists, danalbert,

Currently we only enable the use of __is_final(...) with Clang. GCC also 
provides __is_final(...) since 4.7 in all standard modes. This patch creates 
the macro _LIBCPP_HAS_IS_FINAL to note the availability of `__is_final`.

http://reviews.llvm.org/D8795

Files:
  include/__config
  include/exception
  include/ext/hash_map
  include/map
  include/memory
  include/tuple
  include/type_traits
  include/unordered_map

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: include/__config
===================================================================
--- include/__config
+++ include/__config
@@ -75,10 +75,8 @@
 #ifdef _WIN32
 #  define _LIBCPP_LITTLE_ENDIAN 1
 #  define _LIBCPP_BIG_ENDIAN    0
-// Compiler intrinsics (GCC or MSVC)
-#  if defined(__clang__) \
-   || (defined(_MSC_VER) && _MSC_VER >= 1400) \
-   || (defined(__GNUC__) && _GNUC_VER > 403)
+// Compiler intrinsics (MSVC)
+#if defined(_MSC_VER) && _MSC_VER >= 1400
 #    define _LIBCPP_HAS_IS_BASE_OF
 #  endif
 #  if defined(_MSC_VER) && !defined(__clang__)
@@ -93,12 +91,6 @@
 #  endif
 #endif  // _WIN32
 
-#ifdef __linux__
-#  if defined(__GNUC__) && _GNUC_VER >= 403
-#    define _LIBCPP_HAS_IS_BASE_OF
-#  endif
-#endif
-
 #ifdef __sun__
 # include <sys/isa_defs.h>
 # ifdef _LITTLE_ENDIAN
@@ -318,6 +310,10 @@
 #  define _LIBCPP_HAS_IS_BASE_OF
 #endif
 
+#if __has_feature(is_final)
+#  define _LIBCPP_HAS_IS_FINAL
+#endif
+
 // Objective-C++ features (opt-in)
 #if __has_feature(objc_arc)
 #define _LIBCPP_HAS_OBJC_ARC
@@ -401,6 +397,11 @@
 #if _GNUC_VER >= 407
 #define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
 #define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
+#define _LIBCPP_HAS_IS_FINAL
+#endif
+
+#if defined(__GNUC__) && _GNUC_VER >= 403
+#  define _LIBCPP_HAS_IS_BASE_OF
 #endif
 
 #if !__EXCEPTIONS
@@ -535,6 +536,7 @@
 #define _LIBCPP_HAS_NO_NULLPTR
 #define _LIBCPP_HAS_NO_UNICODE_CHARS
 #define _LIBCPP_HAS_IS_BASE_OF
+#define _LIBCPP_HAS_IS_FINAL
 #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
 
 #if defined(_AIX)
Index: include/exception
===================================================================
--- include/exception
+++ include/exception
@@ -193,8 +193,8 @@
 throw_with_nested(_Tp&& __t, typename enable_if<
                   is_class<typename remove_reference<_Tp>::type>::value &&
                   !is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
-#if _LIBCPP_STD_VER > 11
-                  && !is_final<typename remove_reference<_Tp>::type>::value
+#if defined(_LIBCPP_HAS_IS_FINAL)
+                  && !__is_final(typename remove_reference<_Tp>::type)
 #endif
                                     >::type* = 0)
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
@@ -215,8 +215,8 @@
 throw_with_nested(_Tp&& __t, typename enable_if<
                   !is_class<typename remove_reference<_Tp>::type>::value ||
                   is_base_of<nested_exception, typename remove_reference<_Tp>::type>::value
-#if _LIBCPP_STD_VER > 11
-                  || is_final<typename remove_reference<_Tp>::type>::value
+#if defined(_LIBCPP_HAS_IS_FINAL)
+                  || __is_final(typename remove_reference<_Tp>::type)
 #endif
                                     >::type* = 0)
 #else  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Index: include/ext/hash_map
===================================================================
--- include/ext/hash_map
+++ include/ext/hash_map
@@ -220,7 +220,7 @@
 using namespace std;
 
 template <class _Tp, class _Hash, bool = is_empty<_Hash>::value
-#if __has_feature(is_final)
+#if defined(_LIBCPP_HAS_IS_FINAL)
                                          && !__is_final(_Hash)
 #endif
         >
@@ -256,7 +256,7 @@
 };
 
 template <class _Tp, class _Pred, bool = is_empty<_Pred>::value
-#if __has_feature(is_final)
+#if defined(_LIBCPP_HAS_IS_FINAL)
                                          && !__is_final(_Pred)
 #endif
          >
Index: include/map
===================================================================
--- include/map
+++ include/map
@@ -434,7 +434,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Key, class _CP, class _Compare, bool = is_empty<_Compare>::value
-#if __has_feature(is_final)
+#if defined(_LIBCPP_HAS_IS_FINAL)
                                                         && !__is_final(_Compare)
 #endif
          >
Index: include/memory
===================================================================
--- include/memory
+++ include/memory
@@ -1934,12 +1934,12 @@
 template <class _T1, class _T2, bool = is_same<typename remove_cv<_T1>::type,
                                                      typename remove_cv<_T2>::type>::value,
                                 bool = is_empty<_T1>::value
-#if __has_feature(is_final)
+#if defined(_LIBCPP_HAS_IS_FINAL)
                                        && !__is_final(_T1)
 #endif
                                 ,
                                 bool = is_empty<_T2>::value
-#if __has_feature(is_final)
+#if defined(_LIBCPP_HAS_IS_FINAL)
                                        && !__is_final(_T2)
 #endif
          >
Index: include/tuple
===================================================================
--- include/tuple
+++ include/tuple
@@ -162,7 +162,7 @@
 // __tuple_leaf
 
 template <size_t _Ip, class _Hp, bool=is_empty<_Hp>::value
-#if __has_feature(is_final)
+#if defined(_LIBCPP_HAS_IS_FINAL)
                                  && !__is_final(_Hp)
 #endif
          >
Index: include/type_traits
===================================================================
--- include/type_traits
+++ include/type_traits
@@ -796,8 +796,8 @@
 
 // is_final
 
-#if _LIBCPP_STD_VER > 11 && __has_feature(is_final)
-template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY 
+#if _LIBCPP_STD_VER > 11 && defined(_LIBCPP_HAS_IS_FINAL)
+template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY
 is_final : public integral_constant<bool, __is_final(_Tp)> {};
 #endif
 
Index: include/unordered_map
===================================================================
--- include/unordered_map
+++ include/unordered_map
@@ -360,7 +360,7 @@
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _Key, class _Cp, class _Hash, bool = is_empty<_Hash>::value
-#if __has_feature(is_final)
+#if defined(_LIBCPP_HAS_IS_FINAL)
                                          && !__is_final(_Hash)
 #endif
          >
@@ -411,7 +411,7 @@
 };
 
 template <class _Key, class _Cp, class _Pred, bool = is_empty<_Pred>::value
-#if __has_feature(is_final)
+#if defined(_LIBCPP_HAS_IS_FINAL)
                                          && !__is_final(_Pred)
 #endif
          >
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to