diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -107,6 +107,8 @@ # define _LIBCPP_ABI_ENABLE_UNIQUE_PTR_TRIVIAL_ABI // Enable clang::trivial_abi on std::shared_ptr and std::weak_ptr # define _LIBCPP_ABI_ENABLE_SHARED_PTR_TRIVIAL_ABI +// Remove vector base class +# define _LIBCPP_ABI_NO_VECTOR_BASE_COMMON #elif _LIBCPP_ABI_VERSION == 1 # if !defined(_LIBCPP_OBJECT_FORMAT_COFF) // Enable compiling copies of now inline methods into the dylib to support diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -302,55 +302,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template -struct __vector_base_common; - -template <> -struct __vector_base_common { - // Both are defined in vector.cpp - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const; - _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const; -}; - -template -class __vector_base - : protected __vector_base_common // This base class is historical, but it needs to remain for ABI compatibility -{ - typedef _Allocator allocator_type; - typedef typename allocator_traits::pointer pointer; - -protected: - pointer __begin_; - pointer __end_; - __compressed_pair __end_cap_; - - _LIBCPP_INLINE_VISIBILITY - __vector_base() - _NOEXCEPT_(is_nothrow_default_constructible::value) - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, __default_init_tag()) {} - - _LIBCPP_INLINE_VISIBILITY __vector_base(const allocator_type& __a) - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, __a) {} - -#ifndef _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY __vector_base(allocator_type&& __a) _NOEXCEPT - : __begin_(nullptr), - __end_(nullptr), - __end_cap_(nullptr, _VSTD::move(__a)) {} -#endif -}; - template */> class _LIBCPP_TEMPLATE_VIS vector - // This base class is historical, but it needs to remain for ABI compatibility. - : private __vector_base<_Tp, _Allocator> { private: - typedef __vector_base<_Tp, _Allocator> __base; typedef allocator<_Tp> __default_allocator_type; public: typedef vector __self; @@ -382,7 +337,7 @@ #else _NOEXCEPT #endif - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); } @@ -394,7 +349,7 @@ template ::value> > vector(size_type __n, const value_type& __x, const allocator_type& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); if (__n > 0) @@ -691,6 +646,11 @@ #endif // _LIBCPP_DEBUG_LEVEL == 2 private: + pointer __begin_ = nullptr; + pointer __end_ = nullptr; + __compressed_pair __end_cap_ = + __compressed_pair(nullptr, allocator_type()); + _LIBCPP_INLINE_VISIBILITY void __invalidate_all_iterators(); _LIBCPP_INLINE_VISIBILITY void __invalidate_iterators_past(pointer __new_last); void __vallocate(size_type __n); @@ -859,20 +819,12 @@ _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_length_error() const { -#ifndef _LIBCPP_NO_EXCEPTIONS - __vector_base_common::__throw_length_error(); -#else - _VSTD::abort(); -#endif + _VSTD::__throw_length_error("vector"); } _LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { -#ifndef _LIBCPP_NO_EXCEPTIONS - __vector_base_common::__throw_out_of_range(); -#else - _VSTD::abort(); -#endif + _VSTD::__throw_out_of_range("vector"); } _LIBCPP_INLINE_VISIBILITY @@ -1106,7 +1058,7 @@ #if _LIBCPP_STD_VER > 11 template vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); if (__n > 0) @@ -1151,7 +1103,7 @@ is_constructible< value_type, typename iterator_traits<_InputIterator>::reference>::value>::type*) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); for (; __first != __last; ++__first) @@ -1183,7 +1135,7 @@ is_constructible< value_type, typename iterator_traits<_ForwardIterator>::reference>::value>::type*) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); size_type __n = static_cast(_VSTD::distance(__first, __last)); @@ -1196,7 +1148,7 @@ template vector<_Tp, _Allocator>::vector(const vector& __x) - : __base(__alloc_traits::select_on_container_copy_construction(__x.__alloc())) + : __end_cap_(nullptr, __alloc_traits::select_on_container_copy_construction(__x.__alloc())) { _VSTD::__debug_db_insert_c(this); size_type __n = __x.size(); @@ -1209,7 +1161,7 @@ template vector<_Tp, _Allocator>::vector(const vector& __x, const __identity_t& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); size_type __n = __x.size(); @@ -1230,7 +1182,7 @@ #else _NOEXCEPT_(is_nothrow_move_constructible::value) #endif - : __base(_VSTD::move(__x.__alloc())) + : __end_cap_(nullptr, _VSTD::move(__x.__alloc())) { _VSTD::__debug_db_insert_c(this); #if _LIBCPP_DEBUG_LEVEL == 2 @@ -1245,7 +1197,7 @@ template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x, const __identity_t& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); if (__a == __x.__alloc()) @@ -1280,7 +1232,7 @@ template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list __il, const allocator_type& __a) - : __base(__a) + : __end_cap_(nullptr, __a) { _VSTD::__debug_db_insert_c(this); if (__il.size() > 0) diff --git a/libcxx/src/vector.cpp b/libcxx/src/vector.cpp --- a/libcxx/src/vector.cpp +++ b/libcxx/src/vector.cpp @@ -10,12 +10,22 @@ _LIBCPP_BEGIN_NAMESPACE_STD -void __vector_base_common::__throw_length_error() const { - _VSTD::__throw_length_error("vector"); -} +#ifndef _LIBCPP_ABI_NO_VECTOR_BASE_COMMON + +template +struct __vector_base_common; -void __vector_base_common::__throw_out_of_range() const { +template <> +struct __vector_base_common { + // Both are defined in vector.cpp + _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const { + _VSTD::__throw_length_error("vector"); + } + _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const { _VSTD::__throw_out_of_range("vector"); -} + } +}; + +#endif // _LIBCPP_ABI_NO_VECTOR_BASE_COMMON _LIBCPP_END_NAMESPACE_STD