diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2013-08-23 19:03:36 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2013-08-23 19:03:36 +0000 |
| commit | 2f57df2aa973e09a35aea1fcf18f4e415489dc78 (patch) | |
| tree | 05a463c910c6057d5bd44de6ed75fc92c08b1388 | |
| parent | 469c056299c2efd046c85fee5864d098facbd627 (diff) | |
| download | bcm5719-llvm-2f57df2aa973e09a35aea1fcf18f4e415489dc78.tar.gz bcm5719-llvm-2f57df2aa973e09a35aea1fcf18f4e415489dc78.zip | |
Remove _LIBCPP_DEBUG. This was my first attempt at debug mode for libc++, and is now obsoleted by _LIBCPP_DEBUG2 (which isn't finished).
llvm-svn: 189135
| -rw-r--r-- | libcxx/include/iterator | 416 | ||||
| -rw-r--r-- | libcxx/include/vector | 34 |
2 files changed, 0 insertions, 450 deletions
diff --git a/libcxx/include/iterator b/libcxx/include/iterator index 8e92e6fef1e..bea09a66339 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -1371,422 +1371,6 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, return __x; } -#ifdef _LIBCPP_DEBUG - -// __debug_iter - -template <class _Container, class _Iter> class __debug_iter; - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter> -_LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type, const __debug_iter<_Container, _Iter>&); - -template <class _Container, class _Iter> -class __debug_iter -{ -public: - typedef _Iter iterator_type; - typedef _Container __container_type; - typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; - typedef typename iterator_traits<iterator_type>::value_type value_type; - typedef typename iterator_traits<iterator_type>::difference_type difference_type; - typedef typename iterator_traits<iterator_type>::pointer pointer; - typedef typename iterator_traits<iterator_type>::reference reference; -private: - iterator_type __i; - __debug_iter* __next; - __container_type* __cont; - -public: - _LIBCPP_INLINE_VISIBILITY __debug_iter() : __next(0), __cont(0) {} - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter& __x) - : __i(__x.base()), __next(0), __cont(0) {__set_owner(__x.__cont);} - __debug_iter& operator=(const __debug_iter& __x); - template <class _Up> _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter<_Container, _Up>& __u, - typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) - : __i(__u.base()), __next(0), __cont(0) {__set_owner(__u.__cont);} - _LIBCPP_INLINE_VISIBILITY ~__debug_iter() {__remove_owner();} - _LIBCPP_INLINE_VISIBILITY reference operator*() const {assert(__is_deref()); return *__i;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator++() {assert(__can_increment()); ++__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator++(int) - {__debug_iter __tmp(*this); operator++(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator--() {assert(__can_decrement()); --__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator--(int) - {__debug_iter __tmp(*this); operator--(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator+ (difference_type __n) const - {__debug_iter __t(*this); __t += __n; return __t;} - __debug_iter& operator+=(difference_type __n); - _LIBCPP_INLINE_VISIBILITY __debug_iter operator- (difference_type __n) const - {__debug_iter __t(*this); __t -= __n; return __t;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator-=(difference_type __n) - {*this += -__n; return *this;} - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const - {return *(*this + __n);} - -private: - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __container_type* __c, iterator_type __x) - : __i(__x), __next(0), __cont(0) {__set_owner(__c);} - _LIBCPP_INLINE_VISIBILITY iterator_type base() const {return __i;} - - void __set_owner(const __container_type* __c); - void __remove_owner(); - static void __remove_all(__container_type* __c); - static void swap(__container_type* __x, __container_type* __y); - - _LIBCPP_INLINE_VISIBILITY bool __is_deref() const - {return __is_deref(__is_random_access_iterator<iterator_type>());} - bool __is_deref(false_type) const; - bool __is_deref(true_type) const; - _LIBCPP_INLINE_VISIBILITY bool __can_decrement() const - {return __can_decrement(integral_constant<int, is_pointer<iterator_type>::value ? 2: - __is_random_access_iterator<iterator_type>::value ? 1 : 0>());} - bool __can_decrement(integral_constant<int, 0>) const; - bool __can_decrement(integral_constant<int, 1>) const; - bool __can_decrement(integral_constant<int, 2>) const; - _LIBCPP_INLINE_VISIBILITY bool __can_increment() const - {return __can_increment(integral_constant<int, is_pointer<iterator_type>::value ? 2: - __is_random_access_iterator<iterator_type>::value ? 1 : 0>());} - bool __can_increment(integral_constant<int, 0>) const; - bool __can_increment(integral_constant<int, 1>) const; - bool __can_increment(integral_constant<int, 2>) const; - - _LIBCPP_INLINE_VISIBILITY bool __can_add(difference_type __n) const - {return __can_add(__n, is_pointer<iterator_type>());} - bool __can_add(difference_type __n, false_type) const; - bool __can_add(difference_type __n, true_type) const; - - template <class _Cp, class _Up> friend class __debug_iter; - friend class _Container::__self; - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator==(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator<(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator!=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator>(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator>=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator<=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - typename __debug_iter<_Cp, _Iter1>::difference_type - operator-(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1> - friend - __debug_iter<_Cp, _Iter1> - operator+(typename __debug_iter<_Cp, _Iter1>::difference_type, const __debug_iter<_Cp, _Iter1>&); -}; - -template <class _Container, class _Iter> -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator=(const __debug_iter& __x) -{ - if (this != &__x) - { - __remove_owner(); - __i = __x.__i; - __set_owner(__x.__cont); - } - return *this; -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__set_owner(const __container_type* __c) -{ - __cont = const_cast<__container_type*>(__c); - __debug_iter*& __head = __cont->__get_iterator_list(this); - __next = __head; - __head = this; -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__remove_owner() -{ - if (__cont) - { - __debug_iter*& __head = __cont->__get_iterator_list(this); - if (__head == this) - __head = __next; - else - { - __debug_iter* __prev = __head; - for (__debug_iter* __p = __head->__next; __p != this; __p = __p->__next) - __prev = __p; - __prev->__next = __next; - } - __cont = 0; - } -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__remove_all(__container_type* __c) -{ - __debug_iter*& __head = __c->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head; - __head = 0; - while (__p) - { - __p->__cont = 0; - __debug_iter* __n = __p->__next; - __p->__next = 0; - __p = __n; - } -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::swap(__container_type* __x, __container_type* __y) -{ - __debug_iter*& __head_x = __x->__get_iterator_list((__debug_iter*)0); - __debug_iter*& __head_y = __y->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head_x; - __head_x = __head_y; - __head_y = __p; - for (__p = __head_x; __p; __p = __p->__next) - __p->__cont = __x; - for (__p = __head_y; __p; __p = __p->__next) - __p->__cont = __y; -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__is_deref(false_type) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__is_deref(true_type) const -{ - if (__cont == 0) - return false; - return __i < __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 0>) const -{ - if (__cont == 0) - return false; - return __i != __cont->begin().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 1>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 2>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 0>) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 1>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 2>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, false_type) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, true_type) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator+=(difference_type __n) -{ - assert(__can_add(__n)); - __i += __n; - return *this; -} - -template <class _Container, class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) -{ - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() == __y.base(); -} - -template <class _Container, class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) -{ - return !(__x == __y); -} - -template <class _Container, class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) -{ - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() < __y.base(); -} - -template <class _Container, class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) -{ - return __y < __x; -} - -template <class _Container, class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) -{ - return !(__x < __y); -} - -template <class _Container, class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) -{ - return !(__y < __x); -} - -template <class _Container, class _Iter1, class _Iter2> -inline _LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) -{ - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() - __y.base(); -} - -template <class _Container, class _Iter> -inline _LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type __n, - const __debug_iter<_Container, _Iter>& __x) -{ - return __x + __n; -} - -#endif // _LIBCPP_DEBUG - #if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) template <class _Cp> diff --git a/libcxx/include/vector b/libcxx/include/vector index 2915e127162..6a9d5a6410f 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -2026,21 +2026,8 @@ public: typedef size_type __storage_type; typedef __bit_iterator<vector, false> pointer; typedef __bit_iterator<vector, true> const_pointer; -#ifdef _LIBCPP_DEBUG - typedef __debug_iter<vector, pointer> iterator; - typedef __debug_iter<vector, const_pointer> const_iterator; - - friend class __debug_iter<vector, pointer>; - friend class __debug_iter<vector, const_pointer>; - - pair<iterator*, const_iterator*> __iterator_list_; - - _LIBCPP_INLINE_VISIBILITY iterator*& __get_iterator_list(iterator*) {return __iterator_list_.first;} - _LIBCPP_INLINE_VISIBILITY const_iterator*& __get_iterator_list(const_iterator*) {return __iterator_list_.second;} -#else // _LIBCPP_DEBUG typedef pointer iterator; typedef const_pointer const_iterator; -#endif // _LIBCPP_DEBUG typedef _VSTD::reverse_iterator<iterator> reverse_iterator; typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; @@ -2299,14 +2286,6 @@ private: _LIBCPP_INLINE_VISIBILITY const_reference __make_ref(size_type __pos) const _NOEXCEPT {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} -#ifdef _LIBCPP_DEBUG - _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) - {return iterator(this, pointer(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)));} - _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_type __pos) const - {return const_iterator(this, const_pointer(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)));} - _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) - {return iterator(this, pointer(const_cast<__storage_pointer>(__p.base().__seg_), __p.base().__ctz_));} -#else // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) _NOEXCEPT {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} @@ -2316,7 +2295,6 @@ private: _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {return begin() + (__p - cbegin());} -#endif // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector& __v) @@ -2387,16 +2365,10 @@ private: }; template <class _Allocator> -#ifndef _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY inline -#endif void vector<bool, _Allocator>::__invalidate_all_iterators() { -#ifdef _LIBCPP_DEBUG - iterator::__remove_all(this); - const_iterator::__remove_all(this); -#endif // _LIBCPP_DEBUG } // Allocate space for __n objects @@ -2666,9 +2638,7 @@ vector<bool, _Allocator>::~vector() { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); -#ifdef _LIBCPP_DEBUG __invalidate_all_iterators(); -#endif } template <class _Allocator> @@ -3073,10 +3043,6 @@ vector<bool, _Allocator>::swap(vector& __x) _VSTD::swap(this->__size_, __x.__size_); _VSTD::swap(this->__cap(), __x.__cap()); __swap_alloc(this->__alloc(), __x.__alloc()); -#ifdef _LIBCPP_DEBUG - iterator::swap(this, &__x); - const_iterator::swap(this, &__x); -#endif // _LIBCPP_DEBUG } template <class _Allocator> |

