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> 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> 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/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/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 @@ -9,8 +9,6 @@ algorithm limits algorithm new algorithm type_traits -any atomic -any concepts any cstddef any cstring any initializer_list @@ -74,17 +72,9 @@ chrono string_view cinttypes cstdint cmath type_traits -codecvt atomic codecvt cctype -codecvt concepts -codecvt cstring -codecvt initializer_list -codecvt limits +codecvt cstdint codecvt mutex -codecvt new -codecvt stdexcept -codecvt type_traits -codecvt typeinfo compare cmath compare type_traits complex cmath @@ -111,7 +101,6 @@ ctgmath ccomplex cwchar cwctype cwctype cctype -deque atomic deque compare deque concepts deque cstdlib @@ -120,7 +109,6 @@ deque limits deque new deque stdexcept -deque typeinfo exception cstddef exception cstdlib exception type_traits @@ -220,7 +208,6 @@ format string format string_view format version -forward_list atomic forward_list compare forward_list concepts forward_list cstddef @@ -231,21 +218,14 @@ forward_list new forward_list stdexcept forward_list type_traits -forward_list typeinfo -fstream atomic fstream cctype fstream concepts fstream cstddef -fstream cstring fstream filesystem fstream initializer_list fstream istream -fstream limits fstream mutex -fstream new -fstream stdexcept fstream type_traits -fstream typeinfo functional array functional atomic functional concepts @@ -268,18 +248,10 @@ future thread initializer_list cstddef iomanip istream -ios atomic ios cctype -ios concepts -ios cstring -ios initializer_list +ios cstdint ios iosfwd -ios limits ios mutex -ios new -ios stdexcept -ios type_traits -ios typeinfo iosfwd version iostream ios iostream istream @@ -297,7 +269,6 @@ iterator variant latch atomic limits type_traits -list atomic list compare list concepts list cstdlib @@ -306,8 +277,6 @@ list limits list new list stdexcept -list typeinfo -locale atomic locale cctype locale concepts locale cstdlib @@ -317,10 +286,7 @@ locale iosfwd locale limits locale mutex -locale new -locale stdexcept locale streambuf -locale typeinfo map concepts map cstdlib map initializer_list @@ -406,19 +372,14 @@ ratio climits ratio cstdint ratio type_traits -regex atomic regex cctype regex concepts regex cstdlib -regex cstring regex deque regex initializer_list regex limits regex mutex -regex new -regex stdexcept regex type_traits -regex typeinfo regex vector scoped_allocator cstddef scoped_allocator limits @@ -548,7 +509,7 @@ variant new variant tuple variant type_traits -vector atomic +vector climits vector compare vector concepts vector cstdlib @@ -557,4 +518,3 @@ vector limits vector new vector stdexcept -vector typeinfo