Skip to content

Conversation

@frederick-vs-ja
Copy link
Contributor

@frederick-vs-ja frederick-vs-ja commented Oct 16, 2024

Currently, the occurrences of __add_lvalue_reference_t in __split_buffer and __assoc_state are probably meaningless.

  • In __split_buffer, the __alloc_ref and __alloc_const_ref member typedefs are no longer used.
  • In __assoc_state, we should simply use _Rp&, which must be well-formed since it's already required that sizeof(_Rp) is well-formed.

This PR removes the meaningless usages. The remaining occurrences in shared_ptr, unique_ptr, and several type traits are meaningful.

Currently, the occurrences of `__add_lvalue_reference_t` in
`__split_buffer` and `__assoc_state` are probably meaningless.

* In `__split_buffer`, the `__alloc_ref` and `__alloc_const_ref` member
typedefs are no longer used.
* In `__assoc_state`, we should simply use `_Rp&`, which must be
well-formed since it's already required that `sizeof(_Rp)` is
well-formed.

This PR removes the meaningless usages. The remaining occurences in
`shared_ptr`, `unique_ptr`, and several type traits are meaningful.
@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner October 16, 2024 08:19
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Oct 16, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 16, 2024

@llvm/pr-subscribers-libcxx

Author: A. Jiang (frederick-vs-ja)

Changes

Currently, the occurrences of __add_lvalue_reference_t in __split_buffer and __assoc_state are probably meaningless.

  • In __split_buffer, the __alloc_ref and __alloc_const_ref member typedefs are no longer used.
  • In __assoc_state, we should simply use _Rp&, which must be well-formed since it's already required that sizeof(_Rp) is well-formed.

This PR removes the meaningless usages. The remaining occurences in shared_ptr, unique_ptr, and several type traits are meaningful.


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

2 Files Affected:

  • (modified) libcxx/include/__split_buffer (-3)
  • (modified) libcxx/include/future (+2-2)
diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer
index dfe552fbb45893..c4817601039f3b 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -80,9 +80,6 @@ public:
   pointer __end_;
   _LIBCPP_COMPRESSED_PAIR(pointer, __end_cap_, allocator_type, __alloc_);
 
-  using __alloc_ref       = __add_lvalue_reference_t<allocator_type>;
-  using __alloc_const_ref = __add_lvalue_reference_t<allocator_type>;
-
   __split_buffer(const __split_buffer&)            = delete;
   __split_buffer& operator=(const __split_buffer&) = delete;
 
diff --git a/libcxx/include/future b/libcxx/include/future
index dfa373d6593c79..f16f4234c48966 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -594,7 +594,7 @@ public:
   _LIBCPP_HIDE_FROM_ABI void set_value_at_thread_exit(_Arg&& __arg);
 
   _LIBCPP_HIDE_FROM_ABI _Rp move();
-  _LIBCPP_HIDE_FROM_ABI __add_lvalue_reference_t<_Rp> copy();
+  _LIBCPP_HIDE_FROM_ABI _Rp& copy();
 };
 
 template <class _Rp>
@@ -636,7 +636,7 @@ _Rp __assoc_state<_Rp>::move() {
 }
 
 template <class _Rp>
-__add_lvalue_reference_t<_Rp> __assoc_state<_Rp>::copy() {
+_Rp& __assoc_state<_Rp>::copy() {
   unique_lock<mutex> __lk(this->__mut_);
   this->__sub_wait(__lk);
   if (this->__exception_ != nullptr)

Copy link
Contributor

@philnik777 philnik777 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup!

@ldionne ldionne merged commit 8ce0fb8 into llvm:main Oct 16, 2024
69 checks passed
@frederick-vs-ja frederick-vs-ja deleted the redux-add-lvalue-reference-t branch October 16, 2024 14:27
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.

4 participants