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,9 @@ #endif #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# 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,19 @@ _LIBCPP_END_NAMESPACE_STD +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# 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> @@ -2932,8 +2933,11 @@ #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include +# 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> @@ -1780,8 +1780,11 @@ #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include +# include # include +# include # include +# include #endif #endif // _LIBCPP_FORWARD_LIST diff --git a/libcxx/include/fstream b/libcxx/include/fstream --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -1744,4 +1744,12 @@ _LIBCPP_POP_MACROS +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +#endif + #endif // _LIBCPP_FSTREAM 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/ios b/libcxx/include/ios --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -1038,4 +1038,17 @@ _LIBCPP_END_NAMESPACE_STD +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +#endif + #endif // _LIBCPP_IOS 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> @@ -2361,8 +2361,11 @@ #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include +# include # include +# include # include +# include #endif #endif // _LIBCPP_LIST diff --git a/libcxx/include/locale b/libcxx/include/locale --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -4353,8 +4353,11 @@ _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include # include # include +# include +# include #endif #endif // _LIBCPP_LOCALE 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/regex b/libcxx/include/regex --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -6840,7 +6840,12 @@ _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include # include +# include +# include # include #endif diff --git a/libcxx/include/vector b/libcxx/include/vector --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -3267,6 +3267,7 @@ #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include +# include # include # include #endif 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 @@ -109,22 +106,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 @@ -169,7 +154,6 @@ ctgmath cmath cwchar cwctype cwctype cctype -deque atomic deque compare deque concepts deque cstddef @@ -177,12 +161,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 @@ -305,7 +287,6 @@ format string_view format type_traits format version -forward_list atomic forward_list compare forward_list concepts forward_list cstddef @@ -313,14 +294,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 @@ -330,13 +308,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 @@ -376,21 +350,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 @@ -419,7 +383,6 @@ latch version limits type_traits limits version -list atomic list compare list concepts list cstddef @@ -427,14 +390,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 @@ -449,11 +409,9 @@ locale limits locale mutex locale new -locale stdexcept locale streambuf locale string locale type_traits -locale typeinfo locale version map compare map concepts @@ -579,24 +537,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 @@ -787,7 +740,6 @@ variant tuple variant type_traits variant version -vector atomic vector climits vector compare vector concepts @@ -801,5 +753,4 @@ vector new vector stdexcept vector type_traits -vector typeinfo vector version