diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -393,6 +393,7 @@ __memory/allocation_guard.h __memory/allocator.h __memory/allocator_arg_t.h + __memory/allocator_destructor.h __memory/allocator_traits.h __memory/assume_aligned.h __memory/auto_ptr.h diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h --- a/libcxx/include/__functional/function.h +++ b/libcxx/include/__functional/function.h @@ -18,10 +18,10 @@ #include <__iterator/iterator_traits.h> #include <__memory/addressof.h> #include <__memory/allocator.h> +#include <__memory/allocator_destructor.h> #include <__memory/allocator_traits.h> #include <__memory/builtin_new_allocator.h> #include <__memory/compressed_pair.h> -#include <__memory/shared_ptr.h> #include <__memory/unique_ptr.h> #include <__utility/forward.h> #include <__utility/move.h> diff --git a/libcxx/include/__locale b/libcxx/include/__locale --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -12,7 +12,6 @@ #include <__availability> #include <__config> -#include <__memory/shared_ptr.h> #include #include #include diff --git a/libcxx/include/__memory/allocator_destructor.h b/libcxx/include/__memory/allocator_destructor.h new file mode 100644 --- /dev/null +++ b/libcxx/include/__memory/allocator_destructor.h @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___MEMORY_ALLOCATOR_DESTRUCTOR_H +#define _LIBCPP___MEMORY_ALLOCATOR_DESTRUCTOR_H + +#include <__config> +#include <__memory/allocator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class __allocator_destructor +{ + typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits; +public: + typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer; + typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type; +private: + _Alloc& __alloc_; + size_type __s_; +public: + _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) + _NOEXCEPT + : __alloc_(__a), __s_(__s) {} + _LIBCPP_INLINE_VISIBILITY + void operator()(pointer __p) _NOEXCEPT + {__alloc_traits::deallocate(__alloc_, __p, __s_);} +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___MEMORY_ALLOCATOR_DESTRUCTOR_H diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h --- a/libcxx/include/__memory/shared_ptr.h +++ b/libcxx/include/__memory/shared_ptr.h @@ -21,6 +21,7 @@ #include <__memory/addressof.h> #include <__memory/allocation_guard.h> #include <__memory/allocator.h> +#include <__memory/allocator_destructor.h> #include <__memory/allocator_traits.h> #include <__memory/auto_ptr.h> #include <__memory/compressed_pair.h> @@ -42,32 +43,12 @@ # include #endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif _LIBCPP_BEGIN_NAMESPACE_STD -template -class __allocator_destructor -{ - typedef _LIBCPP_NODEBUG allocator_traits<_Alloc> __alloc_traits; -public: - typedef _LIBCPP_NODEBUG typename __alloc_traits::pointer pointer; - typedef _LIBCPP_NODEBUG typename __alloc_traits::size_type size_type; -private: - _Alloc& __alloc_; - size_type __s_; -public: - _LIBCPP_INLINE_VISIBILITY __allocator_destructor(_Alloc& __a, size_type __s) - _NOEXCEPT - : __alloc_(__a), __s_(__s) {} - _LIBCPP_INLINE_VISIBILITY - void operator()(pointer __p) _NOEXCEPT - {__alloc_traits::deallocate(__alloc_, __p, __s_);} -}; - // NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) // should be sufficient for thread safety. // See https://llvm.org/PR22803 diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -22,7 +22,6 @@ #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> #include <__memory/pointer_traits.h> -#include <__memory/shared_ptr.h> #include <__memory/swap_allocator.h> #include <__utility/forward.h> #include <__utility/move.h> diff --git a/libcxx/include/any b/libcxx/include/any --- a/libcxx/include/any +++ b/libcxx/include/any @@ -84,8 +84,8 @@ #include <__availability> #include <__config> #include <__memory/allocator.h> +#include <__memory/allocator_destructor.h> #include <__memory/allocator_traits.h> -#include <__memory/shared_ptr.h> #include <__memory/unique_ptr.h> #include <__utility/forward.h> #include <__utility/in_place.h> @@ -699,6 +699,8 @@ #endif #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include # include # include # include diff --git a/libcxx/include/codecvt b/libcxx/include/codecvt --- a/libcxx/include/codecvt +++ b/libcxx/include/codecvt @@ -553,4 +553,12 @@ _LIBCPP_END_NAMESPACE_STD +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +#endif + #endif // _LIBCPP_CODECVT diff --git a/libcxx/include/deque b/libcxx/include/deque --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -176,6 +176,7 @@ #include <__iterator/next.h> #include <__iterator/prev.h> #include <__iterator/reverse_iterator.h> +#include <__memory/allocator_destructor.h> #include <__memory/pointer_traits.h> #include <__memory/temp_value.h> #include <__memory/unique_ptr.h> @@ -2931,9 +2932,11 @@ _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include # include # include # include +# include #endif #endif // _LIBCPP_DEQUE diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -190,10 +190,10 @@ #include <__iterator/next.h> #include <__memory/addressof.h> #include <__memory/allocator.h> +#include <__memory/allocator_destructor.h> #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> #include <__memory/pointer_traits.h> -#include <__memory/shared_ptr.h> #include <__memory/swap_allocator.h> #include <__memory/unique_ptr.h> #include <__type_traits/is_allocator.h> diff --git a/libcxx/include/future b/libcxx/include/future --- a/libcxx/include/future +++ b/libcxx/include/future @@ -367,6 +367,7 @@ #include <__chrono/time_point.h> #include <__config> #include <__memory/allocator_arg_t.h> +#include <__memory/allocator_destructor.h> #include <__memory/uses_allocator.h> #include <__utility/auto_cast.h> #include <__utility/forward.h> diff --git a/libcxx/include/list b/libcxx/include/list --- a/libcxx/include/list +++ b/libcxx/include/list @@ -196,10 +196,10 @@ #include <__iterator/reverse_iterator.h> #include <__memory/addressof.h> #include <__memory/allocator.h> +#include <__memory/allocator_destructor.h> #include <__memory/allocator_traits.h> #include <__memory/compressed_pair.h> #include <__memory/pointer_traits.h> -#include <__memory/shared_ptr.h> #include <__memory/swap_allocator.h> #include <__memory/unique_ptr.h> #include <__type_traits/is_allocator.h> diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -859,6 +859,7 @@ module allocation_guard { private header "__memory/allocation_guard.h" } module allocator { private header "__memory/allocator.h" } module allocator_arg_t { private header "__memory/allocator_arg_t.h" } + module allocator_destructor { private header "__memory/allocator_destructor.h" } module allocator_traits { private header "__memory/allocator_traits.h" } module assume_aligned { private header "__memory/assume_aligned.h" } module auto_ptr { private header "__memory/auto_ptr.h" } diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -3266,6 +3266,7 @@ _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include # include # include # include diff --git a/libcxx/test/libcxx/private_headers.verify.cpp b/libcxx/test/libcxx/private_headers.verify.cpp --- a/libcxx/test/libcxx/private_headers.verify.cpp +++ b/libcxx/test/libcxx/private_headers.verify.cpp @@ -424,6 +424,7 @@ #include <__memory/allocation_guard.h> // expected-error@*:* {{use of private header from outside its module: '__memory/allocation_guard.h'}} #include <__memory/allocator.h> // expected-error@*:* {{use of private header from outside its module: '__memory/allocator.h'}} #include <__memory/allocator_arg_t.h> // expected-error@*:* {{use of private header from outside its module: '__memory/allocator_arg_t.h'}} +#include <__memory/allocator_destructor.h> // expected-error@*:* {{use of private header from outside its module: '__memory/allocator_destructor.h'}} #include <__memory/allocator_traits.h> // expected-error@*:* {{use of private header from outside its module: '__memory/allocator_traits.h'}} #include <__memory/assume_aligned.h> // expected-error@*:* {{use of private header from outside its module: '__memory/assume_aligned.h'}} #include <__memory/auto_ptr.h> // expected-error@*:* {{use of private header from outside its module: '__memory/auto_ptr.h'}} diff --git a/libcxx/test/libcxx/transitive_includes/cxx2b.csv b/libcxx/test/libcxx/transitive_includes/cxx2b.csv --- a/libcxx/test/libcxx/transitive_includes/cxx2b.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx2b.csv @@ -11,14 +11,11 @@ algorithm new algorithm type_traits algorithm version -any atomic -any concepts any cstddef any cstdint any cstdlib any cstring any initializer_list -any iosfwd any limits any new any stdexcept @@ -108,22 +105,10 @@ cinttypes cstdint cmath type_traits cmath version -codecvt atomic codecvt cctype -codecvt concepts -codecvt cstddef codecvt cstdint -codecvt cstdlib -codecvt cstring -codecvt initializer_list -codecvt iosfwd -codecvt limits codecvt mutex -codecvt new -codecvt stdexcept codecvt string -codecvt type_traits -codecvt typeinfo codecvt version compare cmath compare cstddef @@ -168,7 +153,6 @@ ctgmath cmath cwchar cwctype cwctype cctype -deque atomic deque compare deque concepts deque cstddef @@ -176,12 +160,10 @@ deque cstdlib deque cstring deque initializer_list -deque iosfwd deque limits deque new deque stdexcept deque type_traits -deque typeinfo deque version exception cstddef exception cstdlib @@ -304,7 +286,6 @@ format string_view format type_traits format version -forward_list atomic forward_list compare forward_list concepts forward_list cstddef @@ -312,14 +293,11 @@ forward_list cstdlib forward_list cstring forward_list initializer_list -forward_list iosfwd forward_list limits forward_list new forward_list stdexcept forward_list type_traits -forward_list typeinfo forward_list version -fstream atomic fstream cctype fstream concepts fstream cstddef @@ -329,13 +307,9 @@ fstream cstring fstream filesystem fstream initializer_list -fstream iosfwd fstream istream -fstream limits fstream mutex -fstream new fstream ostream -fstream stdexcept fstream string fstream type_traits fstream typeinfo @@ -375,21 +349,11 @@ iomanip version ios atomic ios cctype -ios concepts -ios cstddef ios cstdint -ios cstdlib -ios cstring -ios initializer_list ios iosfwd -ios limits ios mutex -ios new -ios stdexcept ios string ios system_error -ios type_traits -ios typeinfo ios version iosfwd version iostream ios @@ -418,7 +382,6 @@ latch version limits type_traits limits version -list atomic list compare list concepts list cstddef @@ -426,14 +389,11 @@ list cstdlib list cstring list initializer_list -list iosfwd list limits list new list stdexcept list type_traits -list typeinfo list version -locale atomic locale cctype locale concepts locale cstddef @@ -448,11 +408,9 @@ locale limits locale mutex locale new -locale stdexcept locale streambuf locale string locale type_traits -locale typeinfo locale version map compare map concepts @@ -577,24 +535,19 @@ ratio cstdint ratio type_traits ratio version -regex atomic regex cctype regex compare regex concepts regex cstddef regex cstdint regex cstdlib -regex cstring regex deque regex initializer_list -regex iosfwd regex limits regex mutex -regex new regex stdexcept regex string regex type_traits -regex typeinfo regex vector regex version scoped_allocator cstddef @@ -779,7 +732,6 @@ variant tuple variant type_traits variant version -vector atomic vector climits vector compare vector concepts @@ -793,5 +745,4 @@ vector new vector stdexcept vector type_traits -vector typeinfo vector version