[cfe-commits] [libcxx] r139930 - in /libcxx/trunk: include/vector test/containers/sequences/vector/vector.special/swap.pass.cpp

Howard Hinnant hhinnant at apple.com
Fri Sep 16 11:41:29 PDT 2011


Author: hhinnant
Date: Fri Sep 16 13:41:29 2011
New Revision: 139930

URL: http://llvm.org/viewvc/llvm-project?rev=139930&view=rev
Log:
The vector test suite now passes for no-debug, debug-lite and debug-regular

Modified:
    libcxx/trunk/include/vector
    libcxx/trunk/test/containers/sequences/vector/vector.special/swap.pass.cpp

Modified: libcxx/trunk/include/vector
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/vector?rev=139930&r1=139929&r2=139930&view=diff
==============================================================================
--- libcxx/trunk/include/vector (original)
+++ libcxx/trunk/include/vector Fri Sep 16 13:41:29 2011
@@ -970,41 +970,41 @@
 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 @@
        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 @@
                          !__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 @@
 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 @@
                                 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 @@
         _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 @@
 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 @@
         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 @@
 _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 @@
 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 @@
 #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;
 }
 

Modified: libcxx/trunk/test/containers/sequences/vector/vector.special/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/vector.special/swap.pass.cpp?rev=139930&r1=139929&r2=139930&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/vector.special/swap.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/vector/vector.special/swap.pass.cpp Fri Sep 16 13:41:29 2011
@@ -58,6 +58,8 @@
         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 @@
         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};





More information about the cfe-commits mailing list