[libcxx-commits] [libcxx] ff993f9 - [libc++] Remove identity casts in <{forward_, }list> (#130049)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 6 07:09:33 PST 2025


Author: Nikolas Klauser
Date: 2025-03-06T16:09:30+01:00
New Revision: ff993f9a4c23cfaae54f2a2708bed23954b8d9c0

URL: https://github.com/llvm/llvm-project/commit/ff993f9a4c23cfaae54f2a2708bed23954b8d9c0
DIFF: https://github.com/llvm/llvm-project/commit/ff993f9a4c23cfaae54f2a2708bed23954b8d9c0.diff

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

Added: 
    

Modified: 
    libcxx/include/forward_list
    libcxx/include/list

Removed: 
    


################################################################################
diff  --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 8c688611d5ee2..7582de20995b9 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -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));
   }
@@ -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)) {}
@@ -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)) {}

diff  --git a/libcxx/include/list b/libcxx/include/list
index 1285174f1c384..5d5304cced872 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -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>
@@ -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 {


        


More information about the libcxx-commits mailing list