[libcxx-commits] [libcxx] a65070a - [libc++] Remove a few transitive includes (#70553)
via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Oct 29 10:31:42 PDT 2023
Author: philnik777
Date: 2023-10-29T18:31:37+01:00
New Revision: a65070a76a7c823c28f1c95a21e4857ed6e123ef
URL: https://github.com/llvm/llvm-project/commit/a65070a76a7c823c28f1c95a21e4857ed6e123ef
DIFF: https://github.com/llvm/llvm-project/commit/a65070a76a7c823c28f1c95a21e4857ed6e123ef.diff
LOG: [libc++] Remove a few transitive includes (#70553)
Added:
Modified:
libcxx/include/__filesystem/directory_entry.h
libcxx/include/__filesystem/filesystem_error.h
libcxx/include/__fwd/string_view.h
libcxx/include/__ios/fpos.h
libcxx/include/__iterator/istream_iterator.h
libcxx/include/__iterator/istreambuf_iterator.h
libcxx/include/__iterator/ostream_iterator.h
libcxx/include/__memory/shared_ptr.h
libcxx/include/__memory_resource/polymorphic_allocator.h
libcxx/include/__random/independent_bits_engine.h
libcxx/include/__random/piecewise_linear_distribution.h
libcxx/include/__ranges/istream_view.h
libcxx/include/__thread/id.h
libcxx/include/__thread/thread.h
libcxx/include/__tree
libcxx/include/algorithm
libcxx/include/charconv
libcxx/include/complex
libcxx/include/condition_variable
libcxx/include/experimental/iterator
libcxx/include/ext/hash_map
libcxx/include/filesystem
libcxx/include/forward_list
libcxx/include/functional
libcxx/include/future
libcxx/include/istream
libcxx/include/iterator
libcxx/include/list
libcxx/include/map
libcxx/include/memory_resource
libcxx/include/mutex
libcxx/include/new
libcxx/include/numeric
libcxx/include/optional
libcxx/include/ostream
libcxx/include/ranges
libcxx/include/set
libcxx/include/span
libcxx/include/stdexcept
libcxx/include/stop_token
libcxx/include/streambuf
libcxx/include/unordered_set
libcxx/src/optional.cpp
libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
libcxx/test/libcxx/transitive_includes/cxx03.csv
libcxx/test/libcxx/transitive_includes/cxx11.csv
libcxx/test/libcxx/transitive_includes/cxx14.csv
libcxx/test/libcxx/transitive_includes/cxx17.csv
libcxx/test/libcxx/transitive_includes/cxx20.csv
libcxx/test/libcxx/transitive_includes/cxx23.csv
libcxx/test/libcxx/transitive_includes/cxx26.csv
libcxx/test/libcxx/utilities/function.objects/func.blocks.pass.cpp
libcxx/test/std/ranges/range.factories/range.repeat.view/size.pass.cpp
libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/types.h
libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__filesystem/directory_entry.h b/libcxx/include/__filesystem/directory_entry.h
index bb7a061db4ceae6..6baaca0709edb5c 100644
--- a/libcxx/include/__filesystem/directory_entry.h
+++ b/libcxx/include/__filesystem/directory_entry.h
@@ -26,7 +26,6 @@
#include <__utility/move.h>
#include <__utility/unreachable.h>
#include <cstdint>
-#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__filesystem/filesystem_error.h b/libcxx/include/__filesystem/filesystem_error.h
index 713cc357ee82f1b..3ffba1b6c2d6130 100644
--- a/libcxx/include/__filesystem/filesystem_error.h
+++ b/libcxx/include/__filesystem/filesystem_error.h
@@ -18,8 +18,6 @@
#include <__system_error/system_error.h>
#include <__utility/forward.h>
#include <__verbose_abort>
-#include <iosfwd>
-#include <new>
#include <string>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__fwd/string_view.h b/libcxx/include/__fwd/string_view.h
index 4818990248da881..786765ca6a2edfd 100644
--- a/libcxx/include/__fwd/string_view.h
+++ b/libcxx/include/__fwd/string_view.h
@@ -11,7 +11,7 @@
#define _LIBCPP___FWD_STRING_VIEW_H
#include <__config>
-#include <iosfwd> // char_traits
+#include <__fwd/string.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__ios/fpos.h b/libcxx/include/__ios/fpos.h
index 87f0135fc3ea2ee..ae578bdbb916c03 100644
--- a/libcxx/include/__ios/fpos.h
+++ b/libcxx/include/__ios/fpos.h
@@ -11,7 +11,7 @@
#define _LIBCPP___IOS_FPOS_H
#include <__config>
-#include <iosfwd>
+#include <__fwd/ios.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__iterator/istream_iterator.h b/libcxx/include/__iterator/istream_iterator.h
index 989902f212bdeb2..4630a1b1585c8ed 100644
--- a/libcxx/include/__iterator/istream_iterator.h
+++ b/libcxx/include/__iterator/istream_iterator.h
@@ -11,12 +11,13 @@
#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H
#include <__config>
+#include <__fwd/istream.h>
+#include <__fwd/string.h>
#include <__iterator/default_sentinel.h>
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
#include <cstddef>
-#include <iosfwd> // for forward declarations of char_traits and basic_istream
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__iterator/istreambuf_iterator.h b/libcxx/include/__iterator/istreambuf_iterator.h
index e39fec6d72dd35a..e8e22ccdeb5e2d6 100644
--- a/libcxx/include/__iterator/istreambuf_iterator.h
+++ b/libcxx/include/__iterator/istreambuf_iterator.h
@@ -11,10 +11,11 @@
#define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H
#include <__config>
+#include <__fwd/istream.h>
+#include <__fwd/streambuf.h>
#include <__iterator/default_sentinel.h>
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
-#include <iosfwd> // for forward declaration of basic_streambuf
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__iterator/ostream_iterator.h b/libcxx/include/__iterator/ostream_iterator.h
index 025712bb1ca96b6..85edebabeb1e105 100644
--- a/libcxx/include/__iterator/ostream_iterator.h
+++ b/libcxx/include/__iterator/ostream_iterator.h
@@ -11,11 +11,12 @@
#define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H
#include <__config>
+#include <__fwd/ostream.h>
+#include <__fwd/string.h>
#include <__iterator/iterator.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
#include <cstddef>
-#include <iosfwd> // for forward declarations of char_traits and basic_ostream
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h
index d9ddb8a17be273f..96e1f80bdede5c5 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -14,9 +14,11 @@
#include <__compare/compare_three_way.h>
#include <__compare/ordering.h>
#include <__config>
+#include <__exception/exception.h>
#include <__functional/binary_function.h>
#include <__functional/operations.h>
#include <__functional/reference_wrapper.h>
+#include <__fwd/ostream.h>
#include <__iterator/access.h>
#include <__memory/addressof.h>
#include <__memory/allocation_guard.h>
@@ -49,9 +51,7 @@
#include <__utility/swap.h>
#include <__verbose_abort>
#include <cstddef>
-#include <iosfwd>
#include <new>
-#include <stdexcept>
#include <typeinfo>
#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
# include <__atomic/memory_order.h>
diff --git a/libcxx/include/__memory_resource/polymorphic_allocator.h b/libcxx/include/__memory_resource/polymorphic_allocator.h
index 8fcce65ad2f4b66..3a2794931767b2a 100644
--- a/libcxx/include/__memory_resource/polymorphic_allocator.h
+++ b/libcxx/include/__memory_resource/polymorphic_allocator.h
@@ -17,7 +17,6 @@
#include <cstddef>
#include <limits>
#include <new>
-#include <stdexcept>
#include <tuple>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__random/independent_bits_engine.h b/libcxx/include/__random/independent_bits_engine.h
index 0164ce08fb5d4bd..376524722d997a0 100644
--- a/libcxx/include/__random/independent_bits_engine.h
+++ b/libcxx/include/__random/independent_bits_engine.h
@@ -10,6 +10,8 @@
#define _LIBCPP___RANDOM_INDEPENDENT_BITS_ENGINE_H
#include <__config>
+#include <__fwd/istream.h>
+#include <__fwd/ostream.h>
#include <__random/is_seed_sequence.h>
#include <__random/log2.h>
#include <__type_traits/conditional.h>
@@ -17,7 +19,6 @@
#include <__type_traits/is_convertible.h>
#include <__utility/move.h>
#include <cstddef>
-#include <iosfwd>
#include <limits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__random/piecewise_linear_distribution.h b/libcxx/include/__random/piecewise_linear_distribution.h
index 6be44b29fcc8400..8d0458d125fd500 100644
--- a/libcxx/include/__random/piecewise_linear_distribution.h
+++ b/libcxx/include/__random/piecewise_linear_distribution.h
@@ -13,8 +13,8 @@
#include <__config>
#include <__random/is_valid.h>
#include <__random/uniform_real_distribution.h>
+#include <cmath>
#include <iosfwd>
-#include <numeric>
#include <vector>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__ranges/istream_view.h b/libcxx/include/__ranges/istream_view.h
index 66cd91527616aea..71af102c3320358 100644
--- a/libcxx/include/__ranges/istream_view.h
+++ b/libcxx/include/__ranges/istream_view.h
@@ -14,6 +14,8 @@
#include <__concepts/derived_from.h>
#include <__concepts/movable.h>
#include <__config>
+#include <__fwd/istream.h>
+#include <__fwd/string.h>
#include <__iterator/default_sentinel.h>
#include <__iterator/iterator_traits.h>
#include <__memory/addressof.h>
@@ -21,7 +23,6 @@
#include <__type_traits/remove_cvref.h>
#include <__utility/forward.h>
#include <cstddef>
-#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__thread/id.h b/libcxx/include/__thread/id.h
index fd6e6dffafa952f..83b1d8eceede3b4 100644
--- a/libcxx/include/__thread/id.h
+++ b/libcxx/include/__thread/id.h
@@ -13,8 +13,8 @@
#include <__compare/ordering.h>
#include <__config>
#include <__fwd/hash.h>
+#include <__fwd/ostream.h>
#include <__threading_support>
-#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__thread/thread.h b/libcxx/include/__thread/thread.h
index a1861e494888948..6ce09147f8d3d50 100644
--- a/libcxx/include/__thread/thread.h
+++ b/libcxx/include/__thread/thread.h
@@ -21,7 +21,6 @@
#include <__thread/id.h>
#include <__threading_support>
#include <__utility/forward.h>
-#include <iosfwd>
#include <tuple>
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
diff --git a/libcxx/include/__tree b/libcxx/include/__tree
index eccadea8a013931..68768e17e600603 100644
--- a/libcxx/include/__tree
+++ b/libcxx/include/__tree
@@ -41,7 +41,6 @@
#include <__utility/pair.h>
#include <__utility/swap.h>
#include <limits>
-#include <stdexcept>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index 7dcf396b683db4f..578de74d401dc2c 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -1754,7 +1754,6 @@ template <class BidirectionalIterator, class Compare>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <cstddef>
#include <version>
#include <__algorithm/adjacent_find.h>
diff --git a/libcxx/include/charconv b/libcxx/include/charconv
index 92273b4ce4766b4..5a2869acba8715b 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -82,9 +82,7 @@ namespace std {
#include <__charconv/traits.h>
#include <__config>
#include <__system_error/errc.h>
-#include <cmath> // for log2f
-#include <cstdint>
-#include <limits>
+#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -95,10 +93,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
_LIBCPP_END_NAMESPACE_STD
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <cmath>
# include <concepts>
+# include <cstdint>
# include <cstdlib>
# include <cstring>
# include <iosfwd>
+# include <limits>
# include <type_traits>
#endif
diff --git a/libcxx/include/complex b/libcxx/include/complex
index c8ffde9515636ce..5cfb160ee00f020 100644
--- a/libcxx/include/complex
+++ b/libcxx/include/complex
@@ -234,8 +234,6 @@ template<class T> complex<T> tanh (const complex<T>&);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <cmath>
-#include <iosfwd>
-#include <stdexcept>
#include <version>
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
@@ -1543,6 +1541,8 @@ inline namespace literals
_LIBCPP_END_NAMESPACE_STD
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <iosfwd>
+# include <stdexcept>
# include <type_traits>
#endif
diff --git a/libcxx/include/condition_variable b/libcxx/include/condition_variable
index f6d72b48337187b..eb1c4bf5de6b6d8 100644
--- a/libcxx/include/condition_variable
+++ b/libcxx/include/condition_variable
@@ -343,6 +343,7 @@ _LIBCPP_END_NAMESPACE_STD
# include <cstdlib>
# include <cstring>
# include <initializer_list>
+# include <iosfwd>
# include <new>
# include <stdexcept>
# include <system_error>
diff --git a/libcxx/include/experimental/iterator b/libcxx/include/experimental/iterator
index a5e3dffba980bca..5f9842de4f7f8a2 100644
--- a/libcxx/include/experimental/iterator
+++ b/libcxx/include/experimental/iterator
@@ -58,7 +58,6 @@ namespace std {
#include <__utility/forward.h>
#include <__utility/move.h>
#include <experimental/__config>
-#include <iosfwd> // char_traits
#include <iterator>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -120,6 +119,7 @@ _LIBCPP_END_NAMESPACE_LFTS
#endif // _LIBCPP_STD_VER >= 14
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <iosfwd>
# include <type_traits>
#endif
diff --git a/libcxx/include/ext/hash_map b/libcxx/include/ext/hash_map
index de963675eb793ca..6df48bcb5f8d9be 100644
--- a/libcxx/include/ext/hash_map
+++ b/libcxx/include/ext/hash_map
@@ -207,7 +207,6 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
#include <algorithm>
#include <ext/__hash>
#include <functional>
-#include <stdexcept>
#if defined(__DEPRECATED) && __DEPRECATED
#if defined(_LIBCPP_WARNING)
diff --git a/libcxx/include/filesystem b/libcxx/include/filesystem
index 99ba713ad07ba88..ec68354a9fc9333 100644
--- a/libcxx/include/filesystem
+++ b/libcxx/include/filesystem
@@ -565,6 +565,8 @@ inline constexpr bool std::ranges::enable_view<std::filesystem::recursive_direct
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <concepts>
# include <cstdlib>
+# include <iosfwd>
+# include <new>
# include <system_error>
#endif
diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list
index 09338ab6957134d..06e38cb9a568bf2 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -1891,6 +1891,7 @@ _LIBCPP_POP_MACROS
# include <functional>
# include <iosfwd>
# include <iterator>
+# include <stdexcept>
# include <type_traits>
# include <typeinfo>
#endif
diff --git a/libcxx/include/functional b/libcxx/include/functional
index 5f9e8fa82a891f8..fd99e11fb181801 100644
--- a/libcxx/include/functional
+++ b/libcxx/include/functional
@@ -542,8 +542,6 @@ POLICY: For non-variadic implementations, the number of arguments is limited
#include <__functional/unary_negate.h>
#include <__type_traits/unwrap_ref.h>
#include <__utility/forward.h>
-#include <memory> // TODO: find out why removing this breaks the modules build
-#include <typeinfo>
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -555,8 +553,12 @@ POLICY: For non-variadic implementations, the number of arguments is limited
# include <concepts>
# include <cstdlib>
# include <exception>
+# include <iosfwd>
+# include <memory>
+# include <stdexcept>
# include <tuple>
# include <type_traits>
+# include <typeinfo>
# include <utility>
#endif
diff --git a/libcxx/include/future b/libcxx/include/future
index f372b8e6ad5d8d8..96aa47fc60fcb4b 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -2476,6 +2476,7 @@ _LIBCPP_END_NAMESPACE_STD
# include <atomic>
# include <cstdlib>
# include <exception>
+# include <iosfwd>
# include <system_error>
#endif
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 89370086106c5e6..d9c1a79cdd54e6a 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -1647,6 +1647,7 @@ _LIBCPP_END_NAMESPACE_STD
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <concepts>
+# include <iosfwd>
# include <type_traits>
#endif
diff --git a/libcxx/include/iterator b/libcxx/include/iterator
index dcba1e1c4fba05b..2f9280742370a2f 100644
--- a/libcxx/include/iterator
+++ b/libcxx/include/iterator
@@ -716,8 +716,6 @@ template <class E> constexpr const E* data(initializer_list<E> il) noexcept;
#include <__iterator/wrap_iter.h>
#include <__memory/addressof.h>
#include <__memory/pointer_traits.h>
-#include <cstddef>
-#include <initializer_list>
#include <version>
// standard-mandated includes
diff --git a/libcxx/include/list b/libcxx/include/list
index e5b524b8835a111..feca1605c773cf8 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -2107,6 +2107,7 @@ _LIBCPP_POP_MACROS
# include <functional>
# include <iosfwd>
# include <iterator>
+# include <stdexcept>
# include <type_traits>
# include <typeinfo>
#endif
diff --git a/libcxx/include/map b/libcxx/include/map
index 17bb715f249d756..04cf2d313422327 100644
--- a/libcxx/include/map
+++ b/libcxx/include/map
@@ -596,6 +596,7 @@ erase_if(multimap<Key, T, Compare, Allocator>& c, Predicate pred); // C++20
#include <__utility/forward.h>
#include <__utility/piecewise_construct.h>
#include <__utility/swap.h>
+#include <stdexcept>
#include <tuple>
#include <version>
diff --git a/libcxx/include/memory_resource b/libcxx/include/memory_resource
index 276e08f23fa12fe..e9c87777e8f750f 100644
--- a/libcxx/include/memory_resource
+++ b/libcxx/include/memory_resource
@@ -62,4 +62,8 @@ namespace std::pmr {
# pragma GCC system_header
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <stdexcept>
+#endif
+
#endif /* _LIBCPP_MEMORY_RESOURCE */
diff --git a/libcxx/include/mutex b/libcxx/include/mutex
index ec110c8c07dede2..bdf1742dfcfe140 100644
--- a/libcxx/include/mutex
+++ b/libcxx/include/mutex
@@ -200,7 +200,7 @@ template<class Callable, class ...Args>
#include <__thread/id.h>
#include <__threading_support>
#include <__utility/forward.h>
-#include <cstdint>
+#include <cstddef>
#include <limits>
#ifndef _LIBCPP_CXX03_LANG
# include <tuple>
@@ -567,6 +567,7 @@ _LIBCPP_POP_MACROS
# include <cstring>
# include <ctime>
# include <initializer_list>
+# include <iosfwd>
# include <new>
# include <stdexcept>
# include <system_error>
diff --git a/libcxx/include/new b/libcxx/include/new
index 0a97c3e37add574..7a2ef54f778ee4b 100644
--- a/libcxx/include/new
+++ b/libcxx/include/new
@@ -94,9 +94,7 @@ void operator delete[](void* ptr, void*) noexcept;
#include <__type_traits/is_function.h>
#include <__type_traits/is_same.h>
#include <__type_traits/remove_cv.h>
-#include <__verbose_abort>
#include <cstddef>
-#include <cstdlib>
#include <version>
#if defined(_LIBCPP_ABI_VCRUNTIME)
@@ -370,6 +368,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 <cstdlib>
# include <exception>
# include <type_traits>
#endif
diff --git a/libcxx/include/numeric b/libcxx/include/numeric
index 3fcf6cefdb4b884..d09d0a81fcc03a2 100644
--- a/libcxx/include/numeric
+++ b/libcxx/include/numeric
@@ -146,7 +146,6 @@ template<class T>
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <cmath> // for isnormal
#include <version>
#include <__numeric/accumulate.h>
@@ -170,6 +169,7 @@ template<class T>
#endif
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <cmath>
# include <concepts>
# include <functional>
# include <iterator>
diff --git a/libcxx/include/optional b/libcxx/include/optional
index fc172c752582f00..ab90cc8ce7f776c 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -183,6 +183,7 @@ namespace std {
#include <__compare/three_way_comparable.h>
#include <__concepts/invocable.h>
#include <__config>
+#include <__exception/exception.h>
#include <__functional/hash.h>
#include <__functional/invoke.h>
#include <__functional/reference_wrapper.h>
@@ -227,7 +228,6 @@ namespace std {
#include <__verbose_abort>
#include <initializer_list>
#include <new>
-#include <stdexcept>
#include <version>
// standard-mandated includes
@@ -1686,6 +1686,7 @@ _LIBCPP_POP_MACROS
# include <iterator>
# include <memory>
# include <ratio>
+# include <stdexcept>
# include <tuple>
# include <type_traits>
# include <typeinfo>
diff --git a/libcxx/include/ostream b/libcxx/include/ostream
index f30cfe26e75517b..469232964d5b79c 100644
--- a/libcxx/include/ostream
+++ b/libcxx/include/ostream
@@ -1201,7 +1201,9 @@ _LIBCPP_END_NAMESPACE_STD
# include <atomic>
# include <concepts>
# include <cstdlib>
+# include <iosfwd>
# include <iterator>
+# include <stdexcept>
# include <type_traits>
#endif
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index db592fd5cb360c4..f71a92f8a660b06 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -437,6 +437,7 @@ namespace std {
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <cstdlib>
+# include <iosfwd>
# include <type_traits>
#endif
diff --git a/libcxx/include/set b/libcxx/include/set
index 75be1e13ede511d..ce6663f34b66336 100644
--- a/libcxx/include/set
+++ b/libcxx/include/set
@@ -1760,6 +1760,7 @@ _LIBCPP_END_NAMESPACE_STD
# include <cstdlib>
# include <functional>
# include <iterator>
+# include <stdexcept>
# include <type_traits>
#endif
diff --git a/libcxx/include/span b/libcxx/include/span
index b050dfe6e340e5a..69b0a2875e26ccd 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -146,7 +146,6 @@ template<class R>
#include <__utility/forward.h>
#include <array> // for array
#include <cstddef> // for byte
-#include <limits>
#include <version>
// standard-mandated includes
diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept
index cc6b0c5f38819ba..902054bb034faed 100644
--- a/libcxx/include/stdexcept
+++ b/libcxx/include/stdexcept
@@ -44,8 +44,8 @@ public:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__exception/exception.h>
+#include <__fwd/string.h>
#include <__verbose_abort>
-#include <iosfwd> // for string forward decl
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -309,6 +309,7 @@ _LIBCPP_END_NAMESPACE_STD
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
# include <cstdlib>
# include <exception>
+# include <iosfwd>
#endif
#endif // _LIBCPP_STDEXCEPT
diff --git a/libcxx/include/stop_token b/libcxx/include/stop_token
index dd43ac298b9ab5f..b223ceb27f0d248 100644
--- a/libcxx/include/stop_token
+++ b/libcxx/include/stop_token
@@ -46,4 +46,8 @@ namespace std {
# error "<stop_token> is not supported since libc++ has been configured without support for threads."
#endif
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <iosfwd>
+#endif
+
#endif // _LIBCPP_STOP_TOKEN
diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf
index 095ac7d3ad8371b..9d94e42f37fe20e 100644
--- a/libcxx/include/streambuf
+++ b/libcxx/include/streambuf
@@ -110,7 +110,6 @@ protected:
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
#include <__fwd/streambuf.h>
-#include <cstdint>
#include <ios>
#include <iosfwd>
#include <version>
@@ -499,4 +498,8 @@ _LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
+#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
+# include <cstdint>
+#endif
+
#endif // _LIBCPP_STREAMBUF
diff --git a/libcxx/include/unordered_set b/libcxx/include/unordered_set
index f1b4104df4f68f7..e8fd22ba6bb8a7b 100644
--- a/libcxx/include/unordered_set
+++ b/libcxx/include/unordered_set
@@ -1976,6 +1976,7 @@ _LIBCPP_END_NAMESPACE_STD
# include <cstdlib>
# include <functional>
# include <iterator>
+# include <stdexcept>
# include <type_traits>
#endif
diff --git a/libcxx/src/optional.cpp b/libcxx/src/optional.cpp
index d0214981a2fda0c..fc91152f011cc57 100644
--- a/libcxx/src/optional.cpp
+++ b/libcxx/src/optional.cpp
@@ -8,6 +8,7 @@
#include <__availability>
#include <optional>
+#include <stdexcept>
namespace std
{
diff --git a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
index 3b33737466c7419..3b0849873ac9140 100644
--- a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
+++ b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp
@@ -34,10 +34,9 @@
// RUN: %{build} -fno-aligned-allocation -fno-sized-deallocation -DNO_ALIGN -DNO_SIZE
// RUN: %{run}
-#include <new>
-#include <typeinfo>
-#include <string>
#include <cassert>
+#include <cstdlib>
+#include <new>
#include "test_macros.h"
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index 153335c3519c473..e41a3b290cf6ef5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -111,6 +111,7 @@ charconv iosfwd
charconv limits
charconv new
charconv type_traits
+charconv version
chrono bit
chrono compare
chrono concepts
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index f3f8956df64ee78..4ac3dccc50040f8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -111,6 +111,7 @@ charconv iosfwd
charconv limits
charconv new
charconv type_traits
+charconv version
chrono bit
chrono compare
chrono concepts
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index fb90523d5552ac3..4f3fdfdd4d2cae5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -111,6 +111,7 @@ charconv iosfwd
charconv limits
charconv new
charconv type_traits
+charconv version
chrono bit
chrono compare
chrono concepts
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index fb90523d5552ac3..4f3fdfdd4d2cae5 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -111,6 +111,7 @@ charconv iosfwd
charconv limits
charconv new
charconv type_traits
+charconv version
chrono bit
chrono compare
chrono concepts
diff --git a/libcxx/test/libcxx/transitive_includes/cxx20.csv b/libcxx/test/libcxx/transitive_includes/cxx20.csv
index 63ea6c09b1f5083..590a39e1b28e93f 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx20.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx20.csv
@@ -110,6 +110,7 @@ charconv iosfwd
charconv limits
charconv new
charconv type_traits
+charconv version
chrono array
chrono bit
chrono charconv
diff --git a/libcxx/test/libcxx/transitive_includes/cxx23.csv b/libcxx/test/libcxx/transitive_includes/cxx23.csv
index 236dedd186c9268..aa6879026c90265 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx23.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx23.csv
@@ -62,12 +62,12 @@ bitset string_view
bitset version
ccomplex complex
charconv cerrno
-charconv cmath
charconv cstddef
charconv cstdint
charconv initializer_list
charconv limits
charconv new
+charconv version
chrono array
chrono cmath
chrono compare
@@ -99,10 +99,8 @@ codecvt cstdlib
codecvt cstring
codecvt cwchar
codecvt initializer_list
-codecvt iosfwd
codecvt limits
codecvt new
-codecvt stdexcept
codecvt string
codecvt tuple
codecvt typeinfo
@@ -113,9 +111,7 @@ compare cstdint
compare limits
compare version
complex cmath
-complex iosfwd
complex sstream
-complex stdexcept
complex version
concepts cstddef
concepts version
@@ -125,7 +121,6 @@ condition_variable cstddef
condition_variable cstdint
condition_variable cstring
condition_variable ctime
-condition_variable iosfwd
condition_variable limits
condition_variable new
condition_variable ratio
@@ -170,7 +165,6 @@ experimental/deque experimental/memory_resource
experimental/forward_list experimental/memory_resource
experimental/forward_list forward_list
experimental/iterator cstddef
-experimental/iterator iosfwd
experimental/iterator iterator
experimental/list experimental/memory_resource
experimental/list list
@@ -208,10 +202,8 @@ filesystem cstdint
filesystem cstring
filesystem ctime
filesystem iomanip
-filesystem iosfwd
filesystem limits
filesystem locale
-filesystem new
filesystem ratio
filesystem string
filesystem string_view
@@ -237,7 +229,6 @@ forward_list cstddef
forward_list initializer_list
forward_list limits
forward_list new
-forward_list stdexcept
forward_list tuple
forward_list version
fstream cctype
@@ -250,12 +241,10 @@ fstream cstring
fstream cwchar
fstream filesystem
fstream initializer_list
-fstream iosfwd
fstream istream
fstream limits
fstream new
fstream ostream
-fstream stdexcept
fstream string
fstream tuple
fstream typeinfo
@@ -265,11 +254,8 @@ functional cstddef
functional cstdint
functional cstring
functional initializer_list
-functional iosfwd
functional limits
-functional memory
functional new
-functional stdexcept
functional tuple
functional typeinfo
functional unordered_map
@@ -281,7 +267,6 @@ future cstdint
future cstdlib
future cstring
future initializer_list
-future iosfwd
future limits
future mutex
future new
@@ -320,7 +305,6 @@ iostream ostream
iostream streambuf
iostream version
istream cstddef
-istream iosfwd
istream ostream
istream version
iterator compare
@@ -346,7 +330,6 @@ list cstring
list initializer_list
list limits
list new
-list stdexcept
list tuple
list version
locale cctype
@@ -364,7 +347,6 @@ locale ios
locale iosfwd
locale limits
locale new
-locale stdexcept
locale streambuf
locale string
locale tuple
@@ -392,10 +374,8 @@ memory cstddef
memory cstdint
memory cstring
memory initializer_list
-memory iosfwd
memory limits
memory new
-memory stdexcept
memory tuple
memory typeinfo
memory version
@@ -404,14 +384,12 @@ memory_resource cstdint
memory_resource limits
memory_resource mutex
memory_resource new
-memory_resource stdexcept
memory_resource tuple
memory_resource version
mutex cerrno
mutex cstddef
mutex cstdint
mutex ctime
-mutex iosfwd
mutex limits
mutex new
mutex ratio
@@ -421,11 +399,9 @@ mutex tuple
mutex typeinfo
mutex version
new cstddef
-new cstdlib
new version
numbers version
numeric climits
-numeric cmath
numeric cstddef
numeric cstdint
numeric cstring
@@ -444,7 +420,6 @@ optional cstring
optional initializer_list
optional limits
optional new
-optional stdexcept
optional version
ostream bitset
ostream cerrno
@@ -453,11 +428,9 @@ ostream cstdint
ostream cstring
ostream initializer_list
ostream ios
-ostream iosfwd
ostream limits
ostream locale
ostream new
-ostream stdexcept
ostream streambuf
ostream string
ostream typeinfo
@@ -501,7 +474,6 @@ ranges compare
ranges cstddef
ranges cwchar
ranges initializer_list
-ranges iosfwd
ranges iterator
ranges limits
ranges new
@@ -523,7 +495,6 @@ regex cstring
regex cwchar
regex deque
regex initializer_list
-regex iosfwd
regex limits
regex new
regex stdexcept
@@ -551,7 +522,6 @@ set initializer_list
set limits
set new
set optional
-set stdexcept
set tuple
set version
shared_mutex cerrno
@@ -582,17 +552,14 @@ stack initializer_list
stack limits
stack new
stack version
-stdexcept iosfwd
stop_token atomic
stop_token cstddef
stop_token cstdint
stop_token cstring
stop_token ctime
-stop_token iosfwd
stop_token limits
stop_token ratio
stop_token version
-streambuf cstdint
streambuf ios
streambuf iosfwd
streambuf version
@@ -683,7 +650,6 @@ unordered_set initializer_list
unordered_set limits
unordered_set new
unordered_set optional
-unordered_set stdexcept
unordered_set tuple
unordered_set version
utility compare
diff --git a/libcxx/test/libcxx/transitive_includes/cxx26.csv b/libcxx/test/libcxx/transitive_includes/cxx26.csv
index 236dedd186c9268..aa6879026c90265 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx26.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx26.csv
@@ -62,12 +62,12 @@ bitset string_view
bitset version
ccomplex complex
charconv cerrno
-charconv cmath
charconv cstddef
charconv cstdint
charconv initializer_list
charconv limits
charconv new
+charconv version
chrono array
chrono cmath
chrono compare
@@ -99,10 +99,8 @@ codecvt cstdlib
codecvt cstring
codecvt cwchar
codecvt initializer_list
-codecvt iosfwd
codecvt limits
codecvt new
-codecvt stdexcept
codecvt string
codecvt tuple
codecvt typeinfo
@@ -113,9 +111,7 @@ compare cstdint
compare limits
compare version
complex cmath
-complex iosfwd
complex sstream
-complex stdexcept
complex version
concepts cstddef
concepts version
@@ -125,7 +121,6 @@ condition_variable cstddef
condition_variable cstdint
condition_variable cstring
condition_variable ctime
-condition_variable iosfwd
condition_variable limits
condition_variable new
condition_variable ratio
@@ -170,7 +165,6 @@ experimental/deque experimental/memory_resource
experimental/forward_list experimental/memory_resource
experimental/forward_list forward_list
experimental/iterator cstddef
-experimental/iterator iosfwd
experimental/iterator iterator
experimental/list experimental/memory_resource
experimental/list list
@@ -208,10 +202,8 @@ filesystem cstdint
filesystem cstring
filesystem ctime
filesystem iomanip
-filesystem iosfwd
filesystem limits
filesystem locale
-filesystem new
filesystem ratio
filesystem string
filesystem string_view
@@ -237,7 +229,6 @@ forward_list cstddef
forward_list initializer_list
forward_list limits
forward_list new
-forward_list stdexcept
forward_list tuple
forward_list version
fstream cctype
@@ -250,12 +241,10 @@ fstream cstring
fstream cwchar
fstream filesystem
fstream initializer_list
-fstream iosfwd
fstream istream
fstream limits
fstream new
fstream ostream
-fstream stdexcept
fstream string
fstream tuple
fstream typeinfo
@@ -265,11 +254,8 @@ functional cstddef
functional cstdint
functional cstring
functional initializer_list
-functional iosfwd
functional limits
-functional memory
functional new
-functional stdexcept
functional tuple
functional typeinfo
functional unordered_map
@@ -281,7 +267,6 @@ future cstdint
future cstdlib
future cstring
future initializer_list
-future iosfwd
future limits
future mutex
future new
@@ -320,7 +305,6 @@ iostream ostream
iostream streambuf
iostream version
istream cstddef
-istream iosfwd
istream ostream
istream version
iterator compare
@@ -346,7 +330,6 @@ list cstring
list initializer_list
list limits
list new
-list stdexcept
list tuple
list version
locale cctype
@@ -364,7 +347,6 @@ locale ios
locale iosfwd
locale limits
locale new
-locale stdexcept
locale streambuf
locale string
locale tuple
@@ -392,10 +374,8 @@ memory cstddef
memory cstdint
memory cstring
memory initializer_list
-memory iosfwd
memory limits
memory new
-memory stdexcept
memory tuple
memory typeinfo
memory version
@@ -404,14 +384,12 @@ memory_resource cstdint
memory_resource limits
memory_resource mutex
memory_resource new
-memory_resource stdexcept
memory_resource tuple
memory_resource version
mutex cerrno
mutex cstddef
mutex cstdint
mutex ctime
-mutex iosfwd
mutex limits
mutex new
mutex ratio
@@ -421,11 +399,9 @@ mutex tuple
mutex typeinfo
mutex version
new cstddef
-new cstdlib
new version
numbers version
numeric climits
-numeric cmath
numeric cstddef
numeric cstdint
numeric cstring
@@ -444,7 +420,6 @@ optional cstring
optional initializer_list
optional limits
optional new
-optional stdexcept
optional version
ostream bitset
ostream cerrno
@@ -453,11 +428,9 @@ ostream cstdint
ostream cstring
ostream initializer_list
ostream ios
-ostream iosfwd
ostream limits
ostream locale
ostream new
-ostream stdexcept
ostream streambuf
ostream string
ostream typeinfo
@@ -501,7 +474,6 @@ ranges compare
ranges cstddef
ranges cwchar
ranges initializer_list
-ranges iosfwd
ranges iterator
ranges limits
ranges new
@@ -523,7 +495,6 @@ regex cstring
regex cwchar
regex deque
regex initializer_list
-regex iosfwd
regex limits
regex new
regex stdexcept
@@ -551,7 +522,6 @@ set initializer_list
set limits
set new
set optional
-set stdexcept
set tuple
set version
shared_mutex cerrno
@@ -582,17 +552,14 @@ stack initializer_list
stack limits
stack new
stack version
-stdexcept iosfwd
stop_token atomic
stop_token cstddef
stop_token cstdint
stop_token cstring
stop_token ctime
-stop_token iosfwd
stop_token limits
stop_token ratio
stop_token version
-streambuf cstdint
streambuf ios
streambuf iosfwd
streambuf version
@@ -683,7 +650,6 @@ unordered_set initializer_list
unordered_set limits
unordered_set new
unordered_set optional
-unordered_set stdexcept
unordered_set tuple
unordered_set version
utility compare
diff --git a/libcxx/test/libcxx/utilities/function.objects/func.blocks.pass.cpp b/libcxx/test/libcxx/utilities/function.objects/func.blocks.pass.cpp
index b95b6ebb534a197..a917e9fe1f81e72 100644
--- a/libcxx/test/libcxx/utilities/function.objects/func.blocks.pass.cpp
+++ b/libcxx/test/libcxx/utilities/function.objects/func.blocks.pass.cpp
@@ -16,9 +16,10 @@
// ADDITIONAL_COMPILE_FLAGS: -fblocks
-#include <functional>
-#include <cstdlib>
#include <cassert>
+#include <cstdlib>
+#include <functional>
+#include <typeinfo>
#include <Block.h>
diff --git a/libcxx/test/std/ranges/range.factories/range.repeat.view/size.pass.cpp b/libcxx/test/std/ranges/range.factories/range.repeat.view/size.pass.cpp
index 097dc94b8658e1a..72531b059aa249f 100644
--- a/libcxx/test/std/ranges/range.factories/range.repeat.view/size.pass.cpp
+++ b/libcxx/test/std/ranges/range.factories/range.repeat.view/size.pass.cpp
@@ -10,11 +10,10 @@
// constexpr auto size() const requires (!same_as<Bound, unreachable_sentinel_t>);
-#include <ranges>
-#include <numeric>
-#include <concepts>
#include <cassert>
#include <iterator>
+#include <limits>
+#include <ranges>
template <class T>
concept has_size = requires(T&& view) {
diff --git a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
index c390e5904c5f408..ca01ed9058e17c3 100644
--- a/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
+++ b/libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.badcall/bad_function_call.pass.cpp
@@ -18,6 +18,7 @@
// bad_function_call();
// };
+#include <exception>
#include <functional>
#include <type_traits>
diff --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/types.h b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/types.h
index 7cd65231404fa68..67e989ed326194d 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/types.h
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/types.h
@@ -11,6 +11,7 @@
#include <cassert>
#include <cstddef>
+#include <exception>
#include "test_macros.h"
diff --git a/libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp b/libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp
index 64e65ac4d3c6211..1f388b44f954637 100644
--- a/libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp
+++ b/libcxx/test/std/utilities/variant/variant.variant/variant.swap/swap.pass.cpp
@@ -17,6 +17,7 @@
// void swap(variant& rhs) noexcept(see below)
#include <cassert>
+#include <cstdlib>
#include <string>
#include <type_traits>
#include <variant>
More information about the libcxx-commits
mailing list