Skip to content

Commit

Permalink
[libc++] Remove __invalidate_all_iterators and replace the uses with …
Browse files Browse the repository at this point in the history
…std::__debug_db_invalidate_all

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D125188
  • Loading branch information
philnik777 committed May 11, 2022
1 parent 08f68df commit c095440
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 47 deletions.
7 changes: 1 addition & 6 deletions libcxx/include/list
Expand Up @@ -679,11 +679,6 @@ private:
void __move_assign_alloc(__list_imp&, false_type)
_NOEXCEPT
{}

_LIBCPP_INLINE_VISIBILITY
void __invalidate_all_iterators() {
std::__debug_db_invalidate_all(this);
}
};

// Unlink nodes [__f, __l]
Expand Down Expand Up @@ -746,7 +741,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
__node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
__node_alloc_traits::deallocate(__na, __np, 1);
}
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}
}

Expand Down
17 changes: 4 additions & 13 deletions libcxx/include/string
Expand Up @@ -1787,7 +1787,6 @@ private:
return *this;
}

_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_all_iterators();
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX17 void __invalidate_iterators_past(size_type);

template<class _Tp>
Expand Down Expand Up @@ -1860,14 +1859,6 @@ basic_string(basic_string_view<_CharT, _Traits>, _Sz, _Sz, const _Allocator& = _
-> basic_string<_CharT, _Traits, _Allocator>;
#endif

template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators()
{
std::__debug_db_invalidate_all(this);
}

template <class _CharT, class _Traits, class _Allocator>
inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
Expand Down Expand Up @@ -2357,7 +2348,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by_and_replace
auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1);
pointer __p = __allocation.ptr;
__begin_lifetime(__p, __allocation.count);
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
if (__n_copy != 0)
traits_type::copy(std::__to_address(__p),
std::__to_address(__old_p), __n_copy);
Expand Down Expand Up @@ -2392,7 +2383,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t
auto __allocation = std::__allocate_at_least(__alloc(), __cap + 1);
pointer __p = __allocation.ptr;
__begin_lifetime(__p, __allocation.count);
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
if (__n_copy != 0)
traits_type::copy(std::__to_address(__p),
std::__to_address(__old_p), __n_copy);
Expand Down Expand Up @@ -3330,7 +3321,7 @@ inline _LIBCPP_CONSTEXPR_AFTER_CXX17
void
basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT
{
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
if (__is_long())
{
traits_type::assign(*__get_long_pointer(), value_type());
Expand Down Expand Up @@ -3481,7 +3472,7 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
}
else
__set_short_size(__sz);
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}

template <class _CharT, class _Traits, class _Allocator>
Expand Down
39 changes: 11 additions & 28 deletions libcxx/include/vector
Expand Up @@ -639,7 +639,7 @@ public:
size_type __old_size = size();
__clear();
__annotate_shrink(__old_size);
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}

void resize(size_type __sz);
Expand Down Expand Up @@ -670,7 +670,6 @@ private:
__compressed_pair<pointer, allocator_type> __end_cap_ =
__compressed_pair<pointer, allocator_type>(nullptr, __default_init_tag());

_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);


Expand Down Expand Up @@ -923,7 +922,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
_VSTD::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}

template <class _Tp, class _Allocator>
Expand All @@ -939,7 +938,7 @@ vector<_Tp, _Allocator>::__swap_out_circular_buffer(__split_buffer<value_type, a
_VSTD::swap(this->__end_cap(), __v.__end_cap());
__v.__first_ = __v.__begin_;
__annotate_new(size());
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
return __r;
}

Expand Down Expand Up @@ -1364,7 +1363,7 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
__vallocate(__recommend(__new_size));
__construct_at_end(__first, __last, __new_size);
}
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}

template <class _Tp, class _Allocator>
Expand All @@ -1386,7 +1385,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
__vallocate(__recommend(static_cast<size_type>(__n)));
__construct_at_end(__n, __u);
}
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}

template <class _Tp, class _Allocator>
Expand Down Expand Up @@ -1996,14 +1995,6 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __

#endif // _LIBCPP_DEBUG_LEVEL == 2

template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<_Tp, _Allocator>::__invalidate_all_iterators()
{
std::__debug_db_invalidate_all(this);
}

template <class _Tp, class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
Expand Down Expand Up @@ -2327,7 +2318,6 @@ private:
// Precondition: __n > 0
// Postcondition: capacity() >= __n
// Postcondition: size() == 0
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
_LIBCPP_HIDE_FROM_ABI void __vallocate(size_type __n) {
if (__n > max_size())
__throw_length_error();
Expand Down Expand Up @@ -2417,21 +2407,14 @@ private:
friend struct _LIBCPP_TEMPLATE_VIS hash<vector>;
};

template <class _Allocator>
inline _LIBCPP_INLINE_VISIBILITY
void
vector<bool, _Allocator>::__invalidate_all_iterators()
{
}

template <class _Allocator>
void
vector<bool, _Allocator>::__vdeallocate() _NOEXCEPT
{
if (this->__begin_ != nullptr)
{
__storage_traits::deallocate(this->__alloc(), this->__begin_, __cap());
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
this->__begin_ = nullptr;
this->__size_ = this->__cap() = 0;
}
Expand Down Expand Up @@ -2604,7 +2587,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
Expand All @@ -2631,7 +2614,7 @@ vector<bool, _Allocator>::vector(_InputIterator __first, _InputIterator __last,
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
throw;
}
#endif // _LIBCPP_NO_EXCEPTIONS
Expand Down Expand Up @@ -2706,7 +2689,7 @@ vector<bool, _Allocator>::~vector()
{
if (__begin_ != nullptr)
__storage_traits::deallocate(__alloc(), __begin_, __cap());
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}

template <class _Allocator>
Expand Down Expand Up @@ -2850,7 +2833,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
}
_VSTD::fill_n(begin(), __n, __x);
}
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}

template <class _Allocator>
Expand Down Expand Up @@ -2904,7 +2887,7 @@ vector<bool, _Allocator>::reserve(size_type __n)
__v.__vallocate(__n);
__v.__construct_at_end(this->begin(), this->end());
swap(__v);
__invalidate_all_iterators();
std::__debug_db_invalidate_all(this);
}
}

Expand Down

0 comments on commit c095440

Please sign in to comment.