[libcxx-commits] [libcxx] 8ce0fb8 - [libc++][NFC] Reduce use of `__add_lvalue_reference_t` (#112497)

via libcxx-commits libcxx-commits at lists.llvm.org
Wed Oct 16 06:32:08 PDT 2024


Author: A. Jiang
Date: 2024-10-16T09:32:02-04:00
New Revision: 8ce0fb86d3acc066a16637ea5c5691da984707a7

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

LOG: [libc++][NFC] Reduce use of `__add_lvalue_reference_t` (#112497)

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.

Added: 
    

Modified: 
    libcxx/include/__split_buffer
    libcxx/include/future

Removed: 
    


################################################################################
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)


        


More information about the libcxx-commits mailing list