[libcxx-commits] [libcxx] 3d94f30 - [libc++] Fix is_pointer support for Objective-C++

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 3 08:10:33 PDT 2020


Author: Louis Dionne
Date: 2020-04-03T11:09:59-04:00
New Revision: 3d94f3060c4c370be00aa74ae6659c9c8a2bcb0d

URL: https://github.com/llvm/llvm-project/commit/3d94f3060c4c370be00aa74ae6659c9c8a2bcb0d
DIFF: https://github.com/llvm/llvm-project/commit/3d94f3060c4c370be00aa74ae6659c9c8a2bcb0d.diff

LOG: [libc++] Fix is_pointer support for Objective-C++

This test regressed with 5ade17e0ca8b, but we never noticed it because
.pass.mm tests were skipped due to a bug in our Lit config. This commit
fixes is_pointer (by essentially reverting tha part of 5ade17e0ca8b) and
also adds .pass.mm tests to the list of supported test suffixes.

We can explore how to support __is_pointer with Objective-C++ qualifiers
as a follow-up -- the main goal of this commit is to fix the regression
quickly and make sure all tests of the suite are run.

Added: 
    

Modified: 
    libcxx/include/type_traits
    libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm
    libcxx/test/lit.cfg

Removed: 
    


################################################################################
diff  --git a/libcxx/include/type_traits b/libcxx/include/type_traits
index 15e9df2ea269..029bb4aa2ae9 100644
--- a/libcxx/include/type_traits
+++ b/libcxx/include/type_traits
@@ -908,18 +908,6 @@ template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __autoreleasing>
 template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __unsafe_unretained> { typedef _Tp type; };
 #endif
 
-#if __has_keyword(__is_pointer)
-
-template<class _Tp>
-struct _LIBCPP_TEMPLATE_VIS is_pointer : _BoolConstant<__is_pointer(_Tp)> { };
-
-#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
-template <class _Tp>
-_LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v = __is_pointer(_Tp);
-#endif
-
-#else // __has_keyword(__is_pointer)
-
 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
     : public __libcpp_is_pointer<typename __libcpp_remove_objc_qualifiers<typename remove_cv<_Tp>::type>::type> {};
 
@@ -929,8 +917,6 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR bool is_pointer_v
     = is_pointer<_Tp>::value;
 #endif
 
-#endif // __has_keyword(__is_pointer)
-
 // is_reference
 
 #if __has_keyword(__is_lvalue_reference) && \

diff  --git a/libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm b/libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm
index 168869972dd1..e8296b3f3698 100644
--- a/libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm
+++ b/libcxx/test/libcxx/type_traits/is_pointer.arc.pass.mm
@@ -17,31 +17,40 @@
 // Test that we correctly handle Objective-C++ ARC qualifiers on pointers.
 
 #include <type_traits>
+#include "test_macros.h"
 
 
 template <typename T>
-void test_is_pointer() {
+void assert_is_pointer() {
     static_assert(std::is_pointer<T>::value, "");
+#if TEST_STD_VER > 14
+    static_assert(std::is_pointer_v<T>, "");
+#endif
+}
 
-    static_assert(std::is_pointer<T __weak>::value, "");
-    static_assert(std::is_pointer<T __strong>::value, "");
-    static_assert(std::is_pointer<T __autoreleasing>::value, "");
-    static_assert(std::is_pointer<T __unsafe_unretained>::value, "");
-
-    static_assert(std::is_pointer<T __weak const>::value, "");
-    static_assert(std::is_pointer<T __strong const>::value, "");
-    static_assert(std::is_pointer<T __autoreleasing const>::value, "");
-    static_assert(std::is_pointer<T __unsafe_unretained const>::value, "");
-
-    static_assert(std::is_pointer<T __weak volatile>::value, "");
-    static_assert(std::is_pointer<T __strong volatile>::value, "");
-    static_assert(std::is_pointer<T __autoreleasing volatile>::value, "");
-    static_assert(std::is_pointer<T __unsafe_unretained volatile>::value, "");
-
-    static_assert(std::is_pointer<T __weak const volatile>::value, "");
-    static_assert(std::is_pointer<T __strong const volatile>::value, "");
-    static_assert(std::is_pointer<T __autoreleasing const volatile>::value, "");
-    static_assert(std::is_pointer<T __unsafe_unretained const volatile>::value, "");
+template <typename T>
+void test_is_pointer() {
+    assert_is_pointer<T>();
+
+    assert_is_pointer<T __weak>();
+    assert_is_pointer<T __strong>();
+    assert_is_pointer<T __autoreleasing>();
+    assert_is_pointer<T __unsafe_unretained>();
+
+    assert_is_pointer<T __weak const>();
+    assert_is_pointer<T __strong const>();
+    assert_is_pointer<T __autoreleasing const>();
+    assert_is_pointer<T __unsafe_unretained const>();
+
+    assert_is_pointer<T __weak volatile>();
+    assert_is_pointer<T __strong volatile>();
+    assert_is_pointer<T __autoreleasing volatile>();
+    assert_is_pointer<T __unsafe_unretained volatile>();
+
+    assert_is_pointer<T __weak const volatile>();
+    assert_is_pointer<T __strong const volatile>();
+    assert_is_pointer<T __autoreleasing const volatile>();
+    assert_is_pointer<T __unsafe_unretained const volatile>();
 }
 
 @class Foo;

diff  --git a/libcxx/test/lit.cfg b/libcxx/test/lit.cfg
index ed5aa29d9175..8ee592b43650 100644
--- a/libcxx/test/lit.cfg
+++ b/libcxx/test/lit.cfg
@@ -15,7 +15,7 @@ if 'PYLINT_IMPORT' in os.environ:
 config.name = 'libc++'
 
 # suffixes: A list of file extensions to treat as test files.
-config.suffixes = ['.pass.cpp', '.fail.cpp', '.sh.cpp']
+config.suffixes = ['.pass.cpp', '.fail.cpp', '.sh.cpp', '.pass.mm']
 
 # test_source_root: The root path where tests are located.
 config.test_source_root = os.path.dirname(__file__)


        


More information about the libcxx-commits mailing list