[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// 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 +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV& +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT +# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false +#endif + +#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]] +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +#endif + +template +class move_only_function; + +template +class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT( +_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> { +private: + static constexpr size_t __buffer_size_ = 3 * sizeof(void*); + static constexpr size_t __buffer_alignment_ = alignof(void*); + using _BufferT = __small_buffer<__buffer_size_, __buffer_alignment_>; + + using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + + template + static constexpr _TrivialVTable __trivial_vtable_ = { + .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT { +return std::invoke_r<_ReturnT>( +static_cast<_Functor _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()), +std::forward<_ArgTypes>(__args)...); + }}; + + template + static constexpr _NonTrivialVTable __non_trivial_vtable_{ + __trivial_vtable_<_Functor>, + [](_BufferT& __buffer) noexcept -> void { +std::destroy_at(__buffer.__get<_Functor>()); +__buffer.__dealloc<_Functor>(); + }, + }; + + template + _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair __get_vptr() { +if constexpr (_BufferT::__fits_in_buffer<_Functor> && is_trivially_destructible_v<_Functor>) { + return {&__trivial_vtable_<_Functor>, false}; +} else { + return {&__non_trivial_vtable_<_Functor>, true}; +} + } + + template + static constexpr bool __is_callable_from = [] { +using _DVT = decay_t<_VT>; +if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) { + return is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} else { + return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} + }(); + + template + _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) { +static_assert(is_constructible_v, _Func>); + +using _StoredFunc = decay_t<_Func>; +__vtable_ = __get_vptr<_StoredFunc>(); +__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...); + } + + _LIBCPP_HIDE_FROM_ABI void __reset() { +if (__vtable_.__get_value()) philnik777 wrote: Did you mean to write something? https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// 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 +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF philnik777 wrote: Can you give an example? A few people already claimed that it gives terrible diagnostics, but I've yet to see one. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,46 @@ +//===--===// +// +// 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 +// +//===--===// + +#ifndef _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H +#define _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class move_only_function; + +template +struct __is_move_only_function : false_type {}; + +template +struct __is_move_only_function> : true_type {}; + +template +struct _MoveOnlyFunctionTrivialVTable { + using _CallFunc = _ReturnT(_BufferT&, _ArgTypes...); + + _CallFunc* __call_; +}; + +template +struct _MoveOnlyFunctionNonTrivialVTable : _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...> { philnik777 wrote: Could you elaborate? I don't see how we can have the vtable function pointer without the template arguments. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,46 @@ +//===--===// +// +// 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 +// +//===--===// + +#ifndef _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H +#define _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_COMMON_H + +#include <__config> +#include <__type_traits/integral_constant.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class move_only_function; + +template +struct __is_move_only_function : false_type {}; + +template +struct __is_move_only_function> : true_type {}; + +template +struct _MoveOnlyFunctionTrivialVTable { + using _CallFunc = _ReturnT(_BufferT&, _ArgTypes...); + + _CallFunc* __call_; +}; + +template +struct _MoveOnlyFunctionNonTrivialVTable : _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...> { philnik777 wrote: The call function pointer is in the base class though. I always want the call pointer and only sometimes the destructor pointer. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
philnik777 wrote: @EricWF When switching to `__libcpp_operator_{new,delete}` everything gets compiled exactly the same on my system. Could you disclose which test you used for this code? You also claim that the `__pointer_int_pair` causes the optimizer to lose track of the function pointer causing the call to not be elided, but I can't see any calls other than `new` and `delete` in the code you posted either. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// 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 +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV& +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT +# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false +#endif + +#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]] +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +#endif + +template +class move_only_function; + +template +class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT( +_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> { +private: + static constexpr size_t __buffer_size_ = 3 * sizeof(void*); + static constexpr size_t __buffer_alignment_ = alignof(void*); + using _BufferT = __small_buffer<__buffer_size_, __buffer_alignment_>; + + using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + + template + static constexpr _TrivialVTable __trivial_vtable_ = { + .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT { +return std::invoke_r<_ReturnT>( +static_cast<_Functor _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()), +std::forward<_ArgTypes>(__args)...); + }}; + + template + static constexpr _NonTrivialVTable __non_trivial_vtable_{ + __trivial_vtable_<_Functor>, + [](_BufferT& __buffer) noexcept -> void { +std::destroy_at(__buffer.__get<_Functor>()); +__buffer.__dealloc<_Functor>(); + }, + }; + + template + _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair __get_vptr() { +if constexpr (_BufferT::__fits_in_buffer<_Functor> && is_trivially_destructible_v<_Functor>) { + return {&__trivial_vtable_<_Functor>, false}; +} else { + return {&__non_trivial_vtable_<_Functor>, true}; +} + } + + template + static constexpr bool __is_callable_from = [] { +using _DVT = decay_t<_VT>; +if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) { + return is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} else { + return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} + }(); + + template + _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) { +static_assert(is_constructible_v, _Func>); + +using _StoredFunc = decay_t<_Func>; +__vtable_ = __get_vptr<_StoredFunc>(); +__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...); + } + + _LIBCPP_HIDE_FROM_ABI void __reset() { +if (__vtable_.__get_value()) philnik777 wrote: The `bool` is in the low bit of the pointer to avoid the need to even look at the vtable in the destructor. The cost of zeroing the lower bits of the pointer is pretty much non-existent on modern platforms (the delay is at most a single cycle - most likely not even
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// 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 +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV& +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT +# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false +#endif + +#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]] +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +#endif + +template +class move_only_function; + +template +class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT( +_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> { +private: + static constexpr size_t __buffer_size_ = 3 * sizeof(void*); + static constexpr size_t __buffer_alignment_ = alignof(void*); + using _BufferT = __small_buffer<__buffer_size_, __buffer_alignment_>; + + using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + + template + static constexpr _TrivialVTable __trivial_vtable_ = { + .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT { +return std::invoke_r<_ReturnT>( +static_cast<_Functor _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()), +std::forward<_ArgTypes>(__args)...); + }}; + + template + static constexpr _NonTrivialVTable __non_trivial_vtable_{ + __trivial_vtable_<_Functor>, + [](_BufferT& __buffer) noexcept -> void { +std::destroy_at(__buffer.__get<_Functor>()); +__buffer.__dealloc<_Functor>(); + }, + }; + + template + _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair __get_vptr() { +if constexpr (_BufferT::__fits_in_buffer<_Functor> && is_trivially_destructible_v<_Functor>) { + return {&__trivial_vtable_<_Functor>, false}; +} else { + return {&__non_trivial_vtable_<_Functor>, true}; +} + } + + template + static constexpr bool __is_callable_from = [] { +using _DVT = decay_t<_VT>; +if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) { + return is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} else { + return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} + }(); + + template + _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) { +static_assert(is_constructible_v, _Func>); + +using _StoredFunc = decay_t<_Func>; +__vtable_ = __get_vptr<_StoredFunc>(); +__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...); + } + + _LIBCPP_HIDE_FROM_ABI void __reset() { +if (__vtable_.__get_value()) philnik777 wrote: Then provide the fucking evidence. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,233 @@ +//===--===// +// +// 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 +// +//===--===// + +// This header is unguarded on purpose. This header is an implementation detail of move_only_function.h +// and generates multiple versions of std::move_only_function + +#include <__config> +#include <__functional/invoke.h> +#include <__functional/move_only_function_common.h> +#include <__type_traits/is_trivially_destructible.h> +#include <__utility/exchange.h> +#include <__utility/forward.h> +#include <__utility/in_place.h> +#include <__utility/move.h> +#include <__utility/pointer_int_pair.h> +#include <__utility/small_buffer.h> +#include <__utility/swap.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#ifndef _LIBCPP_IN_MOVE_ONLY_FUNCTION_H +# error This header should only be included from move_only_function.h +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_CV +# define _LIBCPP_MOVE_ONLY_FUNCTION_CV +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_REF +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV& +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF +#endif + +#ifndef _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT +# define _LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT false +#endif + +#define _LIBCPP_MOVE_ONLY_FUNCTION_CVREF _LIBCPP_MOVE_ONLY_FUNCTION_CV _LIBCPP_MOVE_ONLY_FUNCTION_REF + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifdef _LIBCPP_ABI_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI [[_Clang::__trivial_abi__]] +#else +# define _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI +#endif + +template +class move_only_function; + +template +class _LIBCPP_MOVE_ONLY_FUNCTION_TRIVIAL_ABI move_only_function<_ReturnT( +_ArgTypes...) _LIBCPP_MOVE_ONLY_FUNCTION_CVREF noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT)> { +private: + static constexpr size_t __buffer_size_ = 3 * sizeof(void*); + static constexpr size_t __buffer_alignment_ = alignof(void*); + using _BufferT = __small_buffer<__buffer_size_, __buffer_alignment_>; + + using _TrivialVTable= _MoveOnlyFunctionTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + using _NonTrivialVTable = _MoveOnlyFunctionNonTrivialVTable<_BufferT, _ReturnT, _ArgTypes...>; + + template + static constexpr _TrivialVTable __trivial_vtable_ = { + .__call_ = [](_BufferT& __buffer, _ArgTypes... __args) noexcept(_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) -> _ReturnT { +return std::invoke_r<_ReturnT>( +static_cast<_Functor _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS>(*__buffer.__get<_Functor>()), +std::forward<_ArgTypes>(__args)...); + }}; + + template + static constexpr _NonTrivialVTable __non_trivial_vtable_{ + __trivial_vtable_<_Functor>, + [](_BufferT& __buffer) noexcept -> void { +std::destroy_at(__buffer.__get<_Functor>()); +__buffer.__dealloc<_Functor>(); + }, + }; + + template + _LIBCPP_HIDE_FROM_ABI __pointer_bool_pair __get_vptr() { +if constexpr (_BufferT::__fits_in_buffer<_Functor> && is_trivially_destructible_v<_Functor>) { + return {&__trivial_vtable_<_Functor>, false}; +} else { + return {&__non_trivial_vtable_<_Functor>, true}; +} + } + + template + static constexpr bool __is_callable_from = [] { +using _DVT = decay_t<_VT>; +if (_LIBCPP_MOVE_ONLY_FUNCTION_NOEXCEPT) { + return is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_nothrow_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} else { + return is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_CVREF, _ArgTypes...> && + is_invocable_r_v<_ReturnT, _DVT _LIBCPP_MOVE_ONLY_FUNCTION_INVOKE_QUALS, _ArgTypes...>; +} + }(); + + template + _LIBCPP_HIDE_FROM_ABI void __construct(_Args&&... __args) { +static_assert(is_constructible_v, _Func>); + +using _StoredFunc = decay_t<_Func>; +__vtable_ = __get_vptr<_StoredFunc>(); +__buffer_.__construct<_StoredFunc>(std::forward<_Args>(__args)...); + } + + _LIBCPP_HIDE_FROM_ABI void __reset() { +if (__vtable_.__get_value()) philnik777 wrote: The main thing I'm objecting to currently is Eric's behaviour. He's showing zero evidence for his claims while being extremely patronizing to the point of being insulting [1] and claiming he's got knowledge of other's mental states which he obviously has no access
[llvm-branch-commits] [clang] [libcxx] [clang] Finish implementation of P0522 (PR #96023)
@@ -18,5 +18,9 @@ #include #include -// expected-error@+1 {{template template argument has different template parameters than its corresponding template template parameter}} -static_assert(!std::__is_specialization_v, std::array>); +#if defined(__clang__) && __clang_major__ >= 19 +// expected-error@array:* {{could not match _Size against 'type-parameter-0-0'}} +#else +// expected-error@#SA {{template template argument has different template parameters than its corresponding template template parameter}} +#endif philnik777 wrote: I'd just add an `expected-error@*:*` instead. https://github.com/llvm/llvm-project/pull/96023 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Implement std::move_only_function (P0288R9) (PR #94670)
@@ -0,0 +1,93 @@ +//===--===// +// +// 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 +// +//===--===// + +#ifndef _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_H +#define _LIBCPP___FUNCTIONAL_MOVE_ONLY_FUNCTION_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +#if _LIBCPP_STD_VER >= 23 + +// move_only_function design: +// +// move_only_function has a small buffer with a size of `3 * sizeof(void*)` bytes. This buffer can only be used when the +// object that should be stored is trivially relocatable (currently only when it is trivially move constructible and +// trivially destructible). There is also a bool in the lower bits of the vptr stored which is set when the contained +// object is not trivially destructible. +// +// trivially relocatable: It would also be possible to store nothrow_move_constructible types, but that would mean +// that move_only_function itself would not be trivially relocatable anymore. The decision to keep move_only_function +// trivially relocatable was made because we expect move_only_function to be mostly used to store a functor. To only +// forward functors there is std::function_ref (not voted in yet, expected in C++26). +// +// buffer size: We did a survey of six implementations from various vendors. Three of them had a buffer size of 24 bytes +// on 64 bit systems. This also allows storing a std::string or std::vector inside the small buffer (once the compiler +// has full support of trivially_relocatable annotations). +// +// trivially-destructible bit: This allows us to keep the overall binary size smaller because we don't have to store +// a pointer to a noop function inside the vtable. It also avoids loading the vtable during destruction, potentially +// resulting in fewer cache misses. The downside is that calling the function now also requires setting the lower bits +// of the pointer to zero, but this is a very fast operation on modern CPUs. philnik777 wrote: I'd think so, yes. Fortunately it seems a lot easier in that case, since `function_ref` will probably only store a pointer to the object and a pointer to the function. https://github.com/llvm/llvm-project/pull/94670 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/19.x: [libc++] Add missing xlocale.h include on Apple and FreeBSD (#99689) (PR #100604)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/100604 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release note is nullptr removal (PR #101638)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/101638 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release note is nullptr removal (PR #101638)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/101638 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Clang] Add a release note deprecating __is_nullptr (PR #101638)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/101638 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Clang] Add a release note deprecating __is_nullptr (PR #101638)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/101638 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] b2eab34 - [Clang] Add a release note deprecating __is_nullptr
Author: Nikolas Klauser Date: 2024-08-02T10:53:33+02:00 New Revision: b2eab3486499656ec6ef30ace5033f80d4d9dfc9 URL: https://github.com/llvm/llvm-project/commit/b2eab3486499656ec6ef30ace5033f80d4d9dfc9 DIFF: https://github.com/llvm/llvm-project/commit/b2eab3486499656ec6ef30ace5033f80d4d9dfc9.diff LOG: [Clang] Add a release note deprecating __is_nullptr Added: Modified: clang/docs/ReleaseNotes.rst Removed: diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index b4ef1e9672a5d..c42cb9932f3f7 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -447,6 +447,10 @@ Non-comprehensive list of changes in this release type of the pointer was taken into account. This improves compatibility with GCC's libstdc++. +- The type traits builtin ``__is_nullptr`` is deprecated in CLang 19 and will be + removed in Clang 20. ``__is_same(__remove_cv(T), decltype(nullptr))`` can be + used instead to check whether a type ``T`` is a ``nullptr``. + New Compiler Flags -- - ``-fsanitize=implicit-bitfield-conversion`` checks implicit truncation and @@ -754,7 +758,7 @@ Improvements to Clang's diagnostics - Clang now diagnoses dangling assignments for pointer-like objects (annotated with `[[gsl::Pointer]]`) under `-Wdangling-assignment-gsl` (off by default) Fixes #GH63310. - + - Clang now diagnoses uses of alias templates with a deprecated attribute. (Fixes #GH18236). .. code-block:: c++ ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/19.x: [NFC][libc++][test][AIX] UnXFAIL LIT test transform.pass.cpp (#102338) (PR #102466)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/102466 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] PR for llvm/llvm-project#80718 (PR #80720)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/80720 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Clang][Driver] Add special-casing for including libc++ in C++03 (PR #83723)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/83723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Clang][Driver] Add special-casing for including libc++ in C++03 (PR #83723)
https://github.com/philnik777 closed https://github.com/llvm/llvm-project/pull/83723 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add [[nodiscard]] to (PR #89181)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/89181 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add [[nodiscard]] to (PR #89181)
https://github.com/philnik777 closed https://github.com/llvm/llvm-project/pull/89181 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] 0e823b0 - [libc++] Update libcpp-uglify-attributes to diagnose all attributes in C++03
Author: Nikolas Klauser Date: 2023-12-02T14:04:01+01:00 New Revision: 0e823b02ba8a0f61ddd14bb128cf8e12fe14602a URL: https://github.com/llvm/llvm-project/commit/0e823b02ba8a0f61ddd14bb128cf8e12fe14602a DIFF: https://github.com/llvm/llvm-project/commit/0e823b02ba8a0f61ddd14bb128cf8e12fe14602a.diff LOG: [libc++] Update libcpp-uglify-attributes to diagnose all attributes in C++03 Added: Modified: libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp Removed: diff --git a/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp b/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp index 5252087d55ee9..7812b236f613c 100644 --- a/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp +++ b/libcxx/test/tools/clang_tidy_checks/uglify_attributes.cpp @@ -44,7 +44,12 @@ bool CPlusPlus23(const T& lang_opts) } std::vector get_standard_attributes(const clang::LangOptions& lang_opts) { - std::vector attributes = {"noreturn", "carries_dependency"}; + std::vector attributes; + + if (lang_opts.CPlusPlus11) { +attributes.emplace_back("noreturn"); +attributes.emplace_back("carries_dependency"); + } if (lang_opts.CPlusPlus14) attributes.emplace_back("deprecated"); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][modules] Increase clang-tidy version used. (PR #76268)
https://github.com/philnik777 requested changes to this pull request. I'm really not happy with bumping the clang-tidy version we use all the time to the trunk version. We agreed to using the latest stable version, which we've not done way too many times now. I'd really like to first understand what exactly the issue is that is solved by bumping the version again. https://github.com/llvm/llvm-project/pull/76268 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][modules] Increase clang-tidy version used. (PR #76268)
philnik777 wrote: I'd like to understand what the fixed issues are you're relying on. From what I can tell, this could just as much be a bug in our setup for the clang-tidy plugin as an actual fix in trunk. https://github.com/llvm/llvm-project/pull/76268 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][modules] Increase clang-tidy version used. (PR #76268)
philnik777 wrote: Oh shit. I just realized that this is most likely a latent bug no matter what. We build the module with Clang 18, and then essentially try to load it with Clang 17 (aka Clang Tidy 17). AFAIK that's not guaranteed to work, and probably just happens to work currently with Clang 17 building and Clang 18 loading the module (assuming we even test that right now?). I think we may have to always match the Clang and Clang Tidy versions we use. https://github.com/llvm/llvm-project/pull/76268 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Clang-tidy enable modernize-use-nullptr. (PR #76659)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/76659 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][modules] Increase clang-tidy version used. (PR #76268)
philnik777 wrote: > > Oh shit. I just realized that this is most likely a latent bug no matter > > what. We build the module with Clang 18, and then essentially try to load > > it with Clang 17 (aka Clang Tidy 17). AFAIK that's not guaranteed to work, > > and probably just happens to work currently with Clang 17 building and > > Clang 18 loading the module (assuming we even test that right now?). I > > think we may have to always match the Clang and Clang Tidy versions we use. > > I should probably keep out of these discussions but here I am: Matching Clang > with Clang-Tidy versions feels only natural. For instance "Member visit" > requires new syntax (deducing this) and fixes available in the latest Clang > 18 nightly, so it was surprising to find out the test failing due to > Clang-Tidy being used in the CI. I guess this case happens rarely but this > means working on library features dependant on newly implemented language > features might have to be postponed to the release after. This change doesn't actually help you in this regard. We still support Clang 16 and 17, so the CI would have simply failed at a later stage, but for the same reason. @mordante I'd much rather see this fixed properly than tape over it with this patch. https://github.com/llvm/llvm-project/pull/76268 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][modules] Increase clang-tidy version used. (PR #76268)
philnik777 wrote: > > > Oh shit. I just realized that this is most likely a latent bug no matter > > > what. We build the module with Clang 18, and then essentially try to load > > > it with Clang 17 (aka Clang Tidy 17). AFAIK that's not guaranteed to > > > work, and probably just happens to work currently with Clang 17 building > > > and Clang 18 loading the module (assuming we even test that right now?). > > > I think we may have to always match the Clang and Clang Tidy versions we > > > use. > > > > > > I should probably keep out of these discussions but here I am: > > You're welcome participate in the discussion. This is a public forum. Definitely. @H-G-Hristov feel free to comment on things you have an opinion/question about. Having an outside view is often quite helpful. > Then I can prohibit clang-16 and clang-17. Yeah, that's the solution. clang-tidy defines the same version macros as clang does, so prohibiting it from clang-16 is the same as prohibiting it for clang-tidy 16. > IMO The biggest issue is that the clang-tidy version is hard-coded in CMake. > This is something I mentioned in the past too. If it was a CMake option it > would be trivial to change the value without changing CMakeList.txt. We could also extract the clang version used and search for a clang-tidy that fits this version. That would also avoid the matching problems for others. We would probably have to get a path to the corresponding clang-tidy too. I don't know whether that's trivially possible right now. https://github.com/llvm/llvm-project/pull/76268 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][modules] Increase clang-tidy version used. (PR #76268)
https://github.com/philnik777 approved this pull request. I'm OK with this as a quick fix, since Mark promised to fix it properly in the long term. https://github.com/llvm/llvm-project/pull/76268 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][format][2/7] Optimizes c-string arguments. (PR #101805)
philnik777 wrote: It's also worth noting that compilers can constant-fold `strlen`, so in cases where the string is known this doesn't even result in multiple iterations. https://github.com/llvm/llvm-project/pull/101805 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][C++03] Fix libc++ includes (PR #109000)
philnik777 wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/109000?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#109002** https://app.graphite.dev/github/pr/llvm/llvm-project/109002?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#109001** https://app.graphite.dev/github/pr/llvm/llvm-project/109001?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#109000** https://app.graphite.dev/github/pr/llvm/llvm-project/109000?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 * **#108999** https://app.graphite.dev/github/pr/llvm/llvm-project/108999?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by Graphite. https://stacking.dev/?utm_source=stack-comment";>Learn more about stacking. Join @philnik777 and the rest of your teammates on https://graphite.dev?utm-source=stack-comment";>https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="11px" height="11px"/> Graphite https://github.com/llvm/llvm-project/pull/109000 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][C++03] Update include guards (PR #109001)
philnik777 wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/109001?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#109002** https://app.graphite.dev/github/pr/llvm/llvm-project/109002?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#109001** https://app.graphite.dev/github/pr/llvm/llvm-project/109001?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 * **#109000** https://app.graphite.dev/github/pr/llvm/llvm-project/109000?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#108999** https://app.graphite.dev/github/pr/llvm/llvm-project/108999?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by Graphite. https://stacking.dev/?utm_source=stack-comment";>Learn more about stacking. Join @philnik777 and the rest of your teammates on https://graphite.dev?utm-source=stack-comment";>https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="11px" height="11px"/> Graphite https://github.com/llvm/llvm-project/pull/109001 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [llvm] [libc++][C++03] Use `__cxx03/` headers in C++03 mode (PR #109002)
philnik777 wrote: > [!WARNING] > This pull request is not mergeable via GitHub because a downstack PR is > open. Once all requirements are satisfied, merge this PR as a stack href="https://app.graphite.dev/github/pr/llvm/llvm-project/109002?utm_source=stack-comment-downstack-mergeability-warning"; > >on Graphite. > https://graphite.dev/docs/merge-pull-requests";>Learn more * **#109002** https://app.graphite.dev/github/pr/llvm/llvm-project/109002?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> 👈 * **#109001** https://app.graphite.dev/github/pr/llvm/llvm-project/109001?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#109000** https://app.graphite.dev/github/pr/llvm/llvm-project/109000?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * **#108999** https://app.graphite.dev/github/pr/llvm/llvm-project/108999?utm_source=stack-comment-icon"; target="_blank">https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="10px" height="10px"/> * `main` This stack of pull requests is managed by Graphite. https://stacking.dev/?utm_source=stack-comment";>Learn more about stacking. Join @philnik777 and the rest of your teammates on https://graphite.dev?utm-source=stack-comment";>https://static.graphite.dev/graphite-32x32-black.png"; alt="Graphite" width="11px" height="11px"/> Graphite https://github.com/llvm/llvm-project/pull/109002 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][C++03] Fix libc++ includes (PR #109000)
https://github.com/philnik777 ready_for_review https://github.com/llvm/llvm-project/pull/109000 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [llvm] [libc++][C++03] Use `__cxx03/` headers in C++03 mode (PR #109002)
https://github.com/philnik777 ready_for_review https://github.com/llvm/llvm-project/pull/109002 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][C++03] Update include guards (PR #109001)
https://github.com/philnik777 ready_for_review https://github.com/llvm/llvm-project/pull/109001 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Stop copying headers to the build directory (PR #115380)
@@ -1021,17 +1021,8 @@ set(files configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site" @ONLY) philnik777 wrote: I think this change is fine. I'll have to modify this anyways and removing the copying now means I won't introduce it by accident again. https://github.com/llvm/llvm-project/pull/115380 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Stop copying headers to the build directory (PR #115380)
@@ -1021,17 +1021,8 @@ set(files configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site" @ONLY) philnik777 wrote: This isn't used _yet_. https://github.com/llvm/llvm-project/pull/115380 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [llvm] [libc++][C++03] Use `__cxx03/` headers in C++03 mode (PR #109002)
@@ -587,42 +587,48 @@ template */ -#include <__config> - -#include <__atomic/aliases.h> -#include <__atomic/atomic.h> -#include <__atomic/atomic_base.h> -#include <__atomic/atomic_flag.h> -#include <__atomic/atomic_init.h> -#include <__atomic/atomic_lock_free.h> -#include <__atomic/atomic_sync.h> -#include <__atomic/check_memory_order.h> -#include <__atomic/contention_t.h> -#include <__atomic/cxx_atomic_impl.h> -#include <__atomic/fence.h> -#include <__atomic/is_always_lock_free.h> -#include <__atomic/kill_dependency.h> -#include <__atomic/memory_order.h> -#include - -#if _LIBCPP_STD_VER >= 20 -# include <__atomic/atomic_ref.h> -#endif - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if !_LIBCPP_HAS_ATOMIC_HEADER -# error is not implemented -#endif - -#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 -# include -# include -# include -# include -# include -#endif +#include <__configuration/cxx03.h> + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_CXX03_HEADERS) +# include <__cxx03/algorithm> philnik777 wrote: I've checked the top level headers manually and fixed a few more. https://github.com/llvm/llvm-project/pull/109002 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [llvm] [libc++][C++03] Use `__cxx03/` headers in C++03 mode (PR #109002)
@@ -1827,232 +1827,147 @@ template */ -#include <__config> - -#include <__algorithm/adjacent_find.h> -#include <__algorithm/all_of.h> -#include <__algorithm/any_of.h> -#include <__algorithm/binary_search.h> -#include <__algorithm/copy.h> -#include <__algorithm/copy_backward.h> -#include <__algorithm/copy_if.h> -#include <__algorithm/copy_n.h> -#include <__algorithm/count.h> -#include <__algorithm/count_if.h> -#include <__algorithm/equal.h> -#include <__algorithm/equal_range.h> -#include <__algorithm/fill.h> -#include <__algorithm/fill_n.h> -#include <__algorithm/find.h> -#include <__algorithm/find_end.h> -#include <__algorithm/find_first_of.h> -#include <__algorithm/find_if.h> -#include <__algorithm/find_if_not.h> -#include <__algorithm/for_each.h> -#include <__algorithm/generate.h> -#include <__algorithm/generate_n.h> -#include <__algorithm/includes.h> -#include <__algorithm/inplace_merge.h> -#include <__algorithm/is_heap.h> -#include <__algorithm/is_heap_until.h> -#include <__algorithm/is_partitioned.h> -#include <__algorithm/is_permutation.h> -#include <__algorithm/is_sorted.h> -#include <__algorithm/is_sorted_until.h> -#include <__algorithm/iter_swap.h> -#include <__algorithm/lexicographical_compare.h> -#include <__algorithm/lower_bound.h> -#include <__algorithm/make_heap.h> -#include <__algorithm/max.h> -#include <__algorithm/max_element.h> -#include <__algorithm/merge.h> -#include <__algorithm/min.h> -#include <__algorithm/min_element.h> -#include <__algorithm/minmax.h> -#include <__algorithm/minmax_element.h> -#include <__algorithm/mismatch.h> -#include <__algorithm/move.h> -#include <__algorithm/move_backward.h> -#include <__algorithm/next_permutation.h> -#include <__algorithm/none_of.h> -#include <__algorithm/nth_element.h> -#include <__algorithm/partial_sort.h> -#include <__algorithm/partial_sort_copy.h> -#include <__algorithm/partition.h> -#include <__algorithm/partition_copy.h> -#include <__algorithm/partition_point.h> -#include <__algorithm/pop_heap.h> -#include <__algorithm/prev_permutation.h> -#include <__algorithm/push_heap.h> -#include <__algorithm/remove.h> -#include <__algorithm/remove_copy.h> -#include <__algorithm/remove_copy_if.h> -#include <__algorithm/remove_if.h> -#include <__algorithm/replace.h> -#include <__algorithm/replace_copy.h> -#include <__algorithm/replace_copy_if.h> -#include <__algorithm/replace_if.h> -#include <__algorithm/reverse.h> -#include <__algorithm/reverse_copy.h> -#include <__algorithm/rotate.h> -#include <__algorithm/rotate_copy.h> -#include <__algorithm/search.h> -#include <__algorithm/search_n.h> -#include <__algorithm/set_difference.h> -#include <__algorithm/set_intersection.h> -#include <__algorithm/set_symmetric_difference.h> -#include <__algorithm/set_union.h> -#include <__algorithm/shuffle.h> -#include <__algorithm/sort.h> -#include <__algorithm/sort_heap.h> -#include <__algorithm/stable_partition.h> -#include <__algorithm/stable_sort.h> -#include <__algorithm/swap_ranges.h> -#include <__algorithm/transform.h> -#include <__algorithm/unique.h> -#include <__algorithm/unique_copy.h> -#include <__algorithm/upper_bound.h> - -#if _LIBCPP_STD_VER >= 17 -# include <__algorithm/clamp.h> -# include <__algorithm/for_each_n.h> -# include <__algorithm/pstl.h> -# include <__algorithm/sample.h> -#endif // _LIBCPP_STD_VER >= 17 - -#if _LIBCPP_STD_VER >= 20 -# include <__algorithm/in_found_result.h> -# include <__algorithm/in_fun_result.h> -# include <__algorithm/in_in_out_result.h> -# include <__algorithm/in_in_result.h> -# include <__algorithm/in_out_out_result.h> -# include <__algorithm/in_out_result.h> -# include <__algorithm/lexicographical_compare_three_way.h> -# include <__algorithm/min_max_result.h> -# include <__algorithm/ranges_adjacent_find.h> -# include <__algorithm/ranges_all_of.h> -# include <__algorithm/ranges_any_of.h> -# include <__algorithm/ranges_binary_search.h> -# include <__algorithm/ranges_clamp.h> -# include <__algorithm/ranges_contains.h> -# include <__algorithm/ranges_copy.h> -# include <__algorithm/ranges_copy_backward.h> -# include <__algorithm/ranges_copy_if.h> -# include <__algorithm/ranges_copy_n.h> -# include <__algorithm/ranges_count.h> -# include <__algorithm/ranges_count_if.h> -# include <__algorithm/ranges_equal.h> -# include <__algorithm/ranges_equal_range.h> -# include <__algorithm/ranges_fill.h> -# include <__algorithm/ranges_fill_n.h> -# include <__algorithm/ranges_find.h> -# include <__algorithm/ranges_find_end.h> -# include <__algorithm/ranges_find_first_of.h> -# include <__algorithm/ranges_find_if.h> -# include <__algorithm/ranges_find_if_not.h> -# include <__algorithm/ranges_for_each.h> -# include <__algorithm/ranges_for_each_n.h> -# include <__algorithm/ranges_generate.h> -# include <__algorithm/ranges_generate_n.h> -# include <__algorithm/ranges_includes.h> -# include <__algorithm/ranges_inplace_merge.h> -# include <__algorithm/ranges_is_heap.h> -# include <__a
[llvm-branch-commits] [clang] [Clang] cherry-pick "Fix __{add, remove}_pointer in Objective-C++" (PR #125185)
https://github.com/philnik777 milestoned https://github.com/llvm/llvm-project/pull/125185 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] [Clang] cherry-pick "Fix __{add, remove}_pointer in Objective-C++" (PR #125185)
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/125185 This aligns the builtins with how implementations work which don't use the buitins. >From a729e9190f8047b455d80224e92844b12e493e3c Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Thu, 30 Jan 2025 20:34:29 +0100 Subject: [PATCH] [Clang] Fix __{add,remove}_pointer in Objective-C++ (#123678) This aligns the builtins with how implementations work which don't use the buitins. --- clang/docs/ReleaseNotes.rst | 2 ++ clang/lib/Sema/SemaType.cpp | 6 +++--- clang/test/SemaCXX/remove_pointer.mm | 8 clang/test/SemaObjCXX/type-traits.mm | 17 + 4 files changed, 22 insertions(+), 11 deletions(-) delete mode 100644 clang/test/SemaCXX/remove_pointer.mm create mode 100644 clang/test/SemaObjCXX/type-traits.mm diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index d8a94703bd9c57..25329e9e8a04ae 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -906,6 +906,8 @@ Bug Fixes to Compiler Builtins - Fix ``__builtin_source_location`` incorrectly returning wrong column for method chains. (#GH119129) +- The behvaiour of ``__add_pointer`` and ``__remove_pointer`` for Objective-C++'s ``id`` and interfaces has been fixed. + Bug Fixes to Attribute Support ^^ diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index 33d5378944ddbf..2781651b5d8f7d 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -1826,7 +1826,8 @@ QualType Sema::BuildPointerType(QualType T, if (checkQualifiedFunction(*this, T, Loc, QFK_Pointer)) return QualType(); - assert(!T->isObjCObjectType() && "Should build ObjCObjectPointerType"); + if (T->isObjCObjectType()) +return Context.getObjCObjectPointerType(T); // In ARC, it is forbidden to build pointers to unqualified pointers. if (getLangOpts().ObjCAutoRefCount) @@ -9807,8 +9808,7 @@ QualType Sema::BuiltinAddPointer(QualType BaseType, SourceLocation Loc) { } QualType Sema::BuiltinRemovePointer(QualType BaseType, SourceLocation Loc) { - // We don't want block pointers or ObjectiveC's id type. - if (!BaseType->isAnyPointerType() || BaseType->isObjCIdType()) + if (!BaseType->isAnyPointerType()) return BaseType; return BaseType->getPointeeType(); diff --git a/clang/test/SemaCXX/remove_pointer.mm b/clang/test/SemaCXX/remove_pointer.mm deleted file mode 100644 index d1cf1fa9f4efca..00 --- a/clang/test/SemaCXX/remove_pointer.mm +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s - -// expected-no-diagnostics - -@class X; - -static_assert(__is_same(__remove_pointer(X *), X), ""); -static_assert(__is_same(__remove_pointer(id), id), ""); diff --git a/clang/test/SemaObjCXX/type-traits.mm b/clang/test/SemaObjCXX/type-traits.mm new file mode 100644 index 00..81b9573b521929 --- /dev/null +++ b/clang/test/SemaObjCXX/type-traits.mm @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c++17 %s + +// expected-no-diagnostics + +@interface I; +@end + +@class C; + +static_assert(__is_same(__add_pointer(id), id*)); +static_assert(__is_same(__add_pointer(I), I*)); + +static_assert(__is_same(__remove_pointer(C*), C)); +static_assert(!__is_same(__remove_pointer(id), id)); +static_assert(__is_same(__remove_pointer(id*), id)); +static_assert(__is_same(__remove_pointer(__add_pointer(id)), id)); +static_assert(__is_same(__add_pointer(__remove_pointer(id)), id)); ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/20.x: [libc++] Replace __is_trivially_relocatable by is_trivially_copyable (#124970) (PR #125996)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/125996 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/20.x: [libcxx] Use _ftelli64/_fseeki64 on Windows (#123128) (PR #124922)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/124922 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [llvm] [libc++][C++03] Use `__cxx03/` headers in C++03 mode (PR #109002)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/109002 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Remove the need for _LIBCPP_TEMPLATE_VIS (PR #133010)
https://github.com/philnik777 ready_for_review https://github.com/llvm/llvm-project/pull/133010 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] libcxx: In gdb test detect execute_mi with feature check instead of version check. (PR #132291)
https://github.com/philnik777 approved this pull request. LGTM assuming the diff landed is the same I see. I'm really not a fan of complicating things unnecessarily though. https://github.com/llvm/llvm-project/pull/132291 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] libcxx: In gdb test detect execute_mi with feature check instead of version check. (PR #132291)
philnik777 wrote: Could you not use spr in that case? I can't see the diff as it would be merged AFAICT. https://github.com/llvm/llvm-project/pull/132291 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [libc++][CI] Pin the XCode version. (PR #135412)
https://github.com/philnik777 approved this pull request. @ldionne Should make sure this is correct when he is back. I'm not entirely sure whether "latest stable release" means latest minor or latest major (also, we're not up-to-date in the docs which XCode we're supporting). https://github.com/llvm/llvm-project/pull/135412 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] libcxx: In gdb test detect execute_mi with feature check instead of version check. (PR #132291)
philnik777 wrote: It looks like your merge base is wrong. https://github.com/llvm/llvm-project/pull/132291 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/20.x: [libcxx] [test] Extend mingw workarounds for armv7/aarch64 too (#136419) (PR #136752)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/136752 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/20.x: [libc++] Set feature-test macro `__cpp_lib_atomic_float` (#127559) (PR #127732)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/127732 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][CI] Update action runner base image. (PR #130433)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/130433 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/20.x: [libc++][ci] Update the Windows toolchains to Clang 19 (#129232) (PR #129303)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/129303 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/20.x: [libc++] Guard contents on _LIBCPP_HAS_LOCALIZATION (#129112) (PR #129305)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/129305 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Clang-tidy operator& hijacker. (PR #128366)
https://github.com/philnik777 requested changes to this pull request. @denzor200 It's a lot easier for us to add a libc++-speicific clang-tidy check than a general one. libc++ checks have significantly lower quality requirements, since they only have to work for libc++ (making "seems to work fine" good enough). If anybody wants to make this a general check they're welcome, but it's certainly more effort. https://github.com/llvm/llvm-project/pull/128366 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Clang-tidy operator& hijacker. (PR #128366)
@@ -0,0 +1,47 @@ +//===--===// +// +// 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 +// +//===--===// + +#include "clang-tidy/ClangTidyCheck.h" +#include "clang-tidy/ClangTidyModuleRegistry.h" +#include "clang/Tooling/FixIt.h" + +#include "robust_against_operator_ampersand.hpp" + +// This clang-tidy check ensures that we don't use operator& on dependant +// types. If the type is user supplied it may call the type's operator&. +// Instead use std::addressof. philnik777 wrote: This should go into the coding guidelines instead. https://github.com/llvm/llvm-project/pull/128366 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Clang-tidy operator& hijacker. (PR #128366)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/128366 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Remove the need for _LIBCPP_TEMPLATE_VIS (PR #133010)
https://github.com/philnik777 closed https://github.com/llvm/llvm-project/pull/133010 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++][C++03] Remove XFAILs from the non-frozen libc++-specific tests (PR #144101)
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/144101 The tests in `libcxx/test/libcxx` aren't run against the frozen headers anymore, so we can remove any XFAILs in them. This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc. >From e080572b8168260ecb4c8b2be39111d579056f74 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 13 Jun 2025 17:49:01 +0200 Subject: [PATCH] [libc++][C++03] Remove XFAILs from the non-frozen libc++-specific tests --- libcxx/test/libcxx/algorithms/half_positive.pass.cpp | 2 -- libcxx/test/libcxx/algorithms/vectorization.compile.pass.cpp | 2 -- .../assertions/customize_verbose_abort.link-time.pass.cpp | 2 -- libcxx/test/libcxx/assertions/default_verbose_abort.pass.cpp | 2 -- libcxx/test/libcxx/assertions/modes/none.pass.cpp | 2 -- libcxx/test/libcxx/assertions/single_expression.pass.cpp | 2 -- .../atomics.types.operations.req/atomic_fetch_add.verify.cpp | 2 -- .../atomic_fetch_add_explicit.verify.cpp | 2 -- .../atomics.types.operations.req/atomic_fetch_sub.verify.cpp | 2 -- .../atomic_fetch_sub_explicit.verify.cpp | 2 -- libcxx/test/libcxx/clang_modules_include.gen.py| 2 -- libcxx/test/libcxx/clang_tidy.gen.py | 3 --- .../containers/associative/tree_balance_after_insert.pass.cpp | 2 -- .../containers/associative/tree_key_value_traits.pass.cpp | 2 -- .../libcxx/containers/associative/tree_left_rotate.pass.cpp| 2 -- libcxx/test/libcxx/containers/associative/tree_remove.pass.cpp | 2 -- .../libcxx/containers/associative/tree_right_rotate.pass.cpp | 2 -- .../containers/associative/unord.map/abi.compile.pass.cpp | 2 -- .../containers/associative/unord.set/abi.compile.pass.cpp | 2 -- .../test/libcxx/containers/container_traits.compile.pass.cpp | 2 -- libcxx/test/libcxx/containers/unord/key_value_traits.pass.cpp | 2 -- libcxx/test/libcxx/containers/unord/next_pow2.pass.cpp | 2 -- libcxx/test/libcxx/containers/unord/next_prime.pass.cpp| 2 -- libcxx/test/libcxx/depr/depr.c.headers/extern_c.pass.cpp | 2 -- .../libcxx/experimental/fexperimental-library.compile.pass.cpp | 2 -- libcxx/test/libcxx/header_inclusions.gen.py| 1 - .../string.streams/stringbuf/const_sso_buffer.pass.cpp | 2 -- libcxx/test/libcxx/iterators/aliasing_iterator.pass.cpp| 2 -- libcxx/test/libcxx/iterators/bounded_iter/arithmetic.pass.cpp | 2 -- libcxx/test/libcxx/iterators/bounded_iter/comparison.pass.cpp | 2 -- .../test/libcxx/iterators/bounded_iter/pointer_traits.pass.cpp | 2 -- .../test/libcxx/iterators/bounded_iter/types.compile.pass.cpp | 2 -- .../iterators/contiguous_iterators.conv.compile.pass.cpp | 2 -- libcxx/test/libcxx/iterators/contiguous_iterators.verify.cpp | 2 -- .../iterator.primitives/iterator.operations/prev.verify.cpp| 2 -- .../language.support/support.dynamic/libcpp_deallocate.sh.cpp | 2 -- libcxx/test/libcxx/memory/allocation_guard.pass.cpp| 2 -- libcxx/test/libcxx/memory/swap_allocator.pass.cpp | 2 -- libcxx/test/libcxx/numerics/bit.ops.pass.cpp | 2 -- libcxx/test/libcxx/numerics/clamp_to_integral.pass.cpp | 2 -- .../libcxx/numerics/complex.number/cmplx.over.pow.pass.cpp | 2 -- libcxx/test/libcxx/selftest/test_macros.pass.cpp | 2 -- .../strings/basic.string/string.capacity/max_size.pass.cpp | 2 -- .../test/libcxx/strings/c.strings/constexpr_memmove.pass.cpp | 2 -- libcxx/test/libcxx/system_reserved_names.gen.py| 2 -- libcxx/test/libcxx/transitive_includes.gen.py | 2 -- libcxx/test/libcxx/type_traits/datasizeof.compile.pass.cpp | 2 -- libcxx/test/libcxx/type_traits/desugars_to.compile.pass.cpp| 2 -- libcxx/test/libcxx/type_traits/is_constant_evaluated.pass.cpp | 2 -- libcxx/test/libcxx/type_traits/is_replaceable.compile.pass.cpp | 2 -- .../type_traits/is_trivially_comparable.compile.pass.cpp | 2 -- .../type_traits/is_trivially_relocatable.compile.pass.cpp | 2 -- libcxx/test/libcxx/utilities/exception_guard.odr.sh.cpp| 2 -- .../function.objects/refwrap/desugars_to.compile.pass.cpp | 2 -- libcxx/test/libcxx/utilities/is_pointer_in_range.pass.cpp | 2 -- libcxx/test/libcxx/utilities/is_valid_range.pass.cpp | 2 -- .../libcxx/utilities/meta/is_referenceable.compile.pass.cpp| 2 -- libcxx/test/libcxx/utilities/meta/meta_base.pass.cpp | 2 -- libcxx/test/libcxx/utilities/no_destroy.pass.cpp | 2 -- libcxx/test/libcxx/utilities/template.bitset/includes.pass.cpp | 2 -- .../utilities/utility/private_constructor_tag.compile.pass.cpp | 2 -- 61 files changed, 122 deletions(-) diff --git a/libcxx/test/libcxx/algorithms/half_positive.pass.cpp b/libcxx/test/libcxx/algorithms/half_positiv
[llvm-branch-commits] [libcxx] [libc++][C++03] Fix a bunch of random tests (PR #144117)
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/144117 This fixes/removes a bunch of random tests. They all failed in relatively simple to fix ways. Specificially (all inside `libcxx/test/libcxx-03`): - `utilities/template.bitset/includes.pass.cpp`: the header guards have different names now (guard names fixed) - `utilities/meta/is_referenceable.compile.pass.cpp`: The name changed from `__libcpp_is_referenceable` (reverted name) - `utilities/function.objects/refwrap/desugars_to.compile.pass.cpp`: Optimization has been added after the header split (test removed) - `type_traits/is_replaceable.compile.pass.cpp`: `__is_replacable_v` has been added after the header split (test removed) - `type_traits/is_constant_evaluated.pass.cpp`: Ran C++11 code accidentally (C++11 test parts removed) - `type_traits/desugars_to.compile.pass.cpp`: Optimization has been added after the header split (test removed) - `numerics/bit.ops.pass.cpp`: Tried to include header which doesn't exist (removed include and related code which wasn't executed in C++03) - `experimental/fexperimental-library.compile.pass.cpp`: This test is irrelevant for C++03, since there are no C++03 experimental features (test removed) - `containers/container_traits.compile.pass.cpp`: `container_traits` have been introduced after the header split (test removed) >From 94255420a3a9e470973d3f3d4f7bed76bef39d23 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 13 Jun 2025 18:51:26 +0200 Subject: [PATCH] [libc++][C++03] Fix a bunch of random tests --- .../container_traits.compile.pass.cpp | 165 - .../fexperimental-library.compile.pass.cpp| 31 -- .../bounded_iter/comparison.pass.cpp | 4 +- .../test/libcxx-03/numerics/bit.ops.pass.cpp | 12 +- .../type_traits/desugars_to.compile.pass.cpp | 42 --- .../is_constant_evaluated.pass.cpp| 8 +- .../is_replaceable.compile.pass.cpp | 313 -- .../refwrap/desugars_to.compile.pass.cpp | 36 -- .../meta/is_referenceable.compile.pass.cpp| 230 +++-- .../template.bitset/includes.pass.cpp | 8 +- 10 files changed, 121 insertions(+), 728 deletions(-) delete mode 100644 libcxx/test/libcxx-03/containers/container_traits.compile.pass.cpp delete mode 100644 libcxx/test/libcxx-03/experimental/fexperimental-library.compile.pass.cpp delete mode 100644 libcxx/test/libcxx-03/type_traits/desugars_to.compile.pass.cpp delete mode 100644 libcxx/test/libcxx-03/type_traits/is_replaceable.compile.pass.cpp delete mode 100644 libcxx/test/libcxx-03/utilities/function.objects/refwrap/desugars_to.compile.pass.cpp diff --git a/libcxx/test/libcxx-03/containers/container_traits.compile.pass.cpp b/libcxx/test/libcxx-03/containers/container_traits.compile.pass.cpp deleted file mode 100644 index 22be217487951..0 --- a/libcxx/test/libcxx-03/containers/container_traits.compile.pass.cpp +++ /dev/null @@ -1,165 +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 -// -//===--===// -// -// <__type_traits/container_traits.h> -// - -// XFAIL: FROZEN-CXX03-HEADERS-FIXME - -#include <__type_traits/container_traits.h> - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_allocator.h" -#include "test_macros.h" -#include "MoveOnly.h" - -struct ThrowOnMove { - ThrowOnMove(); - ThrowOnMove(const ThrowOnMove&) TEST_NOEXCEPT_COND(false); - ThrowOnMove(ThrowOnMove&&) TEST_NOEXCEPT_COND(false); - ThrowOnMove& operator=(ThrowOnMove&&) TEST_NOEXCEPT_COND(false); - ThrowOnMove& operator=(const ThrowOnMove&) TEST_NOEXCEPT_COND(false); - - bool operator<(ThrowOnMove const&) const; - bool operator==(ThrowOnMove const&) const; -}; - -struct NonCopyThrowOnMove { - NonCopyThrowOnMove(); - NonCopyThrowOnMove(NonCopyThrowOnMove&&) TEST_NOEXCEPT_COND(false); - NonCopyThrowOnMove(const NonCopyThrowOnMove&) = delete; - NonCopyThrowOnMove& operator=(NonCopyThrowOnMove&&) TEST_NOEXCEPT_COND(false); - NonCopyThrowOnMove& operator=(const NonCopyThrowOnMove&) = delete; - - bool operator<(NonCopyThrowOnMove const&) const; - bool operator==(NonCopyThrowOnMove const&) const; -}; - -struct ThrowingHash { - template - std::size_t operator()(const T&) const TEST_NOEXCEPT_COND(false); -}; - -struct NoThrowHash { - template - std::size_t operator()(const T&) const TEST_NOEXCEPT; -}; - -template -void check() { - static_assert( - std::__container_traits::__emplacement_has_strong_exception_safety_guarantee == Expected, ""); -} - -void test() { - check >(); - check > >(); - check >(); - check >(); - check >(); - - check >(
[llvm-branch-commits] [libcxx] [libc++][C++03] Fix tests which only fail due to incorrect includes (PR #144110)
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/144110 Quite a few of the frozen header tests only fail because the include path is incorrect due to copying the headers. This patch fixes the tests where that's the only problem. This is part of https://discourse.llvm.org/t/rfc-freezing-c-03-headers-in-libc. >From 748f899d6b70933aa50f73bbe45ab198b8aacc38 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Fri, 13 Jun 2025 18:14:22 +0200 Subject: [PATCH] [libc++][C++03] Fix tests which only fail due to incorrect includes --- .../test/libcxx-03/algorithms/half_positive.pass.cpp | 4 +--- .../assertions/default_verbose_abort.pass.cpp | 4 +--- libcxx/test/libcxx-03/assertions/modes/none.pass.cpp | 4 +--- .../libcxx-03/assertions/single_expression.pass.cpp| 4 +--- .../associative/tree_balance_after_insert.pass.cpp | 4 +--- .../associative/tree_key_value_traits.pass.cpp | 4 +--- .../containers/associative/tree_left_rotate.pass.cpp | 4 +--- .../containers/associative/tree_remove.pass.cpp| 4 +--- .../containers/associative/tree_right_rotate.pass.cpp | 4 +--- .../containers/unord/key_value_traits.pass.cpp | 4 +--- .../libcxx-03/containers/unord/next_prime.pass.cpp | 4 +--- .../libcxx-03/depr/depr.c.headers/extern_c.pass.cpp| 4 +--- .../libcxx-03/iterators/aliasing_iterator.pass.cpp | 4 +--- .../iterators/bounded_iter/arithmetic.pass.cpp | 4 +--- .../iterators/bounded_iter/pointer_traits.pass.cpp | 4 +--- .../iterators/bounded_iter/types.compile.pass.cpp | 4 +--- libcxx/test/libcxx-03/memory/allocation_guard.pass.cpp | 4 +--- libcxx/test/libcxx-03/memory/swap_allocator.pass.cpp | 4 +--- .../test/libcxx-03/numerics/clamp_to_integral.pass.cpp | 4 +--- libcxx/test/libcxx-03/selftest/test_macros.pass.cpp| 4 +--- .../strings/c.strings/constexpr_memmove.pass.cpp | 4 +--- .../is_trivially_comparable.compile.pass.cpp | 8 +++- .../is_trivially_relocatable.compile.pass.cpp | 4 +--- .../libcxx-03/utilities/exception_guard.odr.sh.cpp | 4 +--- .../libcxx-03/utilities/is_pointer_in_range.pass.cpp | 4 +--- .../test/libcxx-03/utilities/is_valid_range.pass.cpp | 4 +--- .../test/libcxx-03/utilities/meta/meta_base.pass.cpp | 10 -- libcxx/test/libcxx-03/utilities/no_destroy.pass.cpp| 4 +--- .../utility/private_constructor_tag.compile.pass.cpp | 4 +--- 29 files changed, 34 insertions(+), 92 deletions(-) diff --git a/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp b/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp index 88a18e8592921..292fcf356554b 100644 --- a/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp +++ b/libcxx/test/libcxx-03/algorithms/half_positive.pass.cpp @@ -11,9 +11,7 @@ // __half_positive divides an integer number by 2 as unsigned number for known types. // It can be an important optimization for lower bound, for example. -// XFAIL: FROZEN-CXX03-HEADERS-FIXME - -#include <__algorithm/half_positive.h> +#include <__cxx03/__algorithm/half_positive.h> #include #include #include diff --git a/libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp b/libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp index 803868b757794..27169da5e1c41 100644 --- a/libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp +++ b/libcxx/test/libcxx-03/assertions/default_verbose_abort.pass.cpp @@ -9,9 +9,7 @@ // Test that the default verbose termination function aborts the program. // XFAIL: availability-verbose_abort-missing -// XFAIL: FROZEN-CXX03-HEADERS-FIXME - -#include <__verbose_abort> +#include <__cxx03/__verbose_abort> #include #include diff --git a/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp b/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp index b64290a31a129..e79dee906ae69 100644 --- a/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp +++ b/libcxx/test/libcxx-03/assertions/modes/none.pass.cpp @@ -11,9 +11,7 @@ // REQUIRES: libcpp-hardening-mode=none -// XFAIL: FROZEN-CXX03-HEADERS-FIXME - -#include <__assert> +#include <__cxx03/__assert> #include bool executed_condition = false; diff --git a/libcxx/test/libcxx-03/assertions/single_expression.pass.cpp b/libcxx/test/libcxx-03/assertions/single_expression.pass.cpp index 474edc9dc0833..bbda6f11e4f6a 100644 --- a/libcxx/test/libcxx-03/assertions/single_expression.pass.cpp +++ b/libcxx/test/libcxx-03/assertions/single_expression.pass.cpp @@ -10,9 +10,7 @@ // This is useful so we can use them in places that require an expression, such as // in a constructor initializer list. -// XFAIL: FROZEN-CXX03-HEADERS-FIXME - -#include <__assert> +#include <__cxx03/__assert> #include void f() { diff --git a/libcxx/test/libcxx-03/containers/associative/tree_balance_after_insert.pass.cpp b/libcxx/test/libcxx-03/containers/associative/tree_balance_after_insert.pa
[llvm-branch-commits] [libcxx] [libcxx] Include __fwd/span.h in (PR #142925)
@@ -451,6 +451,7 @@ namespace std { # if _LIBCPP_STD_VER >= 23 #include <__fwd/mdspan.h> +#include <__fwd/span.h> philnik777 wrote: Can you add a comment with the LWG issue number? If the answer is that we indeed expect users to include `` we should remove the include again. I don't expect it, but it's better to have a comment that this is technically an extension currently. https://github.com/llvm/llvm-project/pull/142925 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libcxx] Include __fwd/span.h in (PR #142925)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/142925 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libcxx] Include __fwd/span.h in (PR #142925)
https://github.com/philnik777 approved this pull request. LGTM with added comment. https://github.com/llvm/llvm-project/pull/142925 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/20.x: [libc++] Add _LIBCPP_NO_UNIQUE_ADDRESS to flat_{, multi}map::value_compare (#137594) (PR #138880)
philnik777 wrote: @tstellar The CI failures are most certainly unrelated. https://github.com/llvm/llvm-project/pull/138880 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add accessor functions to __tree_node_base (PR #147679)
https://github.com/philnik777 ready_for_review https://github.com/llvm/llvm-project/pull/147679 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add ABI flag to make __tree nodes more compact (PR #147681)
https://github.com/philnik777 ready_for_review https://github.com/llvm/llvm-project/pull/147681 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add accessor functions to __tree_node_base (PR #147679)
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/147679 >From 8e5e6f010dd8c3aaab2de28b7c33c10d3cbf8a55 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Mon, 9 Jun 2025 18:17:31 +0200 Subject: [PATCH] [libc++] Add accessor functions to __tree_node_base --- libcxx/include/__tree | 218 +++--- 1 file changed, 117 insertions(+), 101 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 9d4ba3ad0639c..a0ab6fa55b2ef 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -77,6 +77,11 @@ class __map_iterator; template class __map_const_iterator; +enum class __tree_color : bool { + __red = false, + __black = true, +}; + /* _NodePtr algorithms @@ -102,7 +107,7 @@ __root, have a non-null __parent_ field. // Precondition: __x != nullptr. template inline _LIBCPP_HIDE_FROM_ABI bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT { - return __x == __x->__parent_->__left_; + return __x == __x->__get_parent()->__left_; } // Determines if the subtree rooted at __x is a proper red black subtree. If @@ -192,7 +197,7 @@ inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEP return static_cast<_EndNodePtr>(std::__tree_min(__x->__right_)); while (!std::__tree_is_left_child(__x)) __x = __x->__parent_unsafe(); - return static_cast<_EndNodePtr>(__x->__parent_); + return static_cast<_EndNodePtr>(__x->__get_parent()); } // Returns: pointer to the previous in-order node before __x. @@ -236,9 +241,9 @@ _LIBCPP_HIDE_FROM_ABI void __tree_left_rotate(_NodePtr __x) _NOEXCEPT { __x->__right_ = __y->__left_; if (__x->__right_ != nullptr) __x->__right_->__set_parent(__x); - __y->__parent_ = __x->__parent_; + __y->__set_parent(__x->__get_parent()); if (std::__tree_is_left_child(__x)) -__x->__parent_->__left_ = __y; +__x->__get_parent()->__left_ = __y; else __x->__parent_unsafe()->__right_ = __y; __y->__left_ = __x; @@ -255,9 +260,9 @@ _LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT { __x->__left_ = __y->__right_; if (__x->__left_ != nullptr) __x->__left_->__set_parent(__x); - __y->__parent_ = __x->__parent_; + __y->__set_parent(__x->__get_parent()); if (std::__tree_is_left_child(__x)) -__x->__parent_->__left_ = __y; +__x->__get_parent()->__left_ = __y; else __x->__parent_unsafe()->__right_ = __y; __y->__right_ = __x; @@ -275,46 +280,47 @@ template _LIBCPP_HIDE_FROM_ABI void __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT { _LIBCPP_ASSERT_INTERNAL(__root != nullptr, "Root of the tree shouldn't be null"); _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Can't attach null node to a leaf"); - __x->__is_black_ = __x == __root; - while (__x != __root && !__x->__parent_unsafe()->__is_black_) { -// __x->__parent_ != __root because __x->__parent_->__is_black == false + using enum __tree_color; + __x->__set_color(__x == __root ? __black : __red); + while (__x != __root && __x->__parent_unsafe()->__get_color() == __red) { +// __x->__parent_ != __root because __x->__parent_->__get_color() == __red if (std::__tree_is_left_child(__x->__parent_unsafe())) { _NodePtr __y = __x->__parent_unsafe()->__parent_unsafe()->__right_; - if (__y != nullptr && !__y->__is_black_) { -__x = __x->__parent_unsafe(); -__x->__is_black_ = true; -__x = __x->__parent_unsafe(); -__x->__is_black_ = __x == __root; -__y->__is_black_ = true; + if (__y != nullptr && __y->__get_color() == __red) { +__x = __x->__parent_unsafe(); +__x->__set_color(__black); +__x = __x->__parent_unsafe(); +__x->__set_color(__x == __root ? __black : __red); +__y->__set_color(__black); } else { if (!std::__tree_is_left_child(__x)) { __x = __x->__parent_unsafe(); std::__tree_left_rotate(__x); } -__x = __x->__parent_unsafe(); -__x->__is_black_ = true; -__x = __x->__parent_unsafe(); -__x->__is_black_ = false; +__x = __x->__parent_unsafe(); +__x->__set_color(__black); +__x = __x->__parent_unsafe(); +__x->__set_color(__red); std::__tree_right_rotate(__x); break; } } else { - _NodePtr __y = __x->__parent_unsafe()->__parent_->__left_; - if (__y != nullptr && !__y->__is_black_) { -__x = __x->__parent_unsafe(); -__x->__is_black_ = true; -__x = __x->__parent_unsafe(); -__x->__is_black_ = __x == __root; -__y->__is_black_ = true; + _NodePtr __y = __x->__parent_unsafe()->__get_parent()->__left_; + if (__y != nullptr && __y->__get_color() == __red) { +__x = __x->__parent_unsafe(); +__x->__set_color(__black); +__x = __x->
[llvm-branch-commits] [libcxx] [libc++] Add ABI flag to make __tree nodes more compact (PR #147681)
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/147681 >From bed3297d32d7a270d216ee3efb706b914fc32f2b Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 10 Jun 2025 05:56:20 +0200 Subject: [PATCH] [libc++] Add ABI flag to make __tree nodes more compact --- libcxx/include/__configuration/abi.h | 3 +++ libcxx/include/__tree| 40 2 files changed, 43 insertions(+) diff --git a/libcxx/include/__configuration/abi.h b/libcxx/include/__configuration/abi.h index cc4b930b3cf4a..b9ef56e76f988 100644 --- a/libcxx/include/__configuration/abi.h +++ b/libcxx/include/__configuration/abi.h @@ -116,6 +116,7 @@ // This setting disables the addition of such artificial padding, leading to a more optimal // representation for several types. # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING +# define _LIBCPP_ABI_TREE_POINTER_INT_PAIR #elif _LIBCPP_ABI_VERSION == 1 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) // Enable compiling copies of now inline methods into the dylib to support @@ -135,6 +136,8 @@ # endif #endif +#define _LIBCPP_ABI_TREE_POINTER_INT_PAIR + // We had some bugs where we use [[no_unique_address]] together with construct_at, // which causes UB as the call on construct_at could write to overlapping subobjects // diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 82ffcc13e1f91..16dd1ae8a0905 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -40,6 +40,7 @@ #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/pair.h> +#include <__utility/pointer_int_pair.h> #include <__utility/swap.h> #include @@ -654,6 +655,45 @@ public: __tree_node_base& operator=(__tree_node_base const&) = delete; }; +#ifdef _LIBCPP_ABI_TREE_POINTER_INT_PAIR +template <> +class __tree_node_base< void*> : public __tree_node_base_types::__end_node_type { + using _NodeBaseTypes = __tree_node_base_types; + +public: + using pointer = typename _NodeBaseTypes::__node_base_pointer; + using __parent_pointer = typename _NodeBaseTypes::__parent_pointer; + + pointer __right_; + +private: + using __pair_t = __pointer_int_pair<__parent_pointer, bool, __integer_width(1)>; + + __pair_t __parent_and_color_; + +public: + _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { +return static_cast(__parent_and_color_.__get_ptr()); + } + + _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __ptr) { __set_parent(static_cast<__parent_pointer>(__ptr)); } + + _LIBCPP_HIDE_FROM_ABI void __set_parent(__parent_pointer __ptr) { +__parent_and_color_ = __pair_t(__ptr, __parent_and_color_.__get_value()); + } + + _LIBCPP_HIDE_FROM_ABI __parent_pointer __get_parent() const { return __parent_and_color_.__get_ptr(); } + _LIBCPP_HIDE_FROM_ABI __tree_color __get_color() const { +return static_cast<__tree_color>(__parent_and_color_.__get_value()); + } + _LIBCPP_HIDE_FROM_ABI void __set_color(__tree_color __color) { +__parent_and_color_ = __pair_t(__parent_and_color_.__get_ptr(), __color == __tree_color::__black); + } +}; +#endif // _LIBCPP_ABI_TREE_POINTER_INT_PAIR + +static_assert(sizeof(__tree_node_base) == 24); + template class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> { public: ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add accessor functions to __tree_node_base (PR #147679)
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/147679 None >From f1fc048e52e5c57898fcb226a1fe3c8519cb5923 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Mon, 9 Jun 2025 18:17:31 +0200 Subject: [PATCH] [libc++] Add accessor functions to __tree_node_base --- libcxx/include/__tree | 218 +++--- 1 file changed, 117 insertions(+), 101 deletions(-) diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 403cfe1ba4036..82ffcc13e1f91 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -76,6 +76,11 @@ class __map_iterator; template class __map_const_iterator; +enum class __tree_color : bool { + __red = false, + __black = true, +}; + /* _NodePtr algorithms @@ -101,7 +106,7 @@ __root, have a non-null __parent_ field. // Precondition: __x != nullptr. template inline _LIBCPP_HIDE_FROM_ABI bool __tree_is_left_child(_NodePtr __x) _NOEXCEPT { - return __x == __x->__parent_->__left_; + return __x == __x->__get_parent()->__left_; } // Determines if the subtree rooted at __x is a proper red black subtree. If @@ -191,7 +196,7 @@ inline _LIBCPP_HIDE_FROM_ABI _EndNodePtr __tree_next_iter(_NodePtr __x) _NOEXCEP return static_cast<_EndNodePtr>(std::__tree_min(__x->__right_)); while (!std::__tree_is_left_child(__x)) __x = __x->__parent_unsafe(); - return static_cast<_EndNodePtr>(__x->__parent_); + return static_cast<_EndNodePtr>(__x->__get_parent()); } // Returns: pointer to the previous in-order node before __x. @@ -235,9 +240,9 @@ _LIBCPP_HIDE_FROM_ABI void __tree_left_rotate(_NodePtr __x) _NOEXCEPT { __x->__right_ = __y->__left_; if (__x->__right_ != nullptr) __x->__right_->__set_parent(__x); - __y->__parent_ = __x->__parent_; + __y->__set_parent(__x->__get_parent()); if (std::__tree_is_left_child(__x)) -__x->__parent_->__left_ = __y; +__x->__get_parent()->__left_ = __y; else __x->__parent_unsafe()->__right_ = __y; __y->__left_ = __x; @@ -254,9 +259,9 @@ _LIBCPP_HIDE_FROM_ABI void __tree_right_rotate(_NodePtr __x) _NOEXCEPT { __x->__left_ = __y->__right_; if (__x->__left_ != nullptr) __x->__left_->__set_parent(__x); - __y->__parent_ = __x->__parent_; + __y->__set_parent(__x->__get_parent()); if (std::__tree_is_left_child(__x)) -__x->__parent_->__left_ = __y; +__x->__get_parent()->__left_ = __y; else __x->__parent_unsafe()->__right_ = __y; __y->__right_ = __x; @@ -274,46 +279,47 @@ template _LIBCPP_HIDE_FROM_ABI void __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) _NOEXCEPT { _LIBCPP_ASSERT_INTERNAL(__root != nullptr, "Root of the tree shouldn't be null"); _LIBCPP_ASSERT_INTERNAL(__x != nullptr, "Can't attach null node to a leaf"); - __x->__is_black_ = __x == __root; - while (__x != __root && !__x->__parent_unsafe()->__is_black_) { -// __x->__parent_ != __root because __x->__parent_->__is_black == false + using enum __tree_color; + __x->__set_color(__x == __root ? __black : __red); + while (__x != __root && __x->__parent_unsafe()->__get_color() == __red) { +// __x->__parent_ != __root because __x->__parent_->__get_color() == __red if (std::__tree_is_left_child(__x->__parent_unsafe())) { _NodePtr __y = __x->__parent_unsafe()->__parent_unsafe()->__right_; - if (__y != nullptr && !__y->__is_black_) { -__x = __x->__parent_unsafe(); -__x->__is_black_ = true; -__x = __x->__parent_unsafe(); -__x->__is_black_ = __x == __root; -__y->__is_black_ = true; + if (__y != nullptr && __y->__get_color() == __red) { +__x = __x->__parent_unsafe(); +__x->__set_color(__black); +__x = __x->__parent_unsafe(); +__x->__set_color(__x == __root ? __black : __red); +__y->__set_color(__black); } else { if (!std::__tree_is_left_child(__x)) { __x = __x->__parent_unsafe(); std::__tree_left_rotate(__x); } -__x = __x->__parent_unsafe(); -__x->__is_black_ = true; -__x = __x->__parent_unsafe(); -__x->__is_black_ = false; +__x = __x->__parent_unsafe(); +__x->__set_color(__black); +__x = __x->__parent_unsafe(); +__x->__set_color(__red); std::__tree_right_rotate(__x); break; } } else { - _NodePtr __y = __x->__parent_unsafe()->__parent_->__left_; - if (__y != nullptr && !__y->__is_black_) { -__x = __x->__parent_unsafe(); -__x->__is_black_ = true; -__x = __x->__parent_unsafe(); -__x->__is_black_ = __x == __root; -__y->__is_black_ = true; + _NodePtr __y = __x->__parent_unsafe()->__get_parent()->__left_; + if (__y != nullptr && __y->__get_color() == __red) { +__x = __x->__parent_unsafe(); +__x->__set_color(__black); +__x =
[llvm-branch-commits] [libcxx] [libc++] Add ABI flag to make __tree nodes more compact (PR #147681)
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/147681 None >From bd3919aed4aa6cae451541d2ad29f914e2785dc0 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 10 Jun 2025 05:56:20 +0200 Subject: [PATCH] [libc++] Add ABI flag to make __tree nodes more compact --- libcxx/include/__configuration/abi.h | 3 ++ libcxx/include/__tree| 47 ++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/libcxx/include/__configuration/abi.h b/libcxx/include/__configuration/abi.h index cc4b930b3cf4a..b9ef56e76f988 100644 --- a/libcxx/include/__configuration/abi.h +++ b/libcxx/include/__configuration/abi.h @@ -116,6 +116,7 @@ // This setting disables the addition of such artificial padding, leading to a more optimal // representation for several types. # define _LIBCPP_ABI_NO_COMPRESSED_PAIR_PADDING +# define _LIBCPP_ABI_TREE_POINTER_INT_PAIR #elif _LIBCPP_ABI_VERSION == 1 # if !(defined(_LIBCPP_OBJECT_FORMAT_COFF) || defined(_LIBCPP_OBJECT_FORMAT_XCOFF)) // Enable compiling copies of now inline methods into the dylib to support @@ -135,6 +136,8 @@ # endif #endif +#define _LIBCPP_ABI_TREE_POINTER_INT_PAIR + // We had some bugs where we use [[no_unique_address]] together with construct_at, // which causes UB as the call on construct_at could write to overlapping subobjects // diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 82ffcc13e1f91..e994b5f8c3a51 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -40,6 +40,7 @@ #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/pair.h> +#include <__utility/pointer_int_pair.h> #include <__utility/swap.h> #include @@ -61,7 +62,7 @@ class __tree_const_iterator; template class __tree_end_node; -template +template class __tree_node_base; template class __tree_node; @@ -626,7 +627,7 @@ public: _LIBCPP_HIDE_FROM_ABI __tree_end_node() _NOEXCEPT : __left_() {} }; -template +template class _LIBCPP_STANDALONE_DEBUG __tree_node_base : public __tree_node_base_types<_VoidPtr>::__end_node_type { typedef __tree_node_base_types<_VoidPtr> _NodeBaseTypes; @@ -654,6 +655,48 @@ public: __tree_node_base& operator=(__tree_node_base const&) = delete; }; +#ifdef _LIBCPP_ABI_TREE_POINTER_INT_PAIR +template +class __tree_node_base< +_VoidPtr, +__enable_if_t::__node_base_pointer>::value> > +: public __tree_node_base_types<_VoidPtr>::__end_node_type { + using _NodeBaseTypes = __tree_node_base_types<_VoidPtr>; + +public: + using pointer = typename _NodeBaseTypes::__node_base_pointer; + using __parent_pointer = typename _NodeBaseTypes::__parent_pointer; + + pointer __right_; + +private: + using __pair_t = __pointer_int_pair<__parent_pointer, bool, __integer_width(1)>; + + __pair_t __parent_and_color_; + +public: + _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { +return static_cast(__parent_and_color_.__get_ptr()); + } + + _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __ptr) { __set_parent(static_cast<__parent_pointer>(__ptr)); } + + _LIBCPP_HIDE_FROM_ABI void __set_parent(__parent_pointer __ptr) { +__parent_and_color_ = __pair_t(__ptr, __parent_and_color_.__get_value()); + } + + _LIBCPP_HIDE_FROM_ABI __parent_pointer __get_parent() const { return __parent_and_color_.__get_ptr(); } + _LIBCPP_HIDE_FROM_ABI __tree_color __get_color() const { +return static_cast<__tree_color>(__parent_and_color_.__get_value()); + } + _LIBCPP_HIDE_FROM_ABI void __set_color(__tree_color __color) { +__parent_and_color_ = __pair_t(__parent_and_color_.__get_ptr(), __color == __tree_color::__black); + } +}; +#endif // _LIBCPP_ABI_TREE_POINTER_INT_PAIR + +static_assert(sizeof(__tree_node_base) == 24); + template class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> { public: ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add ABI flag to make __tree nodes more compact (PR #147681)
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/147681 >From 920e83463665654fd7b48b5e70591fb978b7b50e Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 10 Jun 2025 05:56:20 +0200 Subject: [PATCH] [libc++] Add ABI flag to make __tree nodes more compact --- libcxx/include/__configuration/abi.h | 3 +++ libcxx/include/__tree| 38 2 files changed, 41 insertions(+) diff --git a/libcxx/include/__configuration/abi.h b/libcxx/include/__configuration/abi.h index a75cd0a675339..759687914be91 100644 --- a/libcxx/include/__configuration/abi.h +++ b/libcxx/include/__configuration/abi.h @@ -75,6 +75,7 @@ # define _LIBCPP_ABI_OPTIMIZED_FUNCTION # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION +# define _LIBCPP_ABI_TREE_POINTER_INT_PAIR # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION @@ -98,6 +99,8 @@ # endif #endif +#define _LIBCPP_ABI_TREE_POINTER_INT_PAIR + // We had some bugs where we use [[no_unique_address]] together with construct_at, // which causes UB as the call on construct_at could write to overlapping subobjects // diff --git a/libcxx/include/__tree b/libcxx/include/__tree index a0ab6fa55b2ef..63a22fc93ca24 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -41,6 +41,7 @@ #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/pair.h> +#include <__utility/pointer_int_pair.h> #include <__utility/swap.h> #include @@ -591,6 +592,43 @@ public: __tree_node_base& operator=(__tree_node_base const&) = delete; }; +#ifdef _LIBCPP_ABI_TREE_POINTER_INT_PAIR +template <> +class __tree_node_base : public __tree_end_node<__tree_node_base*> { +public: + using pointer= __tree_node_base*; + using __end_node_pointer _LIBCPP_NODEBUG = __tree_end_node<__tree_node_base*>*; + + pointer __right_; + +private: + using __pair_t = __pointer_int_pair<__end_node_pointer, bool, __integer_width(1)>; + + __pair_t __parent_and_color_; + +public: + _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { +return static_cast(__parent_and_color_.__get_ptr()); + } + + _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __ptr) { __set_parent(static_cast<__end_node_pointer>(__ptr)); } + + _LIBCPP_HIDE_FROM_ABI void __set_parent(__end_node_pointer __ptr) { +__parent_and_color_ = __pair_t(__ptr, __parent_and_color_.__get_value()); + } + + _LIBCPP_HIDE_FROM_ABI __end_node_pointer __get_parent() const { return __parent_and_color_.__get_ptr(); } + _LIBCPP_HIDE_FROM_ABI __tree_color __get_color() const { +return static_cast<__tree_color>(__parent_and_color_.__get_value()); + } + _LIBCPP_HIDE_FROM_ABI void __set_color(__tree_color __color) { +__parent_and_color_ = __pair_t(__parent_and_color_.__get_ptr(), __color == __tree_color::__black); + } +}; +#endif // _LIBCPP_ABI_TREE_POINTER_INT_PAIR + +static_assert(sizeof(__tree_node_base) == 24); + template class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> { public: ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add ABI flag to make __tree nodes more compact (PR #147681)
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/147681 >From 2335111d19903652229a8e3fb25cd03b5ffa5e48 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Tue, 10 Jun 2025 05:56:20 +0200 Subject: [PATCH] [libc++] Add ABI flag to make __tree nodes more compact --- libcxx/include/__configuration/abi.h | 3 +++ libcxx/include/__tree| 38 2 files changed, 41 insertions(+) diff --git a/libcxx/include/__configuration/abi.h b/libcxx/include/__configuration/abi.h index a75cd0a675339..759687914be91 100644 --- a/libcxx/include/__configuration/abi.h +++ b/libcxx/include/__configuration/abi.h @@ -75,6 +75,7 @@ # define _LIBCPP_ABI_OPTIMIZED_FUNCTION # define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO # define _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION +# define _LIBCPP_ABI_TREE_POINTER_INT_PAIR # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY # define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW # define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION @@ -98,6 +99,8 @@ # endif #endif +#define _LIBCPP_ABI_TREE_POINTER_INT_PAIR + // We had some bugs where we use [[no_unique_address]] together with construct_at, // which causes UB as the call on construct_at could write to overlapping subobjects // diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 6b025bcf3496d..3ead4c286f47f 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -41,6 +41,7 @@ #include <__utility/forward.h> #include <__utility/move.h> #include <__utility/pair.h> +#include <__utility/pointer_int_pair.h> #include <__utility/swap.h> #include @@ -593,6 +594,43 @@ public: __tree_node_base& operator=(__tree_node_base const&) = delete; }; +#ifdef _LIBCPP_ABI_TREE_POINTER_INT_PAIR +template <> +class __tree_node_base : public __tree_end_node<__tree_node_base*> { +public: + using pointer= __tree_node_base*; + using __end_node_pointer _LIBCPP_NODEBUG = __tree_end_node<__tree_node_base*>*; + + pointer __right_; + +private: + using __pair_t = __pointer_int_pair<__end_node_pointer, bool, __integer_width(1)>; + + __pair_t __parent_and_color_; + +public: + _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { +return static_cast(__parent_and_color_.__get_ptr()); + } + + _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __ptr) { __set_parent(static_cast<__end_node_pointer>(__ptr)); } + + _LIBCPP_HIDE_FROM_ABI void __set_parent(__end_node_pointer __ptr) { +__parent_and_color_ = __pair_t(__ptr, __parent_and_color_.__get_value()); + } + + _LIBCPP_HIDE_FROM_ABI __end_node_pointer __get_parent() const { return __parent_and_color_.__get_ptr(); } + _LIBCPP_HIDE_FROM_ABI __tree_color __get_color() const { +return static_cast<__tree_color>(__parent_and_color_.__get_value()); + } + _LIBCPP_HIDE_FROM_ABI void __set_color(__tree_color __color) { +__parent_and_color_ = __pair_t(__parent_and_color_.__get_ptr(), __color == __tree_color::__black); + } +}; +#endif // _LIBCPP_ABI_TREE_POINTER_INT_PAIR + +static_assert(sizeof(__tree_node_base) == 24); + template class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> { public: ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] [libc++] Add accessor functions to __tree_node_base (PR #147679)
philnik777 wrote: > I think this could be rebased onto `main` -- it doesn't depend on > `__pointer_int_pair` in itself. That is true, but there is no way to stack a PR from two independent PRs AFAIK. https://github.com/llvm/llvm-project/pull/147679 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits