[libcxx-commits] [libcxx] c095440 - [libc++] Remove __invalidate_all_iterators and replace the uses with std::__debug_db_invalidate_all

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Wed May 11 12:36:33 PDT 2022


Author: Nikolas Klauser
Date: 2022-05-11T21:36:06+02:00
New Revision: c095440cafb22f9342fafbbef0b8dee04fc24206

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

LOG: [libc++] Remove __invalidate_all_iterators and replace the uses with std::__debug_db_invalidate_all

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D125188

Added: 
    

Modified: 
    libcxx/include/list
    libcxx/include/string
    libcxx/include/vector

Removed: 
    


################################################################################
diff  --git a/libcxx/include/list b/libcxx/include/list
index 0f765d2f1b39..3dffcdd1f829 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -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]
@@ -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);
     }
 }
 

diff  --git a/libcxx/include/string b/libcxx/include/string
index c113e2f8b1b0..961f8c6228cd 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -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>
@@ -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
@@ -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);
@@ -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);
@@ -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());
@@ -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>

diff  --git a/libcxx/include/vector b/libcxx/include/vector
index 753b0232840f..07c7476cfeb3 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -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);
@@ -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);
 
 
@@ -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>
@@ -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;
 }
 
@@ -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>
@@ -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>
@@ -1996,14 +1995,6 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptr
diff _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
@@ -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();
@@ -2417,13 +2407,6 @@ 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
@@ -2431,7 +2414,7 @@ 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;
     }
@@ -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
@@ -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
@@ -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>
@@ -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>
@@ -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);
     }
 }
 


        


More information about the libcxx-commits mailing list