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

This test regressed with 5ade17e0ca, 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 5ade17e0ca) 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.
This commit is contained in:
Louis Dionne 2020-04-03 11:06:26 -04:00
parent 4824b5ecce
commit 3d94f3060c
3 changed files with 27 additions and 32 deletions

View File

@ -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) && \

View File

@ -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, "");
template <typename T>
void test_is_pointer() {
assert_is_pointer<T>();
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, "");
assert_is_pointer<T __weak>();
assert_is_pointer<T __strong>();
assert_is_pointer<T __autoreleasing>();
assert_is_pointer<T __unsafe_unretained>();
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, "");
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>();
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, "");
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;

View File

@ -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__)