diff options
author | Howard Hinnant <hhinnant@apple.com> | 2011-09-16 18:41:29 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2011-09-16 18:41:29 +0000 |
commit | 0695db06d76088e6482de7284a7efeb2d5ccea86 (patch) | |
tree | 8f7ece061e170a596baec4b3198aca3b62d2a918 /libcxx | |
parent | 8aee874bf1202772b25e25489d17c939eb7bbddb (diff) | |
download | bcm5719-llvm-0695db06d76088e6482de7284a7efeb2d5ccea86.tar.gz bcm5719-llvm-0695db06d76088e6482de7284a7efeb2d5ccea86.zip |
The vector test suite now passes for no-debug, debug-lite and debug-regular
llvm-svn: 139930
Diffstat (limited to 'libcxx')
-rw-r--r-- | libcxx/include/vector | 80 | ||||
-rw-r--r-- | libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp | 3 |
2 files changed, 43 insertions, 40 deletions
diff --git a/libcxx/include/vector b/libcxx/include/vector index 5c3a6978dc3..f469a3a0de5 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -970,41 +970,41 @@ vector<_Tp, _Allocator>::__append(size_type __n, const_reference __x) template <class _Tp, class _Allocator> vector<_Tp, _Allocator>::vector(size_type __n) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__n > 0) { allocate(__n); __construct_at_end(__n); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } template <class _Tp, class _Allocator> vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__n > 0) { allocate(__n); __construct_at_end(__n, __x); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } template <class _Tp, class _Allocator> vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const allocator_type& __a) : __base(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__n > 0) { allocate(__n); __construct_at_end(__n, __x); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } template <class _Tp, class _Allocator> @@ -1013,11 +1013,11 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value>::type*) { - for (; __first != __last; ++__first) - push_back(*__first); #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif + for (; __first != __last; ++__first) + push_back(*__first); } template <class _Tp, class _Allocator> @@ -1027,11 +1027,11 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c !__is_forward_iterator<_InputIterator>::value>::type*) : __base(__a) { - for (; __first != __last; ++__first) - push_back(*__first); #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif + for (; __first != __last; ++__first) + push_back(*__first); } template <class _Tp, class _Allocator> @@ -1039,15 +1039,15 @@ template <class _ForwardIterator> vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); if (__n > 0) { allocate(__n); __construct_at_end(__first, __last); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } template <class _Tp, class _Allocator> @@ -1056,45 +1056,45 @@ vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __las typename enable_if<__is_forward_iterator<_ForwardIterator>::value>::type*) : __base(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last)); if (__n > 0) { allocate(__n); __construct_at_end(__first, __last); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } template <class _Tp, class _Allocator> vector<_Tp, _Allocator>::vector(const vector& __x) : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif size_type __n = __x.size(); if (__n > 0) { allocate(__n); __construct_at_end(__x.__begin_, __x.__end_); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } template <class _Tp, class _Allocator> vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) : __base(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif size_type __n = __x.size(); if (__n > 0) { allocate(__n); __construct_at_end(__x.__begin_, __x.__end_); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1105,14 +1105,14 @@ vector<_Tp, _Allocator>::vector(vector&& __x) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) : __base(_VSTD::move(__x.__alloc())) { - this->__begin_ = __x.__begin_; - this->__end_ = __x.__end_; - this->__end_cap() = __x.__end_cap(); - __x.__begin_ = __x.__end_ = __x.__end_cap() = 0; #if _LIBCPP_DEBUG_LEVEL >= 2 __x.__invalidate_all_iterators(); __get_db()->__insert_c(this); #endif + this->__begin_ = __x.__begin_; + this->__end_ = __x.__end_; + this->__end_cap() = __x.__end_cap(); + __x.__begin_ = __x.__end_ = __x.__end_cap() = 0; } template <class _Tp, class _Allocator> @@ -1120,6 +1120,9 @@ _LIBCPP_INLINE_VISIBILITY inline vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) : __base(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__a == __x.__alloc()) { this->__begin_ = __x.__begin_; @@ -1133,9 +1136,6 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) typedef move_iterator<iterator> _I; assign(_I(__x.begin()), _I(__x.end())); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -1144,14 +1144,14 @@ template <class _Tp, class _Allocator> _LIBCPP_INLINE_VISIBILITY inline vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__il.size() > 0) { allocate(__il.size()); __construct_at_end(__il.begin(), __il.end()); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } template <class _Tp, class _Allocator> @@ -1159,14 +1159,14 @@ _LIBCPP_INLINE_VISIBILITY inline vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif if (__il.size() > 0) { allocate(__il.size()); __construct_at_end(__il.begin(), __il.end()); } -#if _LIBCPP_DEBUG_LEVEL >= 2 - __get_db()->__insert_c(this); -#endif } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -1747,8 +1747,8 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs #endif // _LIBCPP_NO_EXCEPTIONS } __p = _VSTD::rotate(__p, __old_last, this->__end_); - insert(__make_iter(__p), move_iterator<iterator>(__v.begin()), - move_iterator<iterator>(__v.end())); + insert(__make_iter(__p), make_move_iterator(__v.begin()), + make_move_iterator(__v.end())); return begin() + __off; } diff --git a/libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp b/libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp index 47773c5023a..7cad0f45135 100644 --- a/libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp +++ b/libcxx/test/containers/sequences/vector/vector.special/swap.pass.cpp @@ -58,6 +58,8 @@ int main() assert(c2.empty()); assert(distance(c2.begin(), c2.end()) == 0); } +#ifndef _LIBCPP_DEBUG_LEVEL +// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; @@ -70,6 +72,7 @@ int main() assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); assert(c2.get_allocator() == A(2)); } +#endif { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; |