[libcxx-commits] [libcxx] r357517 - [libc++] Correctly handle Objective-C++ ARC qualifiers in std::is_pointer

Hans Wennborg via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 3 03:06:18 PDT 2019


This broke the Chromium build, see
https://bugs.chromium.org/p/chromium/issues/detail?id=949071

It seems the compiler fails to choose one of the __libcpp_is_pointer
overloads for some reason.

Please let me know if the error message on the bug is enough for you
to investigate, otherwise I can try to extract more info.

I've reverted in r357569 in the meantime.

On Tue, Apr 2, 2019 at 9:46 PM Louis Dionne via libcxx-commits
<libcxx-commits at lists.llvm.org> wrote:
>
> Author: ldionne
> Date: Tue Apr  2 12:48:39 2019
> New Revision: 357517
>
> URL: http://llvm.org/viewvc/llvm-project?rev=357517&view=rev
> Log:
> [libc++] Correctly handle Objective-C++ ARC qualifiers in std::is_pointer
>
> Summary:
> Otherwise, std::is_pointer<id __strong> works, but std::is_pointer<id __weak>
> (and others) don't work as expected.
>
> rdar://problem/49126333
>
> Reviewers: ahatanak, EricWF
>
> Subscribers: christof, jkorous, dexonsmith, libcxx-commits
>
> Differential Revision: https://reviews.llvm.org/D60087
>
> Added:
>     libcxx/trunk/test/libcxx/type_traits/is_pointer_objc.arc.pass.mm
> Modified:
>     libcxx/trunk/include/type_traits
>
> Modified: libcxx/trunk/include/type_traits
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=357517&r1=357516&r2=357517&view=diff
> ==============================================================================
> --- libcxx/trunk/include/type_traits (original)
> +++ libcxx/trunk/include/type_traits Tue Apr  2 12:48:39 2019
> @@ -784,6 +784,11 @@ _LIBCPP_INLINE_VAR _LIBCPP_CONSTEXPR boo
>
>  template <class _Tp> struct __libcpp_is_pointer       : public false_type {};
>  template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {};
> +#if defined(_LIBCPP_HAS_OBJC_ARC)
> +template <class _Tp> struct __libcpp_is_pointer<_Tp* __weak> : public true_type {};
> +template <class _Tp> struct __libcpp_is_pointer<_Tp* __autoreleasing> : public true_type {};
> +template <class _Tp> struct __libcpp_is_pointer<_Tp* __unsafe_unretained> : public true_type {};
> +#endif
>
>  template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_pointer
>      : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {};
>
> Added: libcxx/trunk/test/libcxx/type_traits/is_pointer_objc.arc.pass.mm
> URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/type_traits/is_pointer_objc.arc.pass.mm?rev=357517&view=auto
> ==============================================================================
> --- libcxx/trunk/test/libcxx/type_traits/is_pointer_objc.arc.pass.mm (added)
> +++ libcxx/trunk/test/libcxx/type_traits/is_pointer_objc.arc.pass.mm Tue Apr  2 12:48:39 2019
> @@ -0,0 +1,56 @@
> +//===----------------------------------------------------------------------===//
> +//
> +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
> +// See https://llvm.org/LICENSE.txt for license information.
> +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
> +//
> +//===----------------------------------------------------------------------===//
> +//
> +// UNSUPPORTED: c++98, c++03
> +
> +// <type_traits>
> +
> +// std::is_pointer
> +
> +// Test that we correctly handle Objective-C++ ARC qualifiers on pointers.
> +
> +#include <type_traits>
> +
> +
> +template <typename T>
> +void test() {
> +    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, "");
> +}
> +
> + at class Foo;
> +
> +int main(int, char**) {
> +    test<id>();
> +    test<id const>();
> +    test<id volatile>();
> +    test<id const volatile>();
> +    test<Foo*>();
> +    test<Foo const*>();
> +    test<Foo volatile*>();
> +    test<Foo const volatile*>();
> +
> +    return 0;
> +}
>
>
> _______________________________________________
> libcxx-commits mailing list
> libcxx-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-commits


More information about the libcxx-commits mailing list