From de6350f2a391328e2603d368bdbbbc14219d0be5 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Wed, 13 Aug 2025 10:10:02 +0200 Subject: [PATCH] [libc++] Fix LLVM 22 TODOs --- libcxx/include/CMakeLists.txt | 2 +- .../referenceable.h} | 20 +- libcxx/include/__config | 13 -- libcxx/include/__configuration/abi.h | 8 - libcxx/include/__format/format_arg.h | 17 +- libcxx/include/__format/format_context.h | 4 +- libcxx/include/__hash_table | 12 -- libcxx/include/__iterator/common_iterator.h | 2 +- libcxx/include/__iterator/concepts.h | 17 +- libcxx/include/__iterator/iter_move.h | 2 +- libcxx/include/__iterator/iterator_traits.h | 2 +- libcxx/include/__math/traits.h | 15 +- libcxx/include/__ranges/transform_view.h | 5 +- libcxx/include/__ranges/zip_transform_view.h | 2 +- libcxx/include/__tree | 12 -- libcxx/include/__type_traits/add_pointer.h | 31 +-- .../reference_constructs_from_temporary.h | 6 - libcxx/include/__type_traits/remove_pointer.h | 19 +- libcxx/include/forward_list | 11 - libcxx/include/list | 11 - libcxx/include/module.modulemap.in | 5 +- libcxx/include/tuple | 4 +- libcxx/include/variant | 2 +- .../meta/is_referenceable.compile.pass.cpp | 2 +- .../c.math/constexpr-cxx23-clang.pass.cpp | 7 - .../transform_error.mandates.verify.cpp | 27 +-- .../transform_error.mandates.verify.cpp | 27 +-- .../meta/is_referenceable.compile.pass.cpp | 190 ------------------ .../meta/referenceable.compile.pass.cpp | 155 ++++++++++++++ .../format.arg/visit.pass.cpp | 2 - .../format.arg/visit.return_type.pass.cpp | 2 - .../visit_format_arg.deprecated.verify.cpp | 1 - .../format.arg/visit_format_arg.pass.cpp | 6 +- .../format.arguments/format.args/get.pass.cpp | 6 +- .../meta.trans/objc_support.compile.pass.mm | 25 ++- ...855_tuple_ref_binding_diagnostics.pass.cpp | 22 -- .../robust_against_adl.pass.cpp | 1 - .../variant.visit.member/visit.pass.cpp | 2 - .../visit_return_type.pass.cpp | 2 - libcxx/test/support/test_basic_format_arg.h | 2 +- libcxx/test/support/test_macros.h | 7 - 41 files changed, 237 insertions(+), 471 deletions(-) rename libcxx/include/{__type_traits/is_referenceable.h => __concepts/referenceable.h} (61%) delete mode 100644 libcxx/test/libcxx/utilities/meta/is_referenceable.compile.pass.cpp create mode 100644 libcxx/test/libcxx/utilities/meta/referenceable.compile.pass.cpp diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index ddace8bf8c728..0aa0a2fb7e351 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -316,6 +316,7 @@ set(files __concepts/invocable.h __concepts/movable.h __concepts/predicate.h + __concepts/referenceable.h __concepts/regular.h __concepts/relation.h __concepts/same_as.h @@ -856,7 +857,6 @@ set(files __type_traits/is_primary_template.h __type_traits/is_reference.h __type_traits/is_reference_wrapper.h - __type_traits/is_referenceable.h __type_traits/is_replaceable.h __type_traits/is_same.h __type_traits/is_scalar.h diff --git a/libcxx/include/__type_traits/is_referenceable.h b/libcxx/include/__concepts/referenceable.h similarity index 61% rename from libcxx/include/__type_traits/is_referenceable.h rename to libcxx/include/__concepts/referenceable.h index 3a9d2858ba4c9..d7936ddb5d2e5 100644 --- a/libcxx/include/__type_traits/is_referenceable.h +++ b/libcxx/include/__concepts/referenceable.h @@ -6,29 +6,27 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H -#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H +#ifndef _LIBCPP___CONCEPTS_REFERENCEABLE_H +#define _LIBCPP___CONCEPTS_REFERENCEABLE_H #include <__config> -#include <__type_traits/void_t.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_STD +#if _LIBCPP_STD_VER >= 20 -template -inline const bool __is_referenceable_v = false; +_LIBCPP_BEGIN_NAMESPACE_STD template -inline const bool __is_referenceable_v<_Tp, __void_t<_Tp&> > = true; +using __referenceable_impl _LIBCPP_NODEBUG = _Tp&; -#if _LIBCPP_STD_VER >= 20 template -concept __referenceable = __is_referenceable_v<_Tp>; -#endif +concept __referenceable = requires { typename __referenceable_impl<_Tp>; }; _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H +#endif + +#endif // _LIBCPP___CONCEPTS_REFERENCEABLE_H diff --git a/libcxx/include/__config b/libcxx/include/__config index b4c081dcdff1b..c21b8bc29f913 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -1050,11 +1050,6 @@ typedef __char32_t char32_t; # define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "") # endif -// TODO(LLVM 22): Remove the workaround -# if defined(__OBJC__) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER < 2001) -# define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS -# endif - # define _PSTL_PRAGMA(x) _Pragma(#x) // Enable SIMD for compilers that support OpenMP 4.0 @@ -1255,14 +1250,6 @@ typedef __char32_t char32_t; # define _LIBCPP_DIAGNOSE_NULLPTR # endif -// TODO(LLVM 22): Remove this macro once LLVM19 support ends. __cpp_explicit_this_parameter has been set in LLVM20. -// Clang-18 has support for deducing this, but it does not set the FTM. -# if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800) -# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1 -# else -# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0 -# endif - #endif // __cplusplus #endif // _LIBCPP___CONFIG diff --git a/libcxx/include/__configuration/abi.h b/libcxx/include/__configuration/abi.h index 2d33b9c03090b..26ac7c2dba268 100644 --- a/libcxx/include/__configuration/abi.h +++ b/libcxx/include/__configuration/abi.h @@ -49,14 +49,6 @@ // According to the Standard, `bitset::operator[] const` returns bool # define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL -// In LLVM 20, we've changed to take these ABI breaks unconditionally. These flags only exist in case someone is running -// into the static_asserts we added to catch the ABI break and don't care that it is one. -// TODO(LLVM 22): Remove these flags -# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB -# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB -# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB -# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB - // These flags are documented in ABIGuarantees.rst # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT # define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON diff --git a/libcxx/include/__format/format_arg.h b/libcxx/include/__format/format_arg.h index ed5e76275ea87..19794f0f084ce 100644 --- a/libcxx/include/__format/format_arg.h +++ b/libcxx/include/__format/format_arg.h @@ -149,7 +149,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ __libcpp_unreachable(); } -# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# if _LIBCPP_STD_VER >= 26 template _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { @@ -200,7 +200,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< __libcpp_unreachable(); } -# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# endif // _LIBCPP_STD_VER >= 26 /// Contains the values used in basic_format_arg. /// @@ -285,7 +285,7 @@ class _LIBCPP_NO_SPECIALIZATIONS basic_format_arg { _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; } -# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# if _LIBCPP_STD_VER >= 26 // This function is user facing, so it must wrap the non-standard types of // the "variant" in a handle to stay conforming. See __arg_t for more details. @@ -329,7 +329,7 @@ class _LIBCPP_NO_SPECIALIZATIONS basic_format_arg { } } -# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# endif // _LIBCPP_STD_VER >= 26 private: using char_type = typename _Context::char_type; @@ -371,11 +371,8 @@ class basic_format_arg<_Context>::handle { // This function is user facing, so it must wrap the non-standard types of // the "variant" in a handle to stay conforming. See __arg_t for more details. template -# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER -_LIBCPP_DEPRECATED_IN_CXX26 -# endif - _LIBCPP_HIDE_FROM_ABI decltype(auto) - visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { +_LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_HIDE_FROM_ABI decltype(auto) +visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { switch (__arg.__type_) { # if _LIBCPP_HAS_INT128 case __format::__arg_t::__i128: { @@ -387,7 +384,7 @@ _LIBCPP_DEPRECATED_IN_CXX26 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); } -# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# endif // _LIBCPP_HAS_INT128 default: return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg); } diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h index e672ee7ad0581..1771dd34b82fb 100644 --- a/libcxx/include/__format/format_context.h +++ b/libcxx/include/__format/format_context.h @@ -175,13 +175,13 @@ class basic_format_context::__itera __format::__determine_arg_t(), __basic_format_arg_value(__arg)}; }; -# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# if _LIBCPP_STD_VER >= 26 return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor)); # else _LIBCPP_SUPPRESS_DEPRECATED_PUSH return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id)); _LIBCPP_SUPPRESS_DEPRECATED_POP -# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# endif // _LIBCPP_STD_VER >= 26 }) { } diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table index 6b65e738fef3b..9befedbf01cc2 100644 --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -83,18 +83,6 @@ struct __hash_node_base { typedef _NodePtr __node_pointer; typedef __node_base_pointer __next_pointer; -// TODO(LLVM 22): Remove this check -#ifndef _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB - static_assert(sizeof(__node_base_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == - _LIBCPP_ALIGNOF(__node_pointer), - "It looks like you are using std::__hash_table (an implementation detail for the unordered containers) " - "with a fancy pointer type that thas a different representation depending on whether it points to a " - "__hash_table base pointer or a __hash_table node pointer (both of which are implementation details of " - "the standard library). This means that your ABI is being broken between LLVM 19 and LLVM 20. If you " - "don't care about your ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to " - "silence this diagnostic."); -#endif - __next_pointer __next_; _LIBCPP_HIDE_FROM_ABI __next_pointer __ptr() _NOEXCEPT { diff --git a/libcxx/include/__iterator/common_iterator.h b/libcxx/include/__iterator/common_iterator.h index a59063d245d9c..79c26e49a1d0a 100644 --- a/libcxx/include/__iterator/common_iterator.h +++ b/libcxx/include/__iterator/common_iterator.h @@ -17,6 +17,7 @@ #include <__concepts/copyable.h> #include <__concepts/derived_from.h> #include <__concepts/equality_comparable.h> +#include <__concepts/referenceable.h> #include <__concepts/same_as.h> #include <__config> #include <__iterator/concepts.h> @@ -28,7 +29,6 @@ #include <__memory/addressof.h> #include <__type_traits/conditional.h> #include <__type_traits/is_pointer.h> -#include <__type_traits/is_referenceable.h> #include <__utility/declval.h> #include diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h index f38688734b38a..e0a839ff74435 100644 --- a/libcxx/include/__iterator/concepts.h +++ b/libcxx/include/__iterator/concepts.h @@ -20,6 +20,7 @@ #include <__concepts/invocable.h> #include <__concepts/movable.h> #include <__concepts/predicate.h> +#include <__concepts/referenceable.h> #include <__concepts/regular.h> #include <__concepts/relation.h> #include <__concepts/same_as.h> @@ -40,7 +41,6 @@ #include <__type_traits/is_pointer.h> #include <__type_traits/is_primary_template.h> #include <__type_traits/is_reference.h> -#include <__type_traits/is_referenceable.h> #include <__type_traits/is_valid_expansion.h> #include <__type_traits/remove_cv.h> #include <__type_traits/remove_cvref.h> @@ -117,15 +117,12 @@ template concept __signed_integer_like = signed_integral<_Tp>; template -concept weakly_incrementable = - // TODO: remove this once the clang bug is fixed (https://llvm.org/PR48173). - !same_as<_Ip, bool> && // Currently, clang does not handle bool correctly. - movable<_Ip> && requires(_Ip __i) { - typename iter_difference_t<_Ip>; - requires __signed_integer_like>; - { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving - __i++; // not required to be equality-preserving - }; +concept weakly_incrementable = movable<_Ip> && requires(_Ip __i) { + typename iter_difference_t<_Ip>; + requires __signed_integer_like>; + { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving + __i++; // not required to be equality-preserving +}; // [iterator.concept.inc] template diff --git a/libcxx/include/__iterator/iter_move.h b/libcxx/include/__iterator/iter_move.h index 5cc16152593c3..bcc75dfe97177 100644 --- a/libcxx/include/__iterator/iter_move.h +++ b/libcxx/include/__iterator/iter_move.h @@ -11,10 +11,10 @@ #define _LIBCPP___ITERATOR_ITER_MOVE_H #include <__concepts/class_or_enum.h> +#include <__concepts/referenceable.h> #include <__config> #include <__iterator/iterator_traits.h> #include <__type_traits/is_reference.h> -#include <__type_traits/is_referenceable.h> #include <__type_traits/remove_cvref.h> #include <__utility/declval.h> #include <__utility/forward.h> diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h index ebf315a53b6b7..2517c385b8bff 100644 --- a/libcxx/include/__iterator/iterator_traits.h +++ b/libcxx/include/__iterator/iterator_traits.h @@ -15,6 +15,7 @@ #include <__concepts/convertible_to.h> #include <__concepts/copyable.h> #include <__concepts/equality_comparable.h> +#include <__concepts/referenceable.h> #include <__concepts/same_as.h> #include <__concepts/totally_ordered.h> #include <__config> @@ -32,7 +33,6 @@ #include <__type_traits/is_object.h> #include <__type_traits/is_primary_template.h> #include <__type_traits/is_reference.h> -#include <__type_traits/is_referenceable.h> #include <__type_traits/nat.h> #include <__type_traits/remove_const.h> #include <__type_traits/remove_cv.h> diff --git a/libcxx/include/__math/traits.h b/libcxx/include/__math/traits.h index 00db2a8289fb3..ff22cee7305d7 100644 --- a/libcxx/include/__math/traits.h +++ b/libcxx/include/__math/traits.h @@ -25,33 +25,26 @@ namespace __math { // signbit -// TODO(LLVM 22): Remove conditional once support for Clang 19 is dropped. -#if defined(_LIBCPP_COMPILER_GCC) || __has_constexpr_builtin(__builtin_signbit) -# define _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_CONSTEXPR_SINCE_CXX23 -#else -# define _LIBCPP_SIGNBIT_CONSTEXPR -#endif - // The universal C runtime (UCRT) in the WinSDK provides floating point overloads // for std::signbit(). By defining our overloads as templates, we can work around // this issue as templates are less preferred than non-template functions. template -[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(float __x) _NOEXCEPT { return __builtin_signbit(__x); } template -[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(double __x) _NOEXCEPT { return __builtin_signbit(__x); } template -[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(long double __x) _NOEXCEPT { return __builtin_signbit(__x); } template ::value, int> = 0> -[[__nodiscard__]] inline _LIBCPP_SIGNBIT_CONSTEXPR _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { +[[__nodiscard__]] inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI bool signbit(_A1 __x) _NOEXCEPT { return __x < 0; } diff --git a/libcxx/include/__ranges/transform_view.h b/libcxx/include/__ranges/transform_view.h index ae85dfa452d72..98b38dd9b2aa1 100644 --- a/libcxx/include/__ranges/transform_view.h +++ b/libcxx/include/__ranges/transform_view.h @@ -13,10 +13,10 @@ #include <__compare/three_way_comparable.h> #include <__concepts/constructible.h> #include <__concepts/convertible_to.h> -#include <__concepts/copyable.h> #include <__concepts/derived_from.h> #include <__concepts/equality_comparable.h> #include <__concepts/invocable.h> +#include <__concepts/referenceable.h> #include <__config> #include <__functional/bind_back.h> #include <__functional/invoke.h> @@ -38,7 +38,6 @@ #include <__type_traits/is_nothrow_constructible.h> #include <__type_traits/is_object.h> #include <__type_traits/is_reference.h> -#include <__type_traits/is_referenceable.h> #include <__type_traits/maybe_const.h> #include <__type_traits/remove_cvref.h> #include <__utility/forward.h> @@ -64,7 +63,7 @@ concept __regular_invocable_with_range_ref = regular_invocable<_Fn, range_refere template concept __transform_view_constraints = view<_View> && is_object_v<_Fn> && regular_invocable<_Fn&, range_reference_t<_View>> && - __is_referenceable_v>>; + __referenceable>>; # if _LIBCPP_STD_VER >= 23 template diff --git a/libcxx/include/__ranges/zip_transform_view.h b/libcxx/include/__ranges/zip_transform_view.h index 07aa182f2858f..c56632a2608a1 100644 --- a/libcxx/include/__ranges/zip_transform_view.h +++ b/libcxx/include/__ranges/zip_transform_view.h @@ -17,6 +17,7 @@ #include <__concepts/derived_from.h> #include <__concepts/equality_comparable.h> #include <__concepts/invocable.h> +#include <__concepts/referenceable.h> #include <__functional/invoke.h> #include <__iterator/concepts.h> #include <__iterator/incrementable_traits.h> @@ -33,7 +34,6 @@ #include <__type_traits/invoke.h> #include <__type_traits/is_object.h> #include <__type_traits/is_reference.h> -#include <__type_traits/is_referenceable.h> #include <__type_traits/maybe_const.h> #include <__type_traits/remove_cvref.h> #include <__utility/forward.h> diff --git a/libcxx/include/__tree b/libcxx/include/__tree index d7d074a00f555..f2eb48cfcf52b 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -823,18 +823,6 @@ public: using __node_allocator _LIBCPP_NODEBUG = __rebind_alloc<__alloc_traits, __node>; using __node_traits _LIBCPP_NODEBUG = allocator_traits<__node_allocator>; -// TODO(LLVM 22): Remove this check -#ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB - static_assert(sizeof(__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) == - _LIBCPP_ALIGNOF(__end_node_pointer), - "It looks like you are using std::__tree (an implementation detail for (multi)map/set) with a fancy " - "pointer type that thas a different representation depending on whether it points to a __tree base " - "pointer or a __tree node pointer (both of which are implementation details of the standard library). " - "This means that your ABI is being broken between LLVM 19 and LLVM 20. If you don't care about your " - "ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to silence this " - "diagnostic."); -#endif - private: // check for sane allocator pointer rebinding semantics. Rebinding the // allocator for a new pointer type should be exactly the same as rebinding diff --git a/libcxx/include/__type_traits/add_pointer.h b/libcxx/include/__type_traits/add_pointer.h index fa9376699a74a..09d92ed3a647e 100644 --- a/libcxx/include/__type_traits/add_pointer.h +++ b/libcxx/include/__type_traits/add_pointer.h @@ -10,9 +10,6 @@ #define _LIBCPP___TYPE_TRAITS_ADD_POINTER_H #include <__config> -#include <__type_traits/is_referenceable.h> -#include <__type_traits/is_void.h> -#include <__type_traits/remove_reference.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -20,40 +17,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) - template struct _LIBCPP_NO_SPECIALIZATIONS add_pointer { using type _LIBCPP_NODEBUG = __add_pointer(_Tp); }; -# ifdef _LIBCPP_COMPILER_GCC +#ifdef _LIBCPP_COMPILER_GCC template using __add_pointer_t _LIBCPP_NODEBUG = typename add_pointer<_Tp>::type; -# else -template -using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp); -# endif - #else -template || is_void<_Tp>::value> -struct __add_pointer_impl { - using type _LIBCPP_NODEBUG = __libcpp_remove_reference_t<_Tp>*; -}; -template -struct __add_pointer_impl<_Tp, false> { - using type _LIBCPP_NODEBUG = _Tp; -}; - template -using __add_pointer_t = typename __add_pointer_impl<_Tp>::type; - -template -struct _LIBCPP_NO_SPECIALIZATIONS add_pointer { - using type _LIBCPP_NODEBUG = __add_pointer_t<_Tp>; -}; - -#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) +using __add_pointer_t _LIBCPP_NODEBUG = __add_pointer(_Tp); +#endif #if _LIBCPP_STD_VER >= 14 template diff --git a/libcxx/include/__type_traits/reference_constructs_from_temporary.h b/libcxx/include/__type_traits/reference_constructs_from_temporary.h index 2ff549b4e15ce..3d097ce90cb09 100644 --- a/libcxx/include/__type_traits/reference_constructs_from_temporary.h +++ b/libcxx/include/__type_traits/reference_constructs_from_temporary.h @@ -30,14 +30,8 @@ _LIBCPP_NO_SPECIALIZATIONS inline constexpr bool reference_constructs_from_tempo #endif -#if __has_builtin(__reference_constructs_from_temporary) template inline const bool __reference_constructs_from_temporary_v = __reference_constructs_from_temporary(_Tp, _Up); -#else -// TODO(LLVM 22): Remove this as all supported compilers should have __reference_constructs_from_temporary implemented. -template -inline const bool __reference_constructs_from_temporary_v = __reference_binds_to_temporary(_Tp, _Up); -#endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/remove_pointer.h b/libcxx/include/__type_traits/remove_pointer.h index 975ed43047dee..bbd80e86a643c 100644 --- a/libcxx/include/__type_traits/remove_pointer.h +++ b/libcxx/include/__type_traits/remove_pointer.h @@ -17,31 +17,18 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer) template struct _LIBCPP_NO_SPECIALIZATIONS remove_pointer { using type _LIBCPP_NODEBUG = __remove_pointer(_Tp); }; -# ifdef _LIBCPP_COMPILER_GCC +#ifdef _LIBCPP_COMPILER_GCC template using __remove_pointer_t _LIBCPP_NODEBUG = typename remove_pointer<_Tp>::type; -# else -template -using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp); -# endif #else -// clang-format off -template struct remove_pointer {using type _LIBCPP_NODEBUG = _Tp;}; -template struct remove_pointer<_Tp*> {using type _LIBCPP_NODEBUG = _Tp;}; -template struct remove_pointer<_Tp* const> {using type _LIBCPP_NODEBUG = _Tp;}; -template struct remove_pointer<_Tp* volatile> {using type _LIBCPP_NODEBUG = _Tp;}; -template struct remove_pointer<_Tp* const volatile> {using type _LIBCPP_NODEBUG = _Tp;}; -// clang-format on - template -using __remove_pointer_t = typename remove_pointer<_Tp>::type; -#endif // !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__remove_pointer) +using __remove_pointer_t _LIBCPP_NODEBUG = __remove_pointer(_Tp); +#endif #if _LIBCPP_STD_VER >= 14 template diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list index df7da20cfb611..88d863f494e86 100644 --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -284,17 +284,6 @@ struct __forward_node_traits { typedef _NodePtr __node_pointer; typedef __forward_begin_node<_NodePtr> __begin_node; typedef __rebind_pointer_t<_NodePtr, __begin_node> __begin_node_pointer; - -// TODO(LLVM 22): Remove this check -# ifndef _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB - static_assert(sizeof(__begin_node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__begin_node_pointer) == - _LIBCPP_ALIGNOF(__node_pointer), - "It looks like you are using std::forward_list with a fancy pointer type that thas a different " - "representation depending on whether it points to a forward_list base pointer or a forward_list node " - "pointer (both of which are implementation details of the standard library). This means that your ABI " - "is being broken between LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define " - "the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); -# endif }; template diff --git a/libcxx/include/list b/libcxx/include/list index c5c2a8508999c..0ff85d2ebcb86 100644 --- a/libcxx/include/list +++ b/libcxx/include/list @@ -276,17 +276,6 @@ template struct __list_node_pointer_traits { typedef __rebind_pointer_t<_VoidPtr, __list_node<_Tp, _VoidPtr> > __node_pointer; typedef __rebind_pointer_t<_VoidPtr, __list_node_base<_Tp, _VoidPtr> > __base_pointer; - -// TODO(LLVM 22): Remove this check -# ifndef _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB - static_assert(sizeof(__node_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__base_pointer) == - _LIBCPP_ALIGNOF(__node_pointer), - "It looks like you are using std::list with a fancy pointer type that thas a different representation " - "depending on whether it points to a list base pointer or a list node pointer (both of which are " - "implementation details of the standard library). This means that your ABI is being broken between " - "LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the " - "_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic."); -# endif }; template diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in index 894093b409e11..3443f63ef5b55 100644 --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -265,10 +265,6 @@ module std_core [system] { header "__type_traits/is_reference.h" export std_core.type_traits.integral_constant } - module is_referenceable { - header "__type_traits/is_referenceable.h" - export std_core.type_traits.integral_constant - } module is_replaceable { header "__type_traits/is_replaceable.h" export std_core.type_traits.integral_constant @@ -1079,6 +1075,7 @@ module std [system] { module invocable { header "__concepts/invocable.h" } module movable { header "__concepts/movable.h" } module predicate { header "__concepts/predicate.h" } + module referenceable { header "__concepts/referenceable.h" } module regular { header "__concepts/regular.h" } module relation { header "__concepts/relation.h" } module same_as { header "__concepts/same_as.h" } diff --git a/libcxx/include/tuple b/libcxx/include/tuple index b0d0c38b115a2..964749d9b9fbc 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -302,7 +302,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool __tuple_compare_equal(c template >> inline constexpr bool __can_tuple_compare_equal = false; -// TODO(LLVM 22): Remove `tuple_size_v<_Tp> == tuple_size_v<_Up>` here once once LLVM-20 support ends +// TODO(LLVM 23): Remove `tuple_size_v<_Tp> == tuple_size_v<_Up>` here once once LLVM-20 support ends // because the resolution of CWG2369 landed in LLVM-21. template requires(tuple_size_v<_Tp> == tuple_size_v<_Up>) @@ -329,7 +329,7 @@ concept __tuple_like_no_tuple = __tuple_like<_Tp> && !__is_tuple_v<_Tp>; template struct __tuple_common_comparison_category_impl {}; -// TODO(LLVM 22): Remove `tuple_size_v<_Tp> == tuple_size_v<_Up>` here once once LLVM-20 support ends +// TODO(LLVM 23): Remove `tuple_size_v<_Tp> == tuple_size_v<_Up>` here once once LLVM-20 support ends // because the resolution of CWG2369 landed in LLVM-21. template requires(tuple_size_v<_Tp> == tuple_size_v<_Up>) && requires { diff --git a/libcxx/include/variant b/libcxx/include/variant index 9beef146f203c..8e958581a6b07 100644 --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -1299,7 +1299,7 @@ public: __impl_.__swap(__that.__impl_); } -# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# if _LIBCPP_STD_VER >= 26 // Helper class to implement [variant.visit]/10 // Constraints: The call to visit does not use an explicit template-argument-list // that begins with a type template-argument. diff --git a/libcxx/test/libcxx-03/utilities/meta/is_referenceable.compile.pass.cpp b/libcxx/test/libcxx-03/utilities/meta/is_referenceable.compile.pass.cpp index 093bbae289723..f39d1a5da41af 100644 --- a/libcxx/test/libcxx-03/utilities/meta/is_referenceable.compile.pass.cpp +++ b/libcxx/test/libcxx-03/utilities/meta/is_referenceable.compile.pass.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// // -// __is_referenceable_v +// __libcpp_is_referenceable // // [defns.referenceable] defines "a referenceable type" as: // An object type, a function type that does not have cv-qualifiers diff --git a/libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp b/libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp index 3f17f21e8c108..20887b8cf2678 100644 --- a/libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp +++ b/libcxx/test/libcxx/numerics/c.math/constexpr-cxx23-clang.pass.cpp @@ -220,16 +220,9 @@ int main(int, char**) { ASSERT_CONSTEXPR_CXX23(std::isnormal(-1.0) == 1); ASSERT_CONSTEXPR_CXX23(std::isnormal(-1.0L) == 1); -// TODO(LLVM 22): Remove `__has_constexpr_builtin` conditional once support for Clang 19 is dropped. -#if !__has_constexpr_builtin(__builtin_signbit) - ASSERT_NOT_CONSTEXPR_CXX23(std::signbit(-1.0f) == 1); - ASSERT_NOT_CONSTEXPR_CXX23(std::signbit(-1.0) == 1); - ASSERT_NOT_CONSTEXPR_CXX23(std::signbit(-1.0L) == 1); -#else ASSERT_CONSTEXPR_CXX23(std::signbit(-1.0f) == 1); ASSERT_CONSTEXPR_CXX23(std::signbit(-1.0) == 1); ASSERT_CONSTEXPR_CXX23(std::signbit(-1.0L) == 1); -#endif ASSERT_NOT_CONSTEXPR_CXX23(std::isgreater(-1.0f, 0.0f) == 0); ASSERT_NOT_CONSTEXPR_CXX23(std::isgreater(-1.0, 0.0) == 0); diff --git a/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp index 09ebd0069b3a9..3e9bdd98cd394 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp @@ -8,15 +8,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 -// With clang-cl, some warnings have a 'which is a Microsoft extension' suffix -// which break the tests. But #102851 will turn it into an error, making the test pass. -// However, upstream libcxx buildbots do not build clang from source while testing, so -// this tests still expected to fail on these bots. -// -// TODO(LLVM 22): Remove '0-1' from 'expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}}' -// and remove 'expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}}' -// once LLVM 22 releases. See https://llvm.org/PR104885. - // Test the mandates // template constexpr auto transform_error(F&& f) &; @@ -55,41 +46,39 @@ void test() { { std::expected e; e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} // expected-error-re@*:* {{static assertion failed {{.*}}[expected.object.general] A program that instantiates the definition of template expected for {{.*}} is ill-formed.}} - // expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}} + // expected-error-re@*:* {{union member {{.*}} has reference type {{.*}}}} e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} // expected-error-re@*:* {{static assertion failed {{.*}}[expected.object.general] A program that instantiates the definition of template expected for {{.*}} is ill-formed.}} - // expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}} } // Test const& overload { const std::expected e; e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-2 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-2 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} } // Test && overload { std::expected e; std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-2 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-2 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} } // Test const&& overload { const std::expected e; std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-2 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-2 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} } } // clang-format on diff --git a/libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp index 9fd7452af64fb..c5acc27af03ea 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp @@ -8,16 +8,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 -// With clang-cl, some warnings have a 'which is a Microsoft extension' suffix -// which break the tests. But #102851 will turn it into an error, making the test pass. -// However, upstream libcxx buildbots do not build clang from source while testing, so -// this tests still expected to fail on these bots. -// -// TODO(LLVM 22): Remove '0-1' from 'expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}}' -// and remove 'expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}}' -// and remove 'expected-error-re@*:* 0-1 {{call to deleted constructor of {{.*}}}}' -// once LLVM 22 releases. See See https://llvm.org/PR104885. - // Test the mandates // template constexpr auto transform_error(F&& f) &; @@ -56,43 +46,36 @@ void test() { { std::expected e; e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} // expected-error-re@*:* {{static assertion failed {{.*}}A program that instantiates expected with a E that is not a valid argument for unexpected is ill-formed}} - // expected-error-re@*:* 0-1 {{call to deleted constructor of {{.*}}}} - // expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}} + // expected-error-re@*:* {{union member {{.*}} has reference type {{.*}}}} e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} // expected-error-re@*:* {{static assertion failed {{.*}}A program that instantiates expected with a E that is not a valid argument for unexpected is ill-formed}} - // expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}} } // Test const& overload { const std::expected e; e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} - // expected-error-re@*:* 0-1 {{call to deleted constructor of {{.*}}}} + // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} } // Test && overload { std::expected e; std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} } // Test const&& overload { const std::expected e; std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} - // expected-error-re@*:* 0-1 {{no matching constructor for initialization of{{.*}}}} } } // clang-format on diff --git a/libcxx/test/libcxx/utilities/meta/is_referenceable.compile.pass.cpp b/libcxx/test/libcxx/utilities/meta/is_referenceable.compile.pass.cpp deleted file mode 100644 index c230f6e16e0a2..0000000000000 --- a/libcxx/test/libcxx/utilities/meta/is_referenceable.compile.pass.cpp +++ /dev/null @@ -1,190 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// - -// __is_referenceable_v -// -// [defns.referenceable] defines "a referenceable type" as: -// An object type, a function type that does not have cv-qualifiers -// or a ref-qualifier, or a reference type. -// - -#include -#include - -#include "test_macros.h" - -struct Foo {}; - -static_assert((!std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); - -// Functions without cv-qualifiers are referenceable -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -static_assert((!std::__is_referenceable_v), ""); -#endif - -// member functions with or without cv-qualifiers are referenceable -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif - -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#if TEST_STD_VER >= 11 -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -static_assert((std::__is_referenceable_v), ""); -#endif diff --git a/libcxx/test/libcxx/utilities/meta/referenceable.compile.pass.cpp b/libcxx/test/libcxx/utilities/meta/referenceable.compile.pass.cpp new file mode 100644 index 0000000000000..e6a74c789bd3d --- /dev/null +++ b/libcxx/test/libcxx/utilities/meta/referenceable.compile.pass.cpp @@ -0,0 +1,155 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// + +// __referenceable +// +// [defns.referenceable] defines "a referenceable type" as: +// An object type, a function type that does not have cv-qualifiers +// or a ref-qualifier, or a reference type. +// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +#include <__concepts/referenceable.h> + +struct Foo {}; + +static_assert(!std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +// Functions without cv-qualifiers are referenceable +static_assert(std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); + +static_assert(std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); + +static_assert(std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); + +static_assert(std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); + +static_assert(std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); + +static_assert(std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); + +static_assert(std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); + +static_assert(std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); +static_assert(!std::__referenceable); + +// member functions with or without cv-qualifiers are referenceable +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); + +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); +static_assert(std::__referenceable); diff --git a/libcxx/test/std/utilities/format/format.arguments/format.arg/visit.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg/visit.pass.cpp index 20e0a5ed66bd0..68fe8b6de41d6 100644 --- a/libcxx/test/std/utilities/format/format.arguments/format.arg/visit.pass.cpp +++ b/libcxx/test/std/utilities/format/format.arguments/format.arg/visit.pass.cpp @@ -8,8 +8,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// The tested functionality needs deducing this. -// XFAIL: apple-clang // diff --git a/libcxx/test/std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp index 8a79dd4d50f20..4ae63e896caed 100644 --- a/libcxx/test/std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp +++ b/libcxx/test/std/utilities/format/format.arguments/format.arg/visit.return_type.pass.cpp @@ -8,8 +8,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// The tested functionality needs deducing this. -// XFAIL: apple-clang // diff --git a/libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp index 146ceba58872e..77df72d3c4c6c 100644 --- a/libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp +++ b/libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.deprecated.verify.cpp @@ -8,7 +8,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME -// XFAIL: apple-clang // diff --git a/libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp index d99675a71f321..9b7c8a7f4f8b4 100644 --- a/libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp +++ b/libcxx/test/std/utilities/format/format.arguments/format.arg/visit_format_arg.pass.cpp @@ -9,6 +9,8 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17 // UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME +// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS + // // template @@ -25,10 +27,6 @@ #include "make_string.h" #include "min_allocator.h" -#if TEST_STD_VER >= 26 && defined(TEST_HAS_EXPLICIT_THIS_PARAMETER) -TEST_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations") -#endif - template void test(From value) { auto store = std::make_format_args(value); diff --git a/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp b/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp index c7dd82d726b3a..cbddc4f437a53 100644 --- a/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp +++ b/libcxx/test/std/utilities/format/format.arguments/format.args/get.pass.cpp @@ -32,7 +32,7 @@ void test(From value) { else assert(false); }; -#if TEST_STD_VER >= 26 && defined(TEST_HAS_EXPLICIT_THIS_PARAMETER) +#if TEST_STD_VER >= 26 format_args.get(0).visit(visitor); #else std::visit_format_arg(visitor, format_args.get(0)); @@ -47,7 +47,7 @@ void test_handle(T value) { std::basic_format_args format_args{store}; auto visitor = [](auto a) { assert((std::is_same_v::handle>)); }; -#if TEST_STD_VER >= 26 && defined(TEST_HAS_EXPLICIT_THIS_PARAMETER) +#if TEST_STD_VER >= 26 format_args.get(0).visit(visitor); #else std::visit_format_arg(visitor, format_args.get(0)); @@ -73,7 +73,7 @@ void test_string_view(From value) { else assert(false); }; -#if TEST_STD_VER >= 26 && defined(TEST_HAS_EXPLICIT_THIS_PARAMETER) +#if TEST_STD_VER >= 26 format_args.get(0).visit(visitor); #else std::visit_format_arg(visitor, format_args.get(0)); diff --git a/libcxx/test/std/utilities/meta/meta.trans/objc_support.compile.pass.mm b/libcxx/test/std/utilities/meta/meta.trans/objc_support.compile.pass.mm index 1d252a129483b..c6f435bddd26a 100644 --- a/libcxx/test/std/utilities/meta/meta.trans/objc_support.compile.pass.mm +++ b/libcxx/test/std/utilities/meta/meta.trans/objc_support.compile.pass.mm @@ -13,8 +13,13 @@ // XFAIL: FROZEN-CXX03-HEADERS-FIXME #include + #include "test_macros.h" +#if TEST_STD_VER >= 20 && defined(_LIBCPP_VERSION) +# include <__concepts/referenceable.h> +#endif + @interface I; @end @@ -35,15 +40,17 @@ @interface I; static_assert(std::is_same::type, I>::value, ""); static_assert(std::is_same::type, id*>::value, ""); -// __is_referenceable_v -LIBCPP_STATIC_ASSERT(std::__is_referenceable_v, ""); -LIBCPP_STATIC_ASSERT(std::__is_referenceable_v, ""); -LIBCPP_STATIC_ASSERT(std::__is_referenceable_v, ""); -LIBCPP_STATIC_ASSERT(std::__is_referenceable_v, ""); -LIBCPP_STATIC_ASSERT(std::__is_referenceable_v, ""); -LIBCPP_STATIC_ASSERT(std::__is_referenceable_v, ""); -LIBCPP_STATIC_ASSERT(std::__is_referenceable_v, ""); -LIBCPP_STATIC_ASSERT(std::__is_referenceable_v, ""); +#if TEST_STD_VER >= 20 +// __referenceable +LIBCPP_STATIC_ASSERT(std::__referenceable, ""); +LIBCPP_STATIC_ASSERT(std::__referenceable, ""); +LIBCPP_STATIC_ASSERT(std::__referenceable, ""); +LIBCPP_STATIC_ASSERT(std::__referenceable, ""); +LIBCPP_STATIC_ASSERT(std::__referenceable, ""); +LIBCPP_STATIC_ASSERT(std::__referenceable, ""); +LIBCPP_STATIC_ASSERT(std::__referenceable, ""); +LIBCPP_STATIC_ASSERT(std::__referenceable, ""); +#endif // remove_all_extents static_assert(std::is_same::type, id>::value, ""); diff --git a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp index d78de0eec8e53..0f6a6734264c3 100644 --- a/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp +++ b/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp @@ -16,17 +16,6 @@ #include #include #include -#include "test_macros.h" - -#if TEST_HAS_BUILTIN(__reference_constructs_from_temporary) -# define ASSERT_REFERENCE_BINDS_TEMPORARY(...) static_assert(__reference_constructs_from_temporary(__VA_ARGS__), "") -# define ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(...) \ - static_assert(!__reference_constructs_from_temporary(__VA_ARGS__), "") -#else -// TODO(LLVM 22): Remove this as all support compilers should have __reference_constructs_from_temporary implemented. -# define ASSERT_REFERENCE_BINDS_TEMPORARY(...) static_assert(__reference_binds_to_temporary(__VA_ARGS__), "") -# define ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(...) static_assert(!__reference_binds_to_temporary(__VA_ARGS__), "") -#endif template struct ConvertsTo { @@ -42,17 +31,6 @@ struct ConvertsTo { struct Base {}; struct Derived : Base {}; - -static_assert(std::is_same::value, ""); -ASSERT_REFERENCE_BINDS_TEMPORARY(std::string const&, decltype("abc")); -ASSERT_REFERENCE_BINDS_TEMPORARY(std::string const&, decltype(("abc"))); -ASSERT_REFERENCE_BINDS_TEMPORARY(std::string const&, const char*&&); - -ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(int&, const ConvertsTo&); -ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(const int&, ConvertsTo&); -ASSERT_NOT_REFERENCE_BINDS_TEMPORARY(Base&, Derived&); - - static_assert(std::is_constructible>::value, ""); static_assert(std::is_constructible>::value, ""); diff --git a/libcxx/test/std/utilities/variant/variant.visit.member/robust_against_adl.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit.member/robust_against_adl.pass.cpp index 7be7c7ff9122b..38cf34a9c699c 100644 --- a/libcxx/test/std/utilities/variant/variant.visit.member/robust_against_adl.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit.member/robust_against_adl.pass.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 -// XFAIL: apple-clang // diff --git a/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp index f68112d30fc35..aeb1297c136ae 100644 --- a/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit.member/visit.pass.cpp @@ -7,8 +7,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 -// The tested functionality needs deducing this. -// XFAIL: apple-clang // diff --git a/libcxx/test/std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp b/libcxx/test/std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp index 90320ae518c34..7ca05908ab340 100644 --- a/libcxx/test/std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp +++ b/libcxx/test/std/utilities/variant/variant.visit.member/visit_return_type.pass.cpp @@ -7,8 +7,6 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23 -// The tested functionality needs deducing this. -// XFAIL: apple-clang // diff --git a/libcxx/test/support/test_basic_format_arg.h b/libcxx/test/support/test_basic_format_arg.h index f51f6e97cbed0..99cd558c3c5bf 100644 --- a/libcxx/test/support/test_basic_format_arg.h +++ b/libcxx/test/support/test_basic_format_arg.h @@ -21,7 +21,7 @@ bool test_basic_format_arg(std::basic_format_arg arg, T expected) { else return false; }; -#if TEST_STD_VER >= 26 && defined(TEST_HAS_EXPLICIT_THIS_PARAMETER) +#if TEST_STD_VER >= 26 return arg.visit(std::move(visitor)); #else return std::visit_format_arg(std::move(visitor), arg); diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h index 2fc25fc024ac1..ff1d0e4d8ff1d 100644 --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -525,13 +525,6 @@ inline Tp const& DoNotOptimize(Tp const& value) { # define TEST_IF_AIX(arg_true, arg_false) arg_false #endif -// Clang-18 has support for deducing this, but it does not set the FTM. -#ifdef _LIBCPP_USE_FROZEN_CXX03_HEADERS -// This is a C++20 featue, so we don't care whether the compiler could support it -#elif defined(_LIBCPP_VERSION) && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER -# define TEST_HAS_EXPLICIT_THIS_PARAMETER -#endif - // Placement `operator new`/`operator new[]` are not yet constexpr in C++26 // when using MS ABI, because they are from . #if defined(__cpp_lib_constexpr_new) && __cpp_lib_constexpr_new >= 202406L