Skip to content

[libc++] Remove identity casts in <{forward_,}list> #130049

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions libcxx/include/forward_list
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@ struct __forward_node_traits {
"the _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
# endif

_LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__begin_node_pointer __p) { return __p; }
_LIBCPP_HIDE_FROM_ABI static __begin_node_pointer __as_iter_node(__node_pointer __p) {
return static_cast<__begin_node_pointer>(static_cast<__void_pointer>(__p));
}
Expand Down Expand Up @@ -373,8 +372,7 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_iterator {

_LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}

_LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT
: __ptr_(__traits::__as_iter_node(__p)) {}
_LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__begin_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}

_LIBCPP_HIDE_FROM_ABI explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT
: __ptr_(__traits::__as_iter_node(__p)) {}
Expand Down Expand Up @@ -438,8 +436,7 @@ class _LIBCPP_TEMPLATE_VIS __forward_list_const_iterator {

_LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(nullptr_t) _NOEXCEPT : __ptr_(nullptr) {}

_LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT
: __ptr_(__traits::__as_iter_node(__p)) {}
_LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__begin_node_pointer __p) _NOEXCEPT : __ptr_(__p) {}

_LIBCPP_HIDE_FROM_ABI explicit __forward_list_const_iterator(__node_pointer __p) _NOEXCEPT
: __ptr_(__traits::__as_iter_node(__p)) {}
Expand Down
8 changes: 1 addition & 7 deletions libcxx/include/list
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,6 @@ struct __list_node_pointer_traits {
"LLVM 19 and LLVM 20. If you don't care about your ABI being broken, define the "
"_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB macro to silence this diagnostic.");
# endif

static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__base_pointer __p) { return __p; }

static _LIBCPP_HIDE_FROM_ABI __base_pointer __unsafe_link_pointer_cast(__node_pointer __p) {
return static_cast<__base_pointer>(static_cast<_VoidPtr>(__p));
}
};

template <class _Tp, class _VoidPtr>
Expand Down Expand Up @@ -504,7 +498,7 @@ protected:
_LIBCPP_COMPRESSED_PAIR(size_type, __size_, __node_allocator, __node_alloc_);

_LIBCPP_HIDE_FROM_ABI __base_pointer __end_as_link() const _NOEXCEPT {
return __node_pointer_traits::__unsafe_link_pointer_cast(const_cast<__node_base&>(__end_).__self());
return const_cast<__node_base&>(__end_).__self();
}

_LIBCPP_HIDE_FROM_ABI size_type __node_alloc_max_size() const _NOEXCEPT {
Expand Down
Loading