From c9d36bd80760db14f14b33789e6cbc6cb8c64830 Mon Sep 17 00:00:00 2001 From: Nikolas Klauser Date: Wed, 1 Mar 2023 20:49:22 +0100 Subject: [PATCH] [libc++] Granularize includes Reviewed By: ldionne, #libc Spies: mikhail.ramalho, smeenai, libcxx-commits Differential Revision: https://reviews.llvm.org/D146097 --- libcxx/include/__expected/bad_expected_access.h | 3 +-- libcxx/include/__format/buffer.h | 1 + libcxx/include/__functional/function.h | 2 +- libcxx/include/__ranges/join_view.h | 1 + libcxx/include/functional | 2 +- libcxx/include/future | 4 ++-- libcxx/include/map | 1 + libcxx/include/new | 4 +++- libcxx/include/ostream | 1 + libcxx/include/stdexcept | 7 +++++-- libcxx/include/thread | 2 ++ libcxx/include/typeinfo | 3 ++- libcxx/include/variant | 3 ++- libcxx/test/libcxx/transitive_includes/cxx03.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx11.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx14.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx17.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx20.csv | 1 - libcxx/test/libcxx/transitive_includes/cxx2b.csv | 7 ------- .../wait_terminates.sh.cpp | 11 ++++++----- .../thread.thread.destr/dtor.pass.cpp | 7 ++++--- 21 files changed, 33 insertions(+), 31 deletions(-) diff --git a/libcxx/include/__expected/bad_expected_access.h b/libcxx/include/__expected/bad_expected_access.h index 361eab4b6018..e7a568c88f01 100644 --- a/libcxx/include/__expected/bad_expected_access.h +++ b/libcxx/include/__expected/bad_expected_access.h @@ -10,10 +10,9 @@ #define _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H #include <__config> +#include <__exception/exception.h> #include <__utility/move.h> -#include - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/libcxx/include/__format/buffer.h b/libcxx/include/__format/buffer.h index c8e11925a10c..0f669ba9e285 100644 --- a/libcxx/include/__format/buffer.h +++ b/libcxx/include/__format/buffer.h @@ -27,6 +27,7 @@ #include <__iterator/incrementable_traits.h> #include <__iterator/iterator_traits.h> #include <__iterator/wrap_iter.h> +#include <__memory/addressof.h> #include <__type_traits/add_pointer.h> #include <__utility/move.h> #include diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h index 92e0d24f60b7..3c6998cb8c8f 100644 --- a/libcxx/include/__functional/function.h +++ b/libcxx/include/__functional/function.h @@ -12,6 +12,7 @@ #include <__assert> #include <__config> +#include <__exception/exception.h> #include <__functional/binary_function.h> #include <__functional/invoke.h> #include <__functional/unary_function.h> @@ -32,7 +33,6 @@ #include <__utility/piecewise_construct.h> #include <__utility/swap.h> #include <__verbose_abort> -#include #include #include #include diff --git a/libcxx/include/__ranges/join_view.h b/libcxx/include/__ranges/join_view.h index cba16c807bdb..83145ffb23a9 100644 --- a/libcxx/include/__ranges/join_view.h +++ b/libcxx/include/__ranges/join_view.h @@ -22,6 +22,7 @@ #include <__iterator/iterator_traits.h> #include <__iterator/iterator_with_data.h> #include <__iterator/segmented_iterator.h> +#include <__memory/addressof.h> #include <__ranges/access.h> #include <__ranges/all.h> #include <__ranges/concepts.h> diff --git a/libcxx/include/functional b/libcxx/include/functional index 26c736f5673b..489b70d6462c 100644 --- a/libcxx/include/functional +++ b/libcxx/include/functional @@ -543,7 +543,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited #include <__functional/unary_negate.h> #include <__functional/unwrap_ref.h> #include <__utility/forward.h> -#include #include // TODO: find out why removing this breaks the modules build #include #include @@ -555,6 +554,7 @@ POLICY: For non-variadic implementations, the number of arguments is limited #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include # include +# include # include # include # include diff --git a/libcxx/include/future b/libcxx/include/future index dee9d0a71404..cc7d1f93dd6f 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -366,6 +366,7 @@ template struct uses_allocator, Alloc>; #include <__chrono/duration.h> #include <__chrono/time_point.h> #include <__config> +#include <__exception/exception_ptr.h> #include <__memory/allocator_arg_t.h> #include <__memory/allocator_destructor.h> #include <__memory/shared_ptr.h> @@ -377,8 +378,6 @@ template struct uses_allocator, Alloc>; #include <__utility/auto_cast.h> #include <__utility/forward.h> #include <__utility/move.h> -#include <__verbose_abort> -#include #include #include #include @@ -2461,6 +2460,7 @@ _LIBCPP_END_NAMESPACE_STD #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 # include +# include #endif #endif // _LIBCPP_FUTURE diff --git a/libcxx/include/map b/libcxx/include/map index c190e3fc069b..98ee961559e2 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -549,6 +549,7 @@ erase_if(multimap& c, Predicate pred); // C++20 #include <__iterator/erase_if_container.h> #include <__iterator/iterator_traits.h> #include <__iterator/reverse_iterator.h> +#include <__memory/addressof.h> #include <__memory/allocator.h> #include <__memory_resource/polymorphic_allocator.h> #include <__node_handle> diff --git a/libcxx/include/new b/libcxx/include/new index 871ace09a242..af396cd4b8eb 100644 --- a/libcxx/include/new +++ b/libcxx/include/new @@ -89,13 +89,14 @@ void operator delete[](void* ptr, void*) noexcept; #include <__assert> // all public C++ headers provide the assertion handler #include <__availability> #include <__config> +#include <__exception/exception.h> +#include <__type_traits/alignment_of.h> #include <__type_traits/is_function.h> #include <__type_traits/is_same.h> #include <__type_traits/remove_cv.h> #include <__verbose_abort> #include #include -#include #include #if defined(_LIBCPP_ABI_VCRUNTIME) @@ -365,6 +366,7 @@ inline constexpr size_t hardware_constructive_interference_size = __GCC_CONSTRUC _LIBCPP_END_NAMESPACE_STD #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include # include #endif diff --git a/libcxx/include/ostream b/libcxx/include/ostream index 60f111ce6aa8..dbb54ac7e1a2 100644 --- a/libcxx/include/ostream +++ b/libcxx/include/ostream @@ -165,6 +165,7 @@ basic_ostream& operator<<(basic_ostream&, cons #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__exception/operations.h> #include <__memory/shared_ptr.h> #include <__memory/unique_ptr.h> #include <__type_traits/conjunction.h> diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept index ef4740959e27..abdef87a5b0b 100644 --- a/libcxx/include/stdexcept +++ b/libcxx/include/stdexcept @@ -43,9 +43,8 @@ public: #include <__assert> // all public C++ headers provide the assertion handler #include <__config> -#include <__verbose_abort> +#include <__exception/exception.h> #include -#include #include // for string forward decl #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -300,4 +299,8 @@ void __throw_underflow_error(const char*__msg) _LIBCPP_END_NAMESPACE_STD +#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +#endif + #endif // _LIBCPP_STDEXCEPT diff --git a/libcxx/include/thread b/libcxx/include/thread index db8a1e86251b..13e722ca9476 100644 --- a/libcxx/include/thread +++ b/libcxx/include/thread @@ -85,7 +85,9 @@ void sleep_for(const chrono::duration& rel_time); #include <__assert> // all public C++ headers provide the assertion handler #include <__config> +#include <__exception/terminate.h> #include <__functional/hash.h> +#include <__memory/addressof.h> #include <__memory/unique_ptr.h> #include <__mutex_base> #include <__thread/poll_with_backoff.h> diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo index ca3515064455..1553be1c6e10 100644 --- a/libcxx/include/typeinfo +++ b/libcxx/include/typeinfo @@ -59,12 +59,12 @@ public: #include <__assert> // all public C++ headers provide the assertion handler #include <__availability> #include <__config> +#include <__exception/exception.h> #include <__type_traits/is_constant_evaluated.h> #include <__verbose_abort> #include #include #include -#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -415,6 +415,7 @@ void __throw_bad_cast() _LIBCPP_END_NAMESPACE_STD #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include # include #endif diff --git a/libcxx/include/variant b/libcxx/include/variant index a88662e9fd08..425feadd120b 100644 --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -210,6 +210,7 @@ namespace std { #include <__compare/compare_three_way_result.h> #include <__compare/three_way_comparable.h> #include <__config> +#include <__exception/exception.h> #include <__functional/hash.h> #include <__functional/invoke.h> #include <__functional/operations.h> @@ -239,7 +240,6 @@ namespace std { #include <__utility/swap.h> #include <__variant/monostate.h> #include <__verbose_abort> -#include #include #include #include @@ -1834,6 +1834,7 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include # include # include # include diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv index a5b1c91100d5..92a84f59268b 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx03.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv @@ -213,7 +213,6 @@ exception version execution version expected cstddef expected cstdlib -expected exception expected initializer_list expected new expected version diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv index 2f36b61d3c3c..833e8ac19f8e 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx11.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv @@ -213,7 +213,6 @@ exception version execution version expected cstddef expected cstdlib -expected exception expected initializer_list expected new expected version diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv index cc5075fe139f..c3c0ae6f71e8 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx14.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv @@ -213,7 +213,6 @@ exception version execution version expected cstddef expected cstdlib -expected exception expected initializer_list expected new expected version diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv index cc5075fe139f..c3c0ae6f71e8 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx17.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv @@ -213,7 +213,6 @@ exception version execution version expected cstddef expected cstdlib -expected exception expected initializer_list expected new expected version diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv index 4a892ae5e17b..a5be0f14d858 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx20.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv @@ -220,7 +220,6 @@ exception version execution version expected cstddef expected cstdlib -expected exception expected initializer_list expected new expected version diff --git a/libcxx/test/libcxx/transitive_includes/cxx2b.csv b/libcxx/test/libcxx/transitive_includes/cxx2b.csv index beb4acc3211c..8bed29fafc01 100644 --- a/libcxx/test/libcxx/transitive_includes/cxx2b.csv +++ b/libcxx/test/libcxx/transitive_includes/cxx2b.csv @@ -151,7 +151,6 @@ exception version execution version expected cstddef expected cstdlib -expected exception expected initializer_list expected new expected version @@ -277,7 +276,6 @@ functional cstddef functional cstdint functional cstdlib functional cstring -functional exception functional initializer_list functional iosfwd functional limits @@ -293,7 +291,6 @@ future cstddef future cstdint future cstdlib future cstring -future exception future initializer_list future iosfwd future limits @@ -420,7 +417,6 @@ mutex typeinfo mutex version new cstddef new cstdlib -new exception new version numbers version numeric cmath @@ -548,7 +544,6 @@ stack deque stack initializer_list stack version stdexcept cstdlib -stdexcept exception stdexcept iosfwd streambuf cstdint streambuf ios @@ -618,7 +613,6 @@ typeindex version typeinfo cstddef typeinfo cstdint typeinfo cstdlib -typeinfo exception unordered_map cmath unordered_map compare unordered_map cstddef @@ -663,7 +657,6 @@ variant compare variant cstddef variant cstdint variant cstring -variant exception variant initializer_list variant limits variant new diff --git a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp index fd61634bd96e..4e2086220e96 100644 --- a/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp +++ b/libcxx/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp @@ -55,13 +55,14 @@ // that terminate has been called) -#include #include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include "make_test_thread.h" diff --git a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp index 77665050d184..1d959e96dbca 100644 --- a/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp +++ b/libcxx/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp @@ -15,10 +15,11 @@ // ~thread(); -#include -#include -#include #include +#include +#include +#include +#include #include "make_test_thread.h" #include "test_macros.h"