Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4d6913e

Browse files
authored
[libcxx] Rename __split_buffer alias template to _SplitBuffer (llvm#180284)
`-Wchanges-meaning` is a GCC warning that catches shadowing in more contexts. While a bit annoying here, it's a helpful warning. As such, we need to rename the `__split_buffer` alias template in `std::vector` so that we don't trip it up.
1 parent 047db15 commit 4d6913e

1 file changed

Lines changed: 20 additions & 23 deletions

File tree

libcxx/include/__vector/vector.h

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
8585

8686
template <class _Tp, class _Allocator /* = allocator<_Tp> */>
8787
class vector {
88-
template <class _Up, class _Alloc>
89-
using __split_buffer _LIBCPP_NODEBUG = std::__split_buffer<_Up, _Alloc, __split_buffer_pointer_layout>;
88+
using _SplitBuffer _LIBCPP_NODEBUG = std::__split_buffer<_Tp, _Allocator, __split_buffer_pointer_layout>;
9089

9190
public:
9291
//
@@ -487,7 +486,7 @@ class vector {
487486
if (__len < __cap_ - __end_) {
488487
__construct_at_end(ranges::begin(__range), ranges::end(__range), __len);
489488
} else {
490-
__split_buffer<value_type, allocator_type> __buffer(__recommend(size() + __len), size(), __alloc_);
489+
_SplitBuffer __buffer(__recommend(size() + __len), size(), __alloc_);
491490
__buffer.__construct_at_end_with_size(ranges::begin(__range), __len);
492491
__swap_out_circular_buffer(__buffer);
493492
}
@@ -698,10 +697,9 @@ class vector {
698697
#endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_VECTOR
699698
}
700699

701-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
702-
__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v);
700+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_out_circular_buffer(_SplitBuffer& __v);
703701
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI pointer
704-
__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v, pointer __p);
702+
__swap_out_circular_buffer(_SplitBuffer& __v, pointer __p);
705703
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void
706704
__move_range(pointer __from_s, pointer __from_e, pointer __to);
707705
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __move_assign(vector& __c, true_type)
@@ -811,7 +809,7 @@ class vector {
811809
static _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI _Ptr
812810
__add_alignment_assumption(_Ptr __p) _NOEXCEPT {
813811
if (!__libcpp_is_constant_evaluated()) {
814-
return static_cast<_Ptr>(__builtin_assume_aligned(__p, _LIBCPP_ALIGNOF(decltype(*__p))));
812+
return static_cast<pointer>(__builtin_assume_aligned(__p, _LIBCPP_ALIGNOF(decltype(*__p))));
815813
}
816814
return __p;
817815
}
@@ -822,7 +820,7 @@ class vector {
822820
return __p;
823821
}
824822

825-
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_layouts(__split_buffer<_Tp, allocator_type>& __sb) {
823+
_LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __swap_layouts(_SplitBuffer& __sb) {
826824
auto __vector_begin = __begin_;
827825
auto __vector_sentinel = __end_;
828826
auto __vector_cap = __cap_;
@@ -866,8 +864,7 @@ vector(from_range_t, _Range&&, _Alloc = _Alloc()) -> vector<ranges::range_value_
866864
// *this and __v. It is assumed that __v provides space for exactly (__end_ - __begin_) objects in the front. This
867865
// function has a strong exception guarantee.
868866
template <class _Tp, class _Allocator>
869-
_LIBCPP_CONSTEXPR_SINCE_CXX20 void
870-
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v) {
867+
_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::__swap_out_circular_buffer(_SplitBuffer& __v) {
871868
__annotate_delete();
872869
auto __new_begin = __v.begin() - size();
873870
std::__uninitialized_allocator_relocate(
@@ -886,7 +883,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
886883
// function has a strong exception guarantee if __begin_ == __p || __end_ == __p.
887884
template <class _Tp, class _Allocator>
888885
_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
889-
vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, allocator_type>& __v, pointer __p) {
886+
vector<_Tp, _Allocator>::__swap_out_circular_buffer(_SplitBuffer& __v, pointer __p) {
890887
__annotate_delete();
891888
pointer __ret = __v.begin();
892889

@@ -1086,7 +1083,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __
10861083
if (__n > capacity()) {
10871084
if (__n > max_size())
10881085
this->__throw_length_error();
1089-
__split_buffer<value_type, allocator_type> __v(__n, size(), this->__alloc_);
1086+
_SplitBuffer __v(__n, size(), this->__alloc_);
10901087
__swap_out_circular_buffer(__v);
10911088
}
10921089
}
@@ -1097,7 +1094,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE
10971094
#if _LIBCPP_HAS_EXCEPTIONS
10981095
try {
10991096
#endif // _LIBCPP_HAS_EXCEPTIONS
1100-
__split_buffer<value_type, allocator_type> __v(size(), size(), this->__alloc_);
1097+
_SplitBuffer __v(size(), size(), this->__alloc_);
11011098
// The Standard mandates shrink_to_fit() does not increase the capacity.
11021099
// With equal capacity keep the existing buffer. This avoids extra work
11031100
// due to swapping the elements.
@@ -1114,7 +1111,7 @@ template <class _Tp, class _Allocator>
11141111
template <class... _Args>
11151112
_LIBCPP_CONSTEXPR_SINCE_CXX20 typename vector<_Tp, _Allocator>::pointer
11161113
vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) {
1117-
__split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), size(), this->__alloc_);
1114+
_SplitBuffer __v(__recommend(size() + 1), size(), this->__alloc_);
11181115
// __v.emplace_back(std::forward<_Args>(__args)...);
11191116
pointer __end = __v.end();
11201117
__alloc_traits::construct(this->__alloc_, std::__to_address(__end), std::forward<_Args>(__args)...);
@@ -1217,7 +1214,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, const_reference __x)
12171214
*__p = *__xr;
12181215
}
12191216
} else {
1220-
__split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1217+
_SplitBuffer __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
12211218
__v.emplace_back(__x);
12221219
__p = __swap_out_circular_buffer(__v, __p);
12231220
}
@@ -1236,7 +1233,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, value_type&& __x) {
12361233
*__p = std::move(__x);
12371234
}
12381235
} else {
1239-
__split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1236+
_SplitBuffer __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
12401237
__v.emplace_back(std::move(__x));
12411238
__p = __swap_out_circular_buffer(__v, __p);
12421239
}
@@ -1257,7 +1254,7 @@ vector<_Tp, _Allocator>::emplace(const_iterator __position, _Args&&... __args) {
12571254
*__p = std::move(__tmp.get());
12581255
}
12591256
} else {
1260-
__split_buffer<value_type, allocator_type> __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
1257+
_SplitBuffer __v(__recommend(size() + 1), __p - this->__begin_, this->__alloc_);
12611258
__v.emplace_back(std::forward<_Args>(__args)...);
12621259
__p = __swap_out_circular_buffer(__v, __p);
12631260
}
@@ -1285,7 +1282,7 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, size_type __n, const_
12851282
std::fill_n(__p, __n, *__xr);
12861283
}
12871284
} else {
1288-
__split_buffer<value_type, allocator_type> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
1285+
_SplitBuffer __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
12891286
__v.__construct_at_end(__n, __x);
12901287
__p = __swap_out_circular_buffer(__v, __p);
12911288
}
@@ -1306,11 +1303,11 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu
13061303
if (__first == __last)
13071304
(void)std::rotate(__p, __old_last, this->__end_);
13081305
else {
1309-
__split_buffer<value_type, allocator_type> __v(__alloc_);
1306+
_SplitBuffer __v(__alloc_);
13101307
auto __guard = std::__make_exception_guard(
13111308
_AllocatorDestroyRangeReverse<allocator_type, pointer>(__alloc_, __old_last, this->__end_));
13121309
__v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last));
1313-
__split_buffer<value_type, allocator_type> __merged(
1310+
_SplitBuffer __merged(
13141311
__recommend(size() + __v.size()), __off, __alloc_); // has `__off` positions available at the front
13151312
std::__uninitialized_allocator_relocate(
13161313
__alloc_, std::__to_address(__old_last), std::__to_address(this->__end_), std::__to_address(__merged.end()));
@@ -1356,7 +1353,7 @@ vector<_Tp, _Allocator>::__insert_with_size(
13561353
__insert_assign_n_unchecked<_AlgPolicy>(std::move(__first), __n, __p);
13571354
}
13581355
} else {
1359-
__split_buffer<value_type, allocator_type> __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
1356+
_SplitBuffer __v(__recommend(size() + __n), __p - this->__begin_, this->__alloc_);
13601357
__v.__construct_at_end_with_size(std::move(__first), __n);
13611358
__p = __swap_out_circular_buffer(__v, __p);
13621359
}
@@ -1371,7 +1368,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __n
13711368
if (__new_size <= capacity()) {
13721369
__construct_at_end(__new_size - __current_size);
13731370
} else {
1374-
__split_buffer<value_type, allocator_type> __v(__recommend(__new_size), __current_size, __alloc_);
1371+
_SplitBuffer __v(__recommend(__new_size), __current_size, __alloc_);
13751372
__v.__construct_at_end(__new_size - __current_size);
13761373
__swap_out_circular_buffer(__v);
13771374
}
@@ -1387,7 +1384,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::resize(size_type __n
13871384
if (__new_size <= capacity())
13881385
__construct_at_end(__new_size - __current_size, __x);
13891386
else {
1390-
__split_buffer<value_type, allocator_type> __v(__recommend(__new_size), __current_size, __alloc_);
1387+
_SplitBuffer __v(__recommend(__new_size), __current_size, __alloc_);
13911388
__v.__construct_at_end(__new_size - __current_size, __x);
13921389
__swap_out_circular_buffer(__v);
13931390
}

0 commit comments

Comments
 (0)