Skip to content
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

[libc++] Remove friend declarations from __tree #133237

Merged
merged 1 commit into from
Mar 28, 2025

Conversation

philnik777
Copy link
Contributor

@philnik777 philnik777 commented Mar 27, 2025

Instead, make the few functions map relies on public. This makes it more clear what is private to __tree and what is part of the library-internal interface.

@philnik777 philnik777 force-pushed the tree_remove_friends branch from a415678 to 3efc859 Compare March 27, 2025 12:35
@philnik777 philnik777 changed the title [libc++] Make __tree::__find_equal public and remove the friend declarations for {,multi}map [libc++] Remove friend declarations from __tree Mar 28, 2025
@philnik777 philnik777 marked this pull request as ready for review March 28, 2025 19:50
@philnik777 philnik777 requested a review from a team as a code owner March 28, 2025 19:50
@philnik777 philnik777 merged commit c8246f6 into llvm:main Mar 28, 2025
82 checks passed
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Mar 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 28, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

Instead, make the few functions map relies on public. This makes it more clear what is private to __tree and what is part of the library-internal interface.


Full diff: https://github.com/llvm/llvm-project/pull/133237.diff

1 Files Affected:

  • (modified) libcxx/include/__tree (+12-16)
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index 08ae8996f8f7d..9d28381c8c2ce 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -1225,11 +1225,6 @@ public:
 
   _LIBCPP_HIDE_FROM_ABI __node_holder remove(const_iterator __p) _NOEXCEPT;
 
-private:
-  _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__parent_pointer& __parent, const key_type& __v);
-  _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__parent_pointer& __parent, const key_type& __v);
-  _LIBCPP_HIDE_FROM_ABI __node_base_pointer&
-  __find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v);
   // FIXME: Make this function const qualified. Unfortunately doing so
   // breaks existing code which uses non-const callable comparators.
   template <class _Key>
@@ -1242,12 +1237,6 @@ private:
   _LIBCPP_HIDE_FROM_ABI __node_base_pointer&
   __find_equal(const_iterator __hint, __parent_pointer& __parent, __node_base_pointer& __dummy, const _Key& __v);
 
-  template <class... _Args>
-  _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);
-
-  // TODO: Make this _LIBCPP_HIDE_FROM_ABI
-  _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT;
-
   _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree& __t) {
     __copy_assign_alloc(__t, integral_constant<bool, __node_traits::propagate_on_container_copy_assignment::value>());
   }
@@ -1259,6 +1248,18 @@ private:
   }
   _LIBCPP_HIDE_FROM_ABI void __copy_assign_alloc(const __tree&, false_type) {}
 
+private:
+  _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_low(__parent_pointer& __parent, const key_type& __v);
+  _LIBCPP_HIDE_FROM_ABI __node_base_pointer& __find_leaf_high(__parent_pointer& __parent, const key_type& __v);
+  _LIBCPP_HIDE_FROM_ABI __node_base_pointer&
+  __find_leaf(const_iterator __hint, __parent_pointer& __parent, const key_type& __v);
+
+  template <class... _Args>
+  _LIBCPP_HIDE_FROM_ABI __node_holder __construct_node(_Args&&... __args);
+
+  // TODO: Make this _LIBCPP_HIDE_FROM_ABI
+  _LIBCPP_HIDDEN void destroy(__node_pointer __nd) _NOEXCEPT;
+
   _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, false_type);
   _LIBCPP_HIDE_FROM_ABI void __move_assign(__tree& __t, true_type) _NOEXCEPT_(
       is_nothrow_move_assignable<value_compare>::value&& is_nothrow_move_assignable<__node_allocator>::value);
@@ -1311,11 +1312,6 @@ private:
     __node_pointer __cache_root_;
     __node_pointer __cache_elem_;
   };
-
-  template <class, class, class, class>
-  friend class _LIBCPP_TEMPLATE_VIS map;
-  template <class, class, class, class>
-  friend class _LIBCPP_TEMPLATE_VIS multimap;
 };
 
 template <class _Tp, class _Compare, class _Allocator>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants