[libcxx-commits] [PATCH] D98720: [libc++] Consistent style on _LIBCPP_CLANG_VER tests in <type_traits>
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 16 09:23:59 PDT 2021
Quuxplusone created this revision.
Quuxplusone added reviewers: libc++, zoecarver, tmatheson.
Quuxplusone added a project: libc++.
Quuxplusone requested review of this revision.
Herald added a subscriber: libcxx-commits.
Herald added 1 blocking reviewer(s): libc++.
This came out of my review comments on D97283 <https://reviews.llvm.org/D97283>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98720
Files:
libcxx/include/type_traits
Index: libcxx/include/type_traits
===================================================================
--- libcxx/include/type_traits
+++ libcxx/include/type_traits
@@ -834,8 +834,8 @@
// is_pointer
-// In clang 10.0.0 and earlier __is_pointer didn't work with Objective-C types.
-#if __has_keyword(__is_pointer) && _LIBCPP_CLANG_VER > 1000
+// Before Clang 11, __is_pointer didn't work for Objective-C types.
+#if __has_keyword(__is_pointer) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1100)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
@@ -1129,9 +1129,9 @@
// is_fundamental
-// In clang 9 and lower, this builtin did not work for nullptr_t. Additionally, in C++03 mode,
-// nullptr isn't defined by the compiler so, this builtin won't work.
-#if __has_keyword(__is_fundamental) && _LIBCPP_CLANG_VER > 900 && !defined(_LIBCPP_CXX03_LANG)
+// Before Clang 10, __is_fundamental didn't work for nullptr_t.
+// In C++03 nullptr_t is library-provided but must still count as "fundamental."
+#if __has_keyword(__is_fundamental) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1000) && !defined(_LIBCPP_CXX03_LANG)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_fundamental : _BoolConstant<__is_fundamental(_Tp)> { };
@@ -1158,7 +1158,7 @@
// is_scalar
-// >= 11 because in C++03 nullptr isn't actually nullptr
+// In C++03 nullptr_t is library-provided but must still count as "scalar."
#if __has_keyword(__is_scalar) && !defined(_LIBCPP_CXX03_LANG)
template<class _Tp>
@@ -1415,8 +1415,8 @@
// is_signed
-// In clang 9 and earlier, this builtin did not work for floating points or enums
-#if __has_keyword(__is_signed) && _LIBCPP_CLANG_VER > 900
+// Before Clang 10, __is_signed didn't work for floating-point types or enums.
+#if __has_keyword(__is_signed) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1000)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_signed : _BoolConstant<__is_signed(_Tp)> { };
@@ -1451,7 +1451,8 @@
// is_unsigned
-#if __has_keyword(__is_unsigned)
+// Before Clang 13, __is_unsigned returned true for enums with signed underlying type.
+#if __has_keyword(__is_unsigned) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER >= 1300)
template<class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_unsigned : _BoolConstant<__is_unsigned(_Tp)> { };
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98720.331013.patch
Type: text/x-patch
Size: 2393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210316/a5d0af0d/attachment-0001.bin>
More information about the libcxx-commits
mailing list