Fix debug mode for vector/list and cleanup tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@290657 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
44
include/list
44
include/list
@@ -626,9 +626,9 @@ protected:
|
|||||||
|
|
||||||
void swap(__list_imp& __c)
|
void swap(__list_imp& __c)
|
||||||
#if _LIBCPP_STD_VER >= 14
|
#if _LIBCPP_STD_VER >= 14
|
||||||
_NOEXCEPT;
|
_NOEXCEPT_DEBUG;
|
||||||
#else
|
#else
|
||||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
|
_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
|
||||||
__is_nothrow_swappable<allocator_type>::value);
|
__is_nothrow_swappable<allocator_type>::value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -669,6 +669,13 @@ private:
|
|||||||
void __move_assign_alloc(__list_imp&, false_type)
|
void __move_assign_alloc(__list_imp&, false_type)
|
||||||
_NOEXCEPT
|
_NOEXCEPT
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
|
void __invalidate_all_iterators() {
|
||||||
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
|
__get_db()->__invalidate_all(this);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Unlink nodes [__f, __l]
|
// Unlink nodes [__f, __l]
|
||||||
@@ -724,21 +731,7 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT
|
|||||||
__node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
|
__node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_));
|
||||||
__node_alloc_traits::deallocate(__na, __np, 1);
|
__node_alloc_traits::deallocate(__na, __np, 1);
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
__invalidate_all_iterators();
|
||||||
__c_node* __c = __get_db()->__find_c_and_lock(this);
|
|
||||||
for (__i_node** __p = __c->end_; __p != __c->beg_; )
|
|
||||||
{
|
|
||||||
--__p;
|
|
||||||
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
|
|
||||||
if (__i->__ptr_ != __l)
|
|
||||||
{
|
|
||||||
(*__p)->__c_ = nullptr;
|
|
||||||
if (--__c->end_ != __p)
|
|
||||||
memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
__get_db()->unlock();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,9 +739,9 @@ template <class _Tp, class _Alloc>
|
|||||||
void
|
void
|
||||||
__list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
|
__list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
|
||||||
#if _LIBCPP_STD_VER >= 14
|
#if _LIBCPP_STD_VER >= 14
|
||||||
_NOEXCEPT
|
_NOEXCEPT_DEBUG
|
||||||
#else
|
#else
|
||||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
|
_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
|
||||||
__is_nothrow_swappable<allocator_type>::value)
|
__is_nothrow_swappable<allocator_type>::value)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -1002,9 +995,9 @@ public:
|
|||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
void swap(list& __c)
|
void swap(list& __c)
|
||||||
#if _LIBCPP_STD_VER >= 14
|
#if _LIBCPP_STD_VER >= 14
|
||||||
_NOEXCEPT
|
_NOEXCEPT_DEBUG
|
||||||
#else
|
#else
|
||||||
_NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
|
_NOEXCEPT_DEBUG_(!__node_alloc_traits::propagate_on_container_swap::value ||
|
||||||
__is_nothrow_swappable<__node_allocator>::value)
|
__is_nothrow_swappable<__node_allocator>::value)
|
||||||
#endif
|
#endif
|
||||||
{base::swap(__c);}
|
{base::swap(__c);}
|
||||||
@@ -1361,6 +1354,9 @@ list<_Tp, _Alloc>::assign(_InpIter __f, _InpIter __l,
|
|||||||
insert(__e, __f, __l);
|
insert(__e, __f, __l);
|
||||||
else
|
else
|
||||||
erase(__i, __e);
|
erase(__i, __e);
|
||||||
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
|
__get_db()->__invalidate_all(this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Tp, class _Alloc>
|
template <class _Tp, class _Alloc>
|
||||||
@@ -1375,6 +1371,9 @@ list<_Tp, _Alloc>::assign(size_type __n, const value_type& __x)
|
|||||||
insert(__e, __n, __x);
|
insert(__e, __n, __x);
|
||||||
else
|
else
|
||||||
erase(__i, __e);
|
erase(__i, __e);
|
||||||
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
|
__get_db()->__invalidate_all(this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Tp, class _Alloc>
|
template <class _Tp, class _Alloc>
|
||||||
@@ -1790,6 +1789,9 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l)
|
|||||||
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this,
|
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__f) == this,
|
||||||
"list::erase(iterator, iterator) called with an iterator not"
|
"list::erase(iterator, iterator) called with an iterator not"
|
||||||
" referring to this list");
|
" referring to this list");
|
||||||
|
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__l) == this,
|
||||||
|
"list::erase(iterator, iterator) called with an iterator not"
|
||||||
|
" referring to this list");
|
||||||
#endif
|
#endif
|
||||||
if (__f != __l)
|
if (__f != __l)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -738,9 +738,9 @@ public:
|
|||||||
|
|
||||||
void swap(vector&)
|
void swap(vector&)
|
||||||
#if _LIBCPP_STD_VER >= 14
|
#if _LIBCPP_STD_VER >= 14
|
||||||
_NOEXCEPT;
|
_NOEXCEPT_DEBUG;
|
||||||
#else
|
#else
|
||||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
|
_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
|
||||||
__is_nothrow_swappable<allocator_type>::value);
|
__is_nothrow_swappable<allocator_type>::value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -757,6 +757,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
|
_LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators();
|
||||||
|
_LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last);
|
||||||
void allocate(size_type __n);
|
void allocate(size_type __n);
|
||||||
void deallocate() _NOEXCEPT;
|
void deallocate() _NOEXCEPT;
|
||||||
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
|
_LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const;
|
||||||
@@ -786,21 +787,7 @@ private:
|
|||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
void __destruct_at_end(pointer __new_last) _NOEXCEPT
|
void __destruct_at_end(pointer __new_last) _NOEXCEPT
|
||||||
{
|
{
|
||||||
#if _LIBCPP_DEBUG_LEVEL >= 2
|
__invalidate_iterators_past(__new_last);
|
||||||
__c_node* __c = __get_db()->__find_c_and_lock(this);
|
|
||||||
for (__i_node** __p = __c->end_; __p != __c->beg_; )
|
|
||||||
{
|
|
||||||
--__p;
|
|
||||||
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
|
|
||||||
if (__i->base() > __new_last)
|
|
||||||
{
|
|
||||||
(*__p)->__c_ = nullptr;
|
|
||||||
if (--__c->end_ != __p)
|
|
||||||
memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
__get_db()->unlock();
|
|
||||||
#endif
|
|
||||||
size_type __old_size = size();
|
size_type __old_size = size();
|
||||||
__base::__destruct_at_end(__new_last);
|
__base::__destruct_at_end(__new_last);
|
||||||
__annotate_shrink(__old_size);
|
__annotate_shrink(__old_size);
|
||||||
@@ -1415,6 +1402,7 @@ vector<_Tp, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __las
|
|||||||
allocate(__recommend(__new_size));
|
allocate(__recommend(__new_size));
|
||||||
__construct_at_end(__first, __last, __new_size);
|
__construct_at_end(__first, __last, __new_size);
|
||||||
}
|
}
|
||||||
|
__invalidate_all_iterators();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Tp, class _Allocator>
|
template <class _Tp, class _Allocator>
|
||||||
@@ -1436,6 +1424,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u)
|
|||||||
allocate(__recommend(static_cast<size_type>(__n)));
|
allocate(__recommend(static_cast<size_type>(__n)));
|
||||||
__construct_at_end(__n, __u);
|
__construct_at_end(__n, __u);
|
||||||
}
|
}
|
||||||
|
__invalidate_all_iterators();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Tp, class _Allocator>
|
template <class _Tp, class _Allocator>
|
||||||
@@ -1679,8 +1668,9 @@ vector<_Tp, _Allocator>::erase(const_iterator __position)
|
|||||||
"vector::erase(iterator) called with a non-dereferenceable iterator");
|
"vector::erase(iterator) called with a non-dereferenceable iterator");
|
||||||
difference_type __ps = __position - cbegin();
|
difference_type __ps = __position - cbegin();
|
||||||
pointer __p = this->__begin_ + __ps;
|
pointer __p = this->__begin_ + __ps;
|
||||||
iterator __r = __make_iter(__p);
|
|
||||||
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
|
this->__destruct_at_end(_VSTD::move(__p + 1, this->__end_, __p));
|
||||||
|
this->__invalidate_iterators_past(__p-1);
|
||||||
|
iterator __r = __make_iter(__p);
|
||||||
return __r;
|
return __r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1692,12 +1682,17 @@ vector<_Tp, _Allocator>::erase(const_iterator __first, const_iterator __last)
|
|||||||
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
|
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this,
|
||||||
"vector::erase(iterator, iterator) called with an iterator not"
|
"vector::erase(iterator, iterator) called with an iterator not"
|
||||||
" referring to this vector");
|
" referring to this vector");
|
||||||
|
_LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this,
|
||||||
|
"vector::erase(iterator, iterator) called with an iterator not"
|
||||||
|
" referring to this vector");
|
||||||
#endif
|
#endif
|
||||||
_LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
|
_LIBCPP_ASSERT(__first <= __last, "vector::erase(first, last) called with invalid range");
|
||||||
pointer __p = this->__begin_ + (__first - begin());
|
pointer __p = this->__begin_ + (__first - begin());
|
||||||
iterator __r = __make_iter(__p);
|
if (__first != __last) {
|
||||||
if (__first != __last)
|
|
||||||
this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
|
this->__destruct_at_end(_VSTD::move(__p + (__last - __first), this->__end_, __p));
|
||||||
|
this->__invalidate_iterators_past(__p - 1);
|
||||||
|
}
|
||||||
|
iterator __r = __make_iter(__p);
|
||||||
return __r;
|
return __r;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2018,9 +2013,9 @@ template <class _Tp, class _Allocator>
|
|||||||
void
|
void
|
||||||
vector<_Tp, _Allocator>::swap(vector& __x)
|
vector<_Tp, _Allocator>::swap(vector& __x)
|
||||||
#if _LIBCPP_STD_VER >= 14
|
#if _LIBCPP_STD_VER >= 14
|
||||||
_NOEXCEPT
|
_NOEXCEPT_DEBUG
|
||||||
#else
|
#else
|
||||||
_NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
|
_NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
|
||||||
__is_nothrow_swappable<allocator_type>::value)
|
__is_nothrow_swappable<allocator_type>::value)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
@@ -2103,6 +2098,28 @@ vector<_Tp, _Allocator>::__invalidate_all_iterators()
|
|||||||
#endif // _LIBCPP_DEBUG_LEVEL >= 2
|
#endif // _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class _Tp, class _Allocator>
|
||||||
|
inline _LIBCPP_INLINE_VISIBILITY
|
||||||
|
void
|
||||||
|
vector<_Tp, _Allocator>::__invalidate_iterators_past(pointer __new_last) {
|
||||||
|
#if _LIBCPP_DEBUG_LEVEL >= 2
|
||||||
|
__c_node* __c = __get_db()->__find_c_and_lock(this);
|
||||||
|
for (__i_node** __p = __c->end_; __p != __c->beg_; ) {
|
||||||
|
--__p;
|
||||||
|
const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_);
|
||||||
|
if (__i->base() > __new_last) {
|
||||||
|
(*__p)->__c_ = nullptr;
|
||||||
|
if (--__c->end_ != __p)
|
||||||
|
memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__get_db()->unlock();
|
||||||
|
#else
|
||||||
|
((void)__new_last);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// vector<bool>
|
// vector<bool>
|
||||||
|
|
||||||
template <class _Allocator> class vector<bool, _Allocator>;
|
template <class _Allocator> class vector<bool, _Allocator>;
|
||||||
@@ -2898,6 +2915,7 @@ vector<bool, _Allocator>::assign(size_type __n, const value_type& __x)
|
|||||||
}
|
}
|
||||||
_VSTD::fill_n(begin(), __n, __x);
|
_VSTD::fill_n(begin(), __n, __x);
|
||||||
}
|
}
|
||||||
|
__invalidate_all_iterators();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class _Allocator>
|
template <class _Allocator>
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// Call back() on empty container.
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::list<T> C;
|
|
||||||
C c(1);
|
|
||||||
assert(c.back() == 0);
|
|
||||||
c.clear();
|
|
||||||
assert(c.back() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// Call back() on empty const container.
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::list<T> C;
|
|
||||||
const C c;
|
|
||||||
assert(c.back() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// Call front() on empty const container.
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::list<T> C;
|
|
||||||
const C c;
|
|
||||||
assert(c.front() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// Call front() on empty container.
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::list<T> C;
|
|
||||||
C c(1);
|
|
||||||
assert(c.front() == 0);
|
|
||||||
c.clear();
|
|
||||||
assert(c.front() == 0);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// Decrement iterator prior to begin.
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::list<T> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.end();
|
|
||||||
--i;
|
|
||||||
assert(i == c.begin());
|
|
||||||
--i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// Increment iterator past end.
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::list<T> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.begin();
|
|
||||||
++i;
|
|
||||||
assert(i == c.end());
|
|
||||||
++i;
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// Dereference non-dereferenceable iterator.
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
typedef int T;
|
|
||||||
typedef std::list<T> C;
|
|
||||||
C c(1);
|
|
||||||
C::iterator i = c.end();
|
|
||||||
T j = *i;
|
|
||||||
assert(false);
|
|
||||||
((void)j);
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// UNSUPPORTED: c++98, c++03
|
|
||||||
// UNSUPPORTED: libcpp-no-exceptions
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// Operations on "NULL" iterators
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0)
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include <iterator>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
struct S { int val; };
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
unsigned lib_asserts;
|
|
||||||
|
|
||||||
typedef S T;
|
|
||||||
typedef std::list<T> C;
|
|
||||||
C::iterator i{};
|
|
||||||
C::const_iterator ci{};
|
|
||||||
|
|
||||||
lib_asserts = 0;
|
|
||||||
try { ++i; } catch (int) { ++lib_asserts; }
|
|
||||||
try { i++; } catch (int) { ++lib_asserts; }
|
|
||||||
try { ++ci; } catch (int) { ++lib_asserts; }
|
|
||||||
try { ci++; } catch (int) { ++lib_asserts; }
|
|
||||||
assert(lib_asserts == 4);
|
|
||||||
|
|
||||||
lib_asserts = 0;
|
|
||||||
try { --i; } catch (int) { ++lib_asserts; }
|
|
||||||
try { i--; } catch (int) { ++lib_asserts; }
|
|
||||||
try { --ci; } catch (int) { ++lib_asserts; }
|
|
||||||
try { ci--; } catch (int) { ++lib_asserts; }
|
|
||||||
assert(lib_asserts == 4);
|
|
||||||
|
|
||||||
lib_asserts = 0;
|
|
||||||
try { *i; } catch (int) { ++lib_asserts; }
|
|
||||||
try { *ci; } catch (int) { ++lib_asserts; }
|
|
||||||
try { (void) i->val; } catch (int) { ++lib_asserts; }
|
|
||||||
try { (void) ci->val; } catch (int) { ++lib_asserts; }
|
|
||||||
assert(lib_asserts == 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// template <class T, class Alloc>
|
|
||||||
// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int a1[] = {1, 3, 7, 9, 10};
|
|
||||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
|
||||||
std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
|
||||||
std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
|
|
||||||
std::list<int>::iterator i1 = c1.begin();
|
|
||||||
std::list<int>::iterator i2 = c2.begin();
|
|
||||||
swap(c1, c2);
|
|
||||||
c1.erase(i2);
|
|
||||||
c2.erase(i1);
|
|
||||||
std::list<int>::iterator j = i1;
|
|
||||||
c1.erase(i1); // called with iterator not refering to list.
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <list>
|
|
||||||
|
|
||||||
// template <class T, class Alloc>
|
|
||||||
// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
|
|
||||||
|
|
||||||
|
|
||||||
#define _LIBCPP_DEBUG 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <list>
|
|
||||||
#include <cassert>
|
|
||||||
#include "test_allocator.h"
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
// allocators do not compare equal
|
|
||||||
{
|
|
||||||
int a1[] = {1, 3, 7, 9, 10};
|
|
||||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
|
||||||
typedef test_allocator<int> A;
|
|
||||||
std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
|
|
||||||
std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
|
|
||||||
swap(c1, c2);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||||
|
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
|
||||||
|
|
||||||
|
// test container debugging
|
||||||
|
|
||||||
|
#define _LIBCPP_DEBUG 1
|
||||||
|
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <utility>
|
||||||
|
#include <cassert>
|
||||||
|
#include "debug_mode_helper.h"
|
||||||
|
|
||||||
|
using namespace IteratorDebugChecks;
|
||||||
|
|
||||||
|
template <class Container, ContainerType CT>
|
||||||
|
struct AssociativeContainerChecks : BasicContainerChecks<Container, CT> {
|
||||||
|
using Base = BasicContainerChecks<Container, CT>;
|
||||||
|
using value_type = typename Container::value_type;
|
||||||
|
using iterator = typename Container::iterator;
|
||||||
|
using const_iterator = typename Container::const_iterator;
|
||||||
|
using traits = std::iterator_traits<iterator>;
|
||||||
|
using category = typename traits::iterator_category;
|
||||||
|
|
||||||
|
using Base::makeContainer;
|
||||||
|
public:
|
||||||
|
static void run() {
|
||||||
|
Base::run();
|
||||||
|
try {
|
||||||
|
// FIXME Add tests
|
||||||
|
} catch (...) {
|
||||||
|
assert(false && "uncaught debug exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// FIXME Add tests here
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using SetAlloc = test_allocator<int>;
|
||||||
|
using MapAlloc = test_allocator<std::pair<const int, int>>;
|
||||||
|
// FIXME: Add debug mode to these containers
|
||||||
|
if ((false)) {
|
||||||
|
AssociativeContainerChecks<
|
||||||
|
std::set<int, std::less<int>, SetAlloc>, CT_Set>::run();
|
||||||
|
AssociativeContainerChecks<
|
||||||
|
std::multiset<int, std::less<int>, SetAlloc>, CT_MultiSet>::run();
|
||||||
|
AssociativeContainerChecks<
|
||||||
|
std::map<int, int, std::less<int>, MapAlloc>, CT_Map>::run();
|
||||||
|
AssociativeContainerChecks<
|
||||||
|
std::multimap<int, int, std::less<int>, MapAlloc>, CT_MultiMap>::run();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,265 @@
|
|||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||||
|
// Source Licenses. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// UNSUPPORTED: c++98, c++03, c++11, c++14
|
||||||
|
// UNSUPPORTED: libcpp-no-exceptions, libcpp-no-if-constexpr
|
||||||
|
|
||||||
|
// test container debugging
|
||||||
|
|
||||||
|
#define _LIBCPP_DEBUG 1
|
||||||
|
#define _LIBCPP_DEBUG_USE_EXCEPTIONS
|
||||||
|
#include <forward_list>
|
||||||
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
#include <deque>
|
||||||
|
#include "debug_mode_helper.h"
|
||||||
|
|
||||||
|
using namespace IteratorDebugChecks;
|
||||||
|
|
||||||
|
template <class Container, ContainerType CT>
|
||||||
|
struct SequenceContainerChecks : BasicContainerChecks<Container, CT> {
|
||||||
|
using Base = BasicContainerChecks<Container, CT>;
|
||||||
|
using value_type = typename Container::value_type;
|
||||||
|
using allocator_type = typename Container::allocator_type;
|
||||||
|
using iterator = typename Container::iterator;
|
||||||
|
using const_iterator = typename Container::const_iterator;
|
||||||
|
|
||||||
|
using Base::makeContainer;
|
||||||
|
using Base::makeValueType;
|
||||||
|
public:
|
||||||
|
static void run() {
|
||||||
|
Base::run();
|
||||||
|
try {
|
||||||
|
FrontOnEmptyContainer();
|
||||||
|
if constexpr (CT != CT_ForwardList) {
|
||||||
|
AssignInvalidates();
|
||||||
|
BackOnEmptyContainer();
|
||||||
|
InsertIterValue();
|
||||||
|
InsertIterSizeValue();
|
||||||
|
InsertIterIterIter();
|
||||||
|
EmplaceIterValue();
|
||||||
|
EraseIterIter();
|
||||||
|
}
|
||||||
|
if constexpr (CT == CT_Vector || CT == CT_Deque || CT == CT_List) {
|
||||||
|
PopBack();
|
||||||
|
}
|
||||||
|
if constexpr (CT == CT_List || CT == CT_Deque) {
|
||||||
|
PopFront(); // FIXME: Run with forward list as well
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
assert(false && "uncaught debug exception");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void AssignInvalidates() {
|
||||||
|
CHECKPOINT("assign(Size, Value)");
|
||||||
|
Container C(allocator_type{});
|
||||||
|
iterator it1, it2, it3;
|
||||||
|
auto reset = [&]() {
|
||||||
|
C = makeContainer(3);
|
||||||
|
it1 = C.begin();
|
||||||
|
it2 = ++C.begin();
|
||||||
|
it3 = C.end();
|
||||||
|
};
|
||||||
|
auto check = [&]() {
|
||||||
|
CHECK_DEBUG_THROWS( C.erase(it1) );
|
||||||
|
CHECK_DEBUG_THROWS( C.erase(it2) );
|
||||||
|
CHECK_DEBUG_THROWS( C.erase(it3, C.end()) );
|
||||||
|
};
|
||||||
|
reset();
|
||||||
|
C.assign(2, makeValueType(4));
|
||||||
|
check();
|
||||||
|
reset();
|
||||||
|
CHECKPOINT("assign(Iter, Iter)");
|
||||||
|
std::vector<value_type> V = {
|
||||||
|
makeValueType(1),
|
||||||
|
makeValueType(2),
|
||||||
|
makeValueType(3)
|
||||||
|
};
|
||||||
|
C.assign(V.begin(), V.end());
|
||||||
|
check();
|
||||||
|
reset();
|
||||||
|
CHECKPOINT("assign(initializer_list)");
|
||||||
|
C.assign({makeValueType(1), makeValueType(2), makeValueType(3)});
|
||||||
|
check();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void BackOnEmptyContainer() {
|
||||||
|
CHECKPOINT("testing back on empty");
|
||||||
|
Container C = makeContainer(1);
|
||||||
|
Container const& CC = C;
|
||||||
|
(void)C.back();
|
||||||
|
(void)CC.back();
|
||||||
|
C.clear();
|
||||||
|
CHECK_DEBUG_THROWS( C.back() );
|
||||||
|
CHECK_DEBUG_THROWS( CC.back() );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void FrontOnEmptyContainer() {
|
||||||
|
CHECKPOINT("testing front on empty");
|
||||||
|
Container C = makeContainer(1);
|
||||||
|
Container const& CC = C;
|
||||||
|
(void)C.front();
|
||||||
|
(void)CC.front();
|
||||||
|
C.clear();
|
||||||
|
CHECK_DEBUG_THROWS( C.front() );
|
||||||
|
CHECK_DEBUG_THROWS( CC.front() );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EraseIterIter() {
|
||||||
|
CHECKPOINT("testing erase iter iter invalidation");
|
||||||
|
Container C1 = makeContainer(3);
|
||||||
|
iterator it1 = C1.begin();
|
||||||
|
iterator it1_next = ++C1.begin();
|
||||||
|
iterator it1_after_next = ++C1.begin();
|
||||||
|
++it1_after_next;
|
||||||
|
iterator it1_back = --C1.end();
|
||||||
|
assert(it1_next != it1_back);
|
||||||
|
if (CT == CT_Vector) {
|
||||||
|
CHECK_DEBUG_THROWS( C1.erase(it1_next, it1) ); // bad range
|
||||||
|
}
|
||||||
|
C1.erase(it1, it1_after_next);
|
||||||
|
CHECK_DEBUG_THROWS( C1.erase(it1) );
|
||||||
|
CHECK_DEBUG_THROWS( C1.erase(it1_next) );
|
||||||
|
if (CT == CT_List) {
|
||||||
|
C1.erase(it1_back);
|
||||||
|
} else {
|
||||||
|
CHECK_DEBUG_THROWS( C1.erase(it1_back) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PopBack() {
|
||||||
|
CHECKPOINT("testing pop_back() invalidation");
|
||||||
|
Container C1 = makeContainer(2);
|
||||||
|
iterator it1 = C1.end();
|
||||||
|
--it1;
|
||||||
|
C1.pop_back();
|
||||||
|
CHECK_DEBUG_THROWS( C1.erase(it1) );
|
||||||
|
C1.erase(C1.begin());
|
||||||
|
assert(C1.size() == 0);
|
||||||
|
CHECK_DEBUG_THROWS( C1.pop_back() );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PopFront() {
|
||||||
|
CHECKPOINT("testing pop_front() invalidation");
|
||||||
|
Container C1 = makeContainer(2);
|
||||||
|
iterator it1 = C1.begin();
|
||||||
|
C1.pop_front();
|
||||||
|
CHECK_DEBUG_THROWS( C1.erase(it1) );
|
||||||
|
C1.erase(C1.begin());
|
||||||
|
assert(C1.size() == 0);
|
||||||
|
CHECK_DEBUG_THROWS( C1.pop_front() );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InsertIterValue() {
|
||||||
|
CHECKPOINT("testing insert(iter, value)");
|
||||||
|
Container C1 = makeContainer(2);
|
||||||
|
iterator it1 = C1.begin();
|
||||||
|
iterator it1_next = it1;
|
||||||
|
++it1_next;
|
||||||
|
Container C2 = C1;
|
||||||
|
const value_type value = makeValueType(3);
|
||||||
|
value_type rvalue = makeValueType(3);
|
||||||
|
CHECK_DEBUG_THROWS( C2.insert(it1, value) ); // wrong container
|
||||||
|
CHECK_DEBUG_THROWS( C2.insert(it1, std::move(rvalue)) ); // wrong container
|
||||||
|
C1.insert(it1_next, value);
|
||||||
|
if (CT == CT_List) {
|
||||||
|
C1.insert(it1_next, value);
|
||||||
|
C1.insert(it1, value);
|
||||||
|
C1.insert(it1_next, std::move(rvalue));
|
||||||
|
C1.insert(it1, std::move(rvalue));
|
||||||
|
} else {
|
||||||
|
CHECK_DEBUG_THROWS( C1.insert(it1_next, value) ); // invalidated iterator
|
||||||
|
CHECK_DEBUG_THROWS( C1.insert(it1, value) ); // invalidated iterator
|
||||||
|
CHECK_DEBUG_THROWS( C1.insert(it1_next, std::move(rvalue)) ); // invalidated iterator
|
||||||
|
CHECK_DEBUG_THROWS( C1.insert(it1, std::move(rvalue)) ); // invalidated iterator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void EmplaceIterValue() {
|
||||||
|
CHECKPOINT("testing emplace(iter, value)");
|
||||||
|
Container C1 = makeContainer(2);
|
||||||
|
iterator it1 = C1.begin();
|
||||||
|
iterator it1_next = it1;
|
||||||
|
++it1_next;
|
||||||
|
Container C2 = C1;
|
||||||
|
const value_type value = makeValueType(3);
|
||||||
|
CHECK_DEBUG_THROWS( C2.emplace(it1, value) ); // wrong container
|
||||||
|
CHECK_DEBUG_THROWS( C2.emplace(it1, makeValueType(4)) ); // wrong container
|
||||||
|
C1.emplace(it1_next, value);
|
||||||
|
if (CT == CT_List) {
|
||||||
|
C1.emplace(it1_next, value);
|
||||||
|
C1.emplace(it1, value);
|
||||||
|
} else {
|
||||||
|
CHECK_DEBUG_THROWS( C1.emplace(it1_next, value) ); // invalidated iterator
|
||||||
|
CHECK_DEBUG_THROWS( C1.emplace(it1, value) ); // invalidated iterator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InsertIterSizeValue() {
|
||||||
|
CHECKPOINT("testing insert(iter, size, value)");
|
||||||
|
Container C1 = makeContainer(2);
|
||||||
|
iterator it1 = C1.begin();
|
||||||
|
iterator it1_next = it1;
|
||||||
|
++it1_next;
|
||||||
|
Container C2 = C1;
|
||||||
|
const value_type value = makeValueType(3);
|
||||||
|
CHECK_DEBUG_THROWS( C2.insert(it1, 1, value) ); // wrong container
|
||||||
|
C1.insert(it1_next, 2, value);
|
||||||
|
if (CT == CT_List) {
|
||||||
|
C1.insert(it1_next, 3, value);
|
||||||
|
C1.insert(it1, 1, value);
|
||||||
|
} else {
|
||||||
|
CHECK_DEBUG_THROWS( C1.insert(it1_next, 1, value) ); // invalidated iterator
|
||||||
|
CHECK_DEBUG_THROWS( C1.insert(it1, 1, value) ); // invalidated iterator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void InsertIterIterIter() {
|
||||||
|
CHECKPOINT("testing insert(iter, iter, iter)");
|
||||||
|
Container C1 = makeContainer(2);
|
||||||
|
iterator it1 = C1.begin();
|
||||||
|
iterator it1_next = it1;
|
||||||
|
++it1_next;
|
||||||
|
Container C2 = C1;
|
||||||
|
std::vector<value_type> V = {
|
||||||
|
makeValueType(1),
|
||||||
|
makeValueType(2),
|
||||||
|
makeValueType(3)
|
||||||
|
};
|
||||||
|
CHECK_DEBUG_THROWS( C2.insert(it1, V.begin(), V.end()) ); // wrong container
|
||||||
|
C1.insert(it1_next, V.begin(), V.end());
|
||||||
|
if (CT == CT_List) {
|
||||||
|
C1.insert(it1_next, V.begin(), V.end());
|
||||||
|
C1.insert(it1, V.begin(), V.end());
|
||||||
|
} else {
|
||||||
|
CHECK_DEBUG_THROWS( C1.insert(it1_next, V.begin(), V.end()) ); // invalidated iterator
|
||||||
|
CHECK_DEBUG_THROWS( C1.insert(it1, V.begin(), V.end()) ); // invalidated iterator
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
using Alloc = test_allocator<int>;
|
||||||
|
{
|
||||||
|
SequenceContainerChecks<std::list<int, Alloc>, CT_List>::run();
|
||||||
|
SequenceContainerChecks<std::vector<int, Alloc>, CT_Vector>::run();
|
||||||
|
}
|
||||||
|
// FIXME these containers don't support iterator debugging
|
||||||
|
if ((false)) {
|
||||||
|
SequenceContainerChecks<
|
||||||
|
std::vector<bool, test_allocator<bool>>, CT_VectorBool>::run();
|
||||||
|
SequenceContainerChecks<
|
||||||
|
std::forward_list<int, Alloc>, CT_ForwardList>::run();
|
||||||
|
SequenceContainerChecks<
|
||||||
|
std::deque<int, Alloc>, CT_Deque>::run();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,22 +7,20 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// UNSUPPORTED: c++98, c++03
|
||||||
|
|
||||||
// <vector>
|
// <vector>
|
||||||
|
|
||||||
// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
|
// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
#include "asan_testing.h"
|
#include "asan_testing.h"
|
||||||
|
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
class A
|
class A
|
||||||
{
|
{
|
||||||
int i_;
|
int i_;
|
||||||
@@ -55,11 +53,8 @@ public:
|
|||||||
double getd() const {return d_;}
|
double getd() const {return d_;}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
{
|
{
|
||||||
std::vector<A> c;
|
std::vector<A> c;
|
||||||
std::vector<A>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
|
std::vector<A>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
|
||||||
@@ -114,15 +109,6 @@ int main()
|
|||||||
assert(c.back().getd() == 4.5);
|
assert(c.back().getd() == 4.5);
|
||||||
assert(is_contiguous_container_asan_correct(c));
|
assert(is_contiguous_container_asan_correct(c));
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<A> c1;
|
|
||||||
std::vector<A> c2;
|
|
||||||
std::vector<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
{
|
||||||
std::vector<A, min_allocator<A>> c;
|
std::vector<A, min_allocator<A>> c;
|
||||||
std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
|
std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
|
||||||
@@ -147,14 +133,4 @@ int main()
|
|||||||
assert(c.back().geti() == 3);
|
assert(c.back().geti() == 3);
|
||||||
assert(c.back().getd() == 4.5);
|
assert(c.back().getd() == 4.5);
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<A, min_allocator<A>> c1;
|
|
||||||
std::vector<A, min_allocator<A>> c2;
|
|
||||||
std::vector<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call erase(const_iterator position) with end()
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int> l1(a1, a1+3);
|
|
||||||
std::vector<int>::const_iterator i = l1.end();
|
|
||||||
l1.erase(i);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>>::const_iterator i = l1.end();
|
|
||||||
l1.erase(i);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call erase(const_iterator position) with iterator from another container
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int> l1(a1, a1+3);
|
|
||||||
std::vector<int> l2(a1, a1+3);
|
|
||||||
std::vector<int>::const_iterator i = l2.begin();
|
|
||||||
l1.erase(i);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>> l2(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>>::const_iterator i = l2.begin();
|
|
||||||
l1.erase(i);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call erase(const_iterator first, const_iterator last); with first iterator from another container
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int> l1(a1, a1+3);
|
|
||||||
std::vector<int> l2(a1, a1+3);
|
|
||||||
std::vector<int>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>> l2(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call erase(const_iterator first, const_iterator last); with second iterator from another container
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int> l1(a1, a1+3);
|
|
||||||
std::vector<int> l2(a1, a1+3);
|
|
||||||
std::vector<int>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>> l2(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call erase(const_iterator first, const_iterator last); with both iterators from another container
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int> l1(a1, a1+3);
|
|
||||||
std::vector<int> l2(a1, a1+3);
|
|
||||||
std::vector<int>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>> l2(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// Call erase(const_iterator first, const_iterator last); with a bad range
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
#include <exception>
|
|
||||||
#include <cstdlib>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int> l1(a1, a1+3);
|
|
||||||
std::vector<int>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
|
||||||
int a1[] = {1, 2, 3};
|
|
||||||
std::vector<int, min_allocator<int>> l1(a1, a1+3);
|
|
||||||
std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -12,13 +12,10 @@
|
|||||||
// template <class Iter>
|
// template <class Iter>
|
||||||
// iterator insert(const_iterator position, Iter first, Iter last);
|
// iterator insert(const_iterator position, Iter first, Iter last);
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#include "test_macros.h"
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "test_iterators.h"
|
#include "test_iterators.h"
|
||||||
@@ -131,17 +128,6 @@ int main()
|
|||||||
for (; j < 105; ++j)
|
for (; j < 105; ++j)
|
||||||
assert(v[j] == 0);
|
assert(v[j] == 0);
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<int> v(100);
|
|
||||||
std::vector<int> v2(100);
|
|
||||||
int a[] = {1, 2, 3, 4, 5};
|
|
||||||
const int N = sizeof(a)/sizeof(a[0]);
|
|
||||||
std::vector<int>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
|
|
||||||
input_iterator<const int*>(a+N));
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if TEST_STD_VER >= 11
|
#if TEST_STD_VER >= 11
|
||||||
{
|
{
|
||||||
std::vector<int, min_allocator<int>> v(100);
|
std::vector<int, min_allocator<int>> v(100);
|
||||||
@@ -177,16 +163,5 @@ int main()
|
|||||||
for (; j < 105; ++j)
|
for (; j < 105; ++j)
|
||||||
assert(v[j] == 0);
|
assert(v[j] == 0);
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<int, min_allocator<int>> v(100);
|
|
||||||
std::vector<int, min_allocator<int>> v2(100);
|
|
||||||
int a[] = {1, 2, 3, 4, 5};
|
|
||||||
const int N = sizeof(a)/sizeof(a[0]);
|
|
||||||
std::vector<int, min_allocator<int>>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
|
|
||||||
input_iterator<const int*>(a+N));
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,16 +7,16 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// UNSUPPORTED: c++98, c++03
|
||||||
|
|
||||||
// <vector>
|
// <vector>
|
||||||
|
|
||||||
// iterator insert(const_iterator position, value_type&& x);
|
// iterator insert(const_iterator position, value_type&& x);
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "MoveOnly.h"
|
#include "MoveOnly.h"
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
@@ -24,7 +24,6 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
{
|
{
|
||||||
std::vector<MoveOnly> v(100);
|
std::vector<MoveOnly> v(100);
|
||||||
std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
|
std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
|
||||||
@@ -51,15 +50,6 @@ int main()
|
|||||||
for (++j; j < 101; ++j)
|
for (++j; j < 101; ++j)
|
||||||
assert(v[j] == MoveOnly());
|
assert(v[j] == MoveOnly());
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<int> v1(3);
|
|
||||||
std::vector<int> v2(3);
|
|
||||||
v1.insert(v2.begin(), 4);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
{
|
||||||
std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
|
std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
|
||||||
std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
|
std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
|
||||||
@@ -73,14 +63,4 @@ int main()
|
|||||||
for (++j; j < 101; ++j)
|
for (++j; j < 101; ++j)
|
||||||
assert(v[j] == MoveOnly());
|
assert(v[j] == MoveOnly());
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<int, min_allocator<int>> v1(3);
|
|
||||||
std::vector<int, min_allocator<int>> v2(3);
|
|
||||||
v1.insert(v2.begin(), 4);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,11 @@
|
|||||||
|
|
||||||
// iterator insert(const_iterator position, size_type n, const value_type& x);
|
// iterator insert(const_iterator position, size_type n, const value_type& x);
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
#include "asan_testing.h"
|
#include "asan_testing.h"
|
||||||
@@ -84,14 +82,6 @@ int main()
|
|||||||
for (++j; j < 105; ++j)
|
for (++j; j < 105; ++j)
|
||||||
assert(v[j] == 0);
|
assert(v[j] == 0);
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<int> c1(100);
|
|
||||||
std::vector<int> c2;
|
|
||||||
std::vector<int>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if TEST_STD_VER >= 11
|
#if TEST_STD_VER >= 11
|
||||||
{
|
{
|
||||||
std::vector<int, min_allocator<int>> v(100);
|
std::vector<int, min_allocator<int>> v(100);
|
||||||
@@ -121,13 +111,5 @@ int main()
|
|||||||
for (++j; j < 105; ++j)
|
for (++j; j < 105; ++j)
|
||||||
assert(v[j] == 0);
|
assert(v[j] == 0);
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<int, min_allocator<int>> c1(100);
|
|
||||||
std::vector<int, min_allocator<int>> c2;
|
|
||||||
std::vector<int, min_allocator<int>>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,13 +11,11 @@
|
|||||||
|
|
||||||
// iterator insert(const_iterator position, const value_type& x);
|
// iterator insert(const_iterator position, const value_type& x);
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
#include "asan_testing.h"
|
#include "asan_testing.h"
|
||||||
@@ -81,15 +79,6 @@ int main()
|
|||||||
for (++j; j < 101; ++j)
|
for (++j; j < 101; ++j)
|
||||||
assert(v[j] == 0);
|
assert(v[j] == 0);
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<int> v1(3);
|
|
||||||
std::vector<int> v2(3);
|
|
||||||
int i = 4;
|
|
||||||
v1.insert(v2.begin(), i);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if TEST_STD_VER >= 11
|
#if TEST_STD_VER >= 11
|
||||||
{
|
{
|
||||||
std::vector<int, min_allocator<int>> v(100);
|
std::vector<int, min_allocator<int>> v(100);
|
||||||
@@ -104,14 +93,5 @@ int main()
|
|||||||
for (++j; j < 101; ++j)
|
for (++j; j < 101; ++j)
|
||||||
assert(v[j] == 0);
|
assert(v[j] == 0);
|
||||||
}
|
}
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
std::vector<int, min_allocator<int>> v1(3);
|
|
||||||
std::vector<int, min_allocator<int>> v2(3);
|
|
||||||
int i = 4;
|
|
||||||
v1.insert(v2.begin(), i);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,20 +11,13 @@
|
|||||||
|
|
||||||
// void pop_back();
|
// void pop_back();
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
#include "test_allocator.h"
|
#include "test_allocator.h"
|
||||||
#include "min_allocator.h"
|
#include "min_allocator.h"
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <exception>
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@@ -34,10 +27,7 @@ int main()
|
|||||||
assert(c.size() == 1);
|
assert(c.size() == 1);
|
||||||
c.pop_back();
|
c.pop_back();
|
||||||
assert(c.size() == 0);
|
assert(c.size() == 0);
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
c.pop_back();
|
|
||||||
assert(false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#if TEST_STD_VER >= 11
|
#if TEST_STD_VER >= 11
|
||||||
{
|
{
|
||||||
@@ -46,10 +36,6 @@ int main()
|
|||||||
assert(c.size() == 1);
|
assert(c.size() == 1);
|
||||||
c.pop_back();
|
c.pop_back();
|
||||||
assert(c.size() == 0);
|
assert(c.size() == 0);
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
c.pop_back();
|
|
||||||
assert(false);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
||||||
// Source Licenses. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// <vector>
|
|
||||||
|
|
||||||
// template <class T, class Alloc>
|
|
||||||
// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
|
|
||||||
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <cassert>
|
|
||||||
|
|
||||||
#include "min_allocator.h"
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
#if _LIBCPP_DEBUG >= 1
|
|
||||||
{
|
|
||||||
int a1[] = {1, 3, 7, 9, 10};
|
|
||||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
|
||||||
std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
|
||||||
std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
|
|
||||||
std::vector<int>::iterator i1 = c1.begin();
|
|
||||||
std::vector<int>::iterator i2 = c2.begin();
|
|
||||||
swap(c1, c2);
|
|
||||||
c1.erase(i2);
|
|
||||||
c2.erase(i1);
|
|
||||||
c1.erase(i1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#if TEST_STD_VER >= 11
|
|
||||||
{
|
|
||||||
int a1[] = {1, 3, 7, 9, 10};
|
|
||||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
|
||||||
std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
|
|
||||||
std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
|
|
||||||
std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
|
|
||||||
std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
|
|
||||||
swap(c1, c2);
|
|
||||||
c1.erase(i2);
|
|
||||||
c2.erase(i1);
|
|
||||||
c1.erase(i1);
|
|
||||||
assert(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -162,8 +162,6 @@ int main()
|
|||||||
assert(is_contiguous_container_asan_correct(c1));
|
assert(is_contiguous_container_asan_correct(c1));
|
||||||
assert(is_contiguous_container_asan_correct(c2));
|
assert(is_contiguous_container_asan_correct(c2));
|
||||||
}
|
}
|
||||||
#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 a1[] = {1, 3, 7, 9, 10};
|
||||||
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
int a2[] = {0, 2, 4, 5, 6, 8, 11};
|
||||||
@@ -181,5 +179,4 @@ int main()
|
|||||||
assert(is_contiguous_container_asan_correct(c2));
|
assert(is_contiguous_container_asan_correct(c2));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user