diff options
author | Eric Christopher <echristo@gmail.com> | 2018-10-25 06:20:12 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2018-10-25 06:20:12 +0000 |
commit | 9bbee38db3b12c47a898e2723b69342355cdfe4f (patch) | |
tree | b5b93821f494c8d150aa4ff590b34ea9de1cee24 /libcxx/include/valarray | |
parent | 199325450932a06d4392cb4d87fd69fc163b00eb (diff) | |
download | bcm5719-llvm-9bbee38db3b12c47a898e2723b69342355cdfe4f.tar.gz bcm5719-llvm-9bbee38db3b12c47a898e2723b69342355cdfe4f.zip |
Temporarily Revert "Implement sized deallocation for std::allocator and friends."
This is breaking the bots here (and related): http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/builds/1428
This reverts commit r345214.
llvm-svn: 345239
Diffstat (limited to 'libcxx/include/valarray')
-rw-r--r-- | libcxx/include/valarray | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/libcxx/include/valarray b/libcxx/include/valarray index 027436dce9b..a941e3ec441 100644 --- a/libcxx/include/valarray +++ b/libcxx/include/valarray @@ -1054,7 +1054,7 @@ private: const _Up* end(const valarray<_Up>& __v); - void __clear(size_t __capacity); + void __clear(); valarray& __assign_range(const value_type* __f, const value_type* __l); }; @@ -2762,13 +2762,13 @@ valarray<_Tp>::valarray(size_t __n) try { #endif // _LIBCPP_NO_EXCEPTIONS - for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) + for (; __n; --__n, ++__end_) ::new (__end_) value_type(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { - __clear(__n); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2797,13 +2797,13 @@ valarray<_Tp>::valarray(const value_type* __p, size_t __n) try { #endif // _LIBCPP_NO_EXCEPTIONS - for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) + for (; __n; ++__end_, ++__p, --__n) ::new (__end_) value_type(*__p); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { - __clear(__n); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2829,7 +2829,7 @@ valarray<_Tp>::valarray(const valarray& __v) } catch (...) { - __clear(__v.size()); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2852,7 +2852,7 @@ valarray<_Tp>::valarray(initializer_list<value_type> __il) : __begin_(0), __end_(0) { - const size_t __n = __il.size(); + size_t __n = __il.size(); if (__n) { __begin_ = __end_ = static_cast<value_type*>( @@ -2861,14 +2861,13 @@ _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type))); try { #endif // _LIBCPP_NO_EXCEPTIONS - size_t __n_left = __n; - for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) + for (const value_type* __p = __il.begin(); __n; ++__end_, ++__p, --__n) ::new (__end_) value_type(*__p); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { - __clear(__n); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2882,7 +2881,7 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa) : __begin_(0), __end_(0) { - const size_t __n = __sa.__size_; + size_t __n = __sa.__size_; if (__n) { __begin_ = __end_ = static_cast<value_type*>( @@ -2891,14 +2890,13 @@ valarray<_Tp>::valarray(const slice_array<value_type>& __sa) try { #endif // _LIBCPP_NO_EXCEPTIONS - size_t __n_left = __n; - for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) + for (const value_type* __p = __sa.__vp_; __n; ++__end_, __p += __sa.__stride_, --__n) ::new (__end_) value_type(*__p); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { - __clear(__n); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2910,7 +2908,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) : __begin_(0), __end_(0) { - const size_t __n = __ga.__1d_.size(); + size_t __n = __ga.__1d_.size(); if (__n) { __begin_ = __end_ = static_cast<value_type*>( @@ -2928,7 +2926,7 @@ valarray<_Tp>::valarray(const gslice_array<value_type>& __ga) } catch (...) { - __clear(__n); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2940,7 +2938,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma) : __begin_(0), __end_(0) { - const size_t __n = __ma.__1d_.size(); + size_t __n = __ma.__1d_.size(); if (__n) { __begin_ = __end_ = static_cast<value_type*>( @@ -2958,7 +2956,7 @@ valarray<_Tp>::valarray(const mask_array<value_type>& __ma) } catch (...) { - __clear(__n); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2970,7 +2968,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) : __begin_(0), __end_(0) { - const size_t __n = __ia.__1d_.size(); + size_t __n = __ia.__1d_.size(); if (__n) { __begin_ = __end_ = static_cast<value_type*>( @@ -2988,7 +2986,7 @@ valarray<_Tp>::valarray(const indirect_array<value_type>& __ia) } catch (...) { - __clear(__n); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS @@ -2999,7 +2997,7 @@ template <class _Tp> inline valarray<_Tp>::~valarray() { - __clear(size()); + __clear(); } template <class _Tp> @@ -3009,7 +3007,7 @@ valarray<_Tp>::__assign_range(const value_type* __f, const value_type* __l) size_t __n = __l - __f; if (size() != __n) { - __clear(size()); + __clear(); __begin_ = static_cast<value_type*>( _VSTD::__libcpp_allocate(__n * sizeof(value_type), __alignof(value_type))); __end_ = __begin_ + __n; @@ -3036,7 +3034,7 @@ inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT { - __clear(size()); + __clear(); __begin_ = __v.__begin_; __end_ = __v.__end_; __v.__begin_ = nullptr; @@ -3728,23 +3726,23 @@ valarray<_Tp>::apply(value_type __f(const value_type&)) const } template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY -void valarray<_Tp>::__clear(size_t __capacity) +void +valarray<_Tp>::__clear() { - if (__begin_ != nullptr) - { - while (__end_ != __begin_) - (--__end_)->~value_type(); - _VSTD::__libcpp_deallocate(__begin_, __capacity * sizeof(value_type), __alignof(value_type)); - __begin_ = __end_ = nullptr; - } + if (__begin_ != nullptr) + { + while (__end_ != __begin_) + (--__end_)->~value_type(); + _VSTD::__libcpp_deallocate(__begin_, __alignof(value_type)); + __begin_ = __end_ = nullptr; + } } template <class _Tp> void valarray<_Tp>::resize(size_t __n, value_type __x) { - __clear(size()); + __clear(); if (__n) { __begin_ = __end_ = static_cast<value_type*>( @@ -3753,13 +3751,13 @@ valarray<_Tp>::resize(size_t __n, value_type __x) try { #endif // _LIBCPP_NO_EXCEPTIONS - for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) + for (; __n; --__n, ++__end_) ::new (__end_) value_type(__x); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { - __clear(__n); + __clear(); throw; } #endif // _LIBCPP_NO_EXCEPTIONS |