[libcxx-commits] [libcxx] [libc++] Harmonize header inclusion for all sorts of subsetting (PR #202246)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 8 01:46:57 PDT 2026
https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/202246
>From 301e61fe01f5a30a2219670ea91ced8e4fa354d1 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 8 Jun 2026 10:05:59 +0800
Subject: [PATCH 1/5] [libc++] Cover support for header inclusion in all modes
We intend to allow standard library header to be included in modes where
they are not supposed to be provided, where the header should
effectively provide nothing.
This patch attempts to remove most uses of `lit_header_restrictions` in
libc++'s test suite, which should be sufficient for our intent.
The following tests are not modified:
- tests in `libcxx/test/libcxx-03` subdirectory,
- `clang_modules_include.gen.py`, and
- `mandatory_inclusions.gen.py`.
Co-authored-by: Connector Switch <c8ef at outlook.com>
---
libcxx/test/extensions/libcxx/libcpp_version.gen.py | 2 --
libcxx/test/extensions/libcxx/no_assert_include.gen.py | 2 --
libcxx/test/extensions/posix/xopen_source.gen.py | 2 --
libcxx/test/libcxx/clang_tidy.gen.py | 3 +--
libcxx/test/libcxx/system_reserved_names.gen.py | 2 --
libcxx/test/libcxx/transitive_includes.gen.py | 6 +-----
libcxx/test/libcxx/transitive_includes/cxx03.csv | 5 +++++
libcxx/test/libcxx/transitive_includes/cxx11.csv | 5 +++++
libcxx/test/libcxx/transitive_includes/cxx14.csv | 5 +++++
libcxx/test/libcxx/transitive_includes/cxx17.csv | 5 +++++
libcxx/test/std/double_include.gen.py | 2 --
libcxx/test/std/header_inclusions.gen.py | 2 --
12 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/libcxx/test/extensions/libcxx/libcpp_version.gen.py b/libcxx/test/extensions/libcxx/libcpp_version.gen.py
index ebeab777c934f..31b1760f864ed 100644
--- a/libcxx/test/extensions/libcxx/libcpp_version.gen.py
+++ b/libcxx/test/extensions/libcxx/libcpp_version.gen.py
@@ -13,7 +13,6 @@
import sys
sys.path.append(sys.argv[1])
from libcxx.header_information import (
- lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)
@@ -22,7 +21,6 @@
print(
f"""\
//--- {header}.compile.pass.cpp
-{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}
#include <{header}>
diff --git a/libcxx/test/extensions/libcxx/no_assert_include.gen.py b/libcxx/test/extensions/libcxx/no_assert_include.gen.py
index e0dbc3d815f31..d206ac5cd459a 100644
--- a/libcxx/test/extensions/libcxx/no_assert_include.gen.py
+++ b/libcxx/test/extensions/libcxx/no_assert_include.gen.py
@@ -15,7 +15,6 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
- lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)
@@ -27,7 +26,6 @@
print(
f"""\
//--- {header}.compile.pass.cpp
-{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}
#include <{header}>
diff --git a/libcxx/test/extensions/posix/xopen_source.gen.py b/libcxx/test/extensions/posix/xopen_source.gen.py
index e98197c8ed21c..99e0b0b7c7d1f 100644
--- a/libcxx/test/extensions/posix/xopen_source.gen.py
+++ b/libcxx/test/extensions/posix/xopen_source.gen.py
@@ -26,7 +26,6 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
- lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)
@@ -40,7 +39,6 @@
print(
f"""\
//--- {header}.xopen_source_{version}.compile.pass.cpp
-{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}
// ADDITIONAL_COMPILE_FLAGS: -D_XOPEN_SOURCE={version}
diff --git a/libcxx/test/libcxx/clang_tidy.gen.py b/libcxx/test/libcxx/clang_tidy.gen.py
index 48527e3617f90..10dfe053f5ccb 100644
--- a/libcxx/test/libcxx/clang_tidy.gen.py
+++ b/libcxx/test/libcxx/clang_tidy.gen.py
@@ -18,12 +18,11 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, lit_header_undeprecations, public_headers
+from libcxx.header_information import lit_header_undeprecations, public_headers
for header in public_headers:
print(f"""\
//--- {header}.sh.cpp
-{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}
// TODO: run clang-tidy with modules enabled once they are supported
diff --git a/libcxx/test/libcxx/system_reserved_names.gen.py b/libcxx/test/libcxx/system_reserved_names.gen.py
index bb0bbeb1caf82..aaaa385409be4 100644
--- a/libcxx/test/libcxx/system_reserved_names.gen.py
+++ b/libcxx/test/libcxx/system_reserved_names.gen.py
@@ -17,7 +17,6 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
- lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)
@@ -26,7 +25,6 @@
print(
f"""\
//--- {header}.compile.pass.cpp
-{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}
// This is required to detect the platform we're building for below.
diff --git a/libcxx/test/libcxx/transitive_includes.gen.py b/libcxx/test/libcxx/transitive_includes.gen.py
index 1ff80af1b5e1d..c73a37dea44c7 100644
--- a/libcxx/test/libcxx/transitive_includes.gen.py
+++ b/libcxx/test/libcxx/transitive_includes.gen.py
@@ -21,7 +21,7 @@
import sys
sys.path.append(sys.argv[1])
-from libcxx.header_information import lit_header_restrictions, public_headers
+from libcxx.header_information import public_headers
import re
@@ -68,10 +68,6 @@
print(
f"""\
//--- {header}.sh.cpp
-{lit_header_restrictions.get(header, '')}
-
-// TODO: Fix this test to make it work with localization or wide characters disabled
-// UNSUPPORTED: no-localization, no-wide-characters, no-threads, no-filesystem, libcpp-has-no-experimental-tzdb
// When built with modules, this test doesn't work because --trace-includes doesn't
// report the stack of includes correctly.
diff --git a/libcxx/test/libcxx/transitive_includes/cxx03.csv b/libcxx/test/libcxx/transitive_includes/cxx03.csv
index c0031543e47bc..920a6145a02b8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx03.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx03.csv
@@ -122,15 +122,19 @@ atomic ratio
atomic type_traits
atomic version
barrier atomic
+barrier cctype
barrier climits
barrier cmath
barrier compare
barrier concepts
barrier cstddef
barrier cstdint
+barrier cstdio
barrier cstdlib
barrier cstring
barrier ctime
+barrier cwchar
+barrier cwctype
barrier exception
barrier initializer_list
barrier iosfwd
@@ -2032,6 +2036,7 @@ stdexcept new
stdexcept type_traits
stdexcept typeinfo
stdexcept version
+stop_token cstddef
stop_token iosfwd
stop_token version
streambuf algorithm
diff --git a/libcxx/test/libcxx/transitive_includes/cxx11.csv b/libcxx/test/libcxx/transitive_includes/cxx11.csv
index c0031543e47bc..920a6145a02b8 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx11.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx11.csv
@@ -122,15 +122,19 @@ atomic ratio
atomic type_traits
atomic version
barrier atomic
+barrier cctype
barrier climits
barrier cmath
barrier compare
barrier concepts
barrier cstddef
barrier cstdint
+barrier cstdio
barrier cstdlib
barrier cstring
barrier ctime
+barrier cwchar
+barrier cwctype
barrier exception
barrier initializer_list
barrier iosfwd
@@ -2032,6 +2036,7 @@ stdexcept new
stdexcept type_traits
stdexcept typeinfo
stdexcept version
+stop_token cstddef
stop_token iosfwd
stop_token version
streambuf algorithm
diff --git a/libcxx/test/libcxx/transitive_includes/cxx14.csv b/libcxx/test/libcxx/transitive_includes/cxx14.csv
index c2eb5b44e8d7a..cfcf7bc7c4c19 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx14.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx14.csv
@@ -125,15 +125,19 @@ atomic ratio
atomic type_traits
atomic version
barrier atomic
+barrier cctype
barrier climits
barrier cmath
barrier compare
barrier concepts
barrier cstddef
barrier cstdint
+barrier cstdio
barrier cstdlib
barrier cstring
barrier ctime
+barrier cwchar
+barrier cwctype
barrier exception
barrier initializer_list
barrier iosfwd
@@ -2072,6 +2076,7 @@ stdexcept new
stdexcept type_traits
stdexcept typeinfo
stdexcept version
+stop_token cstddef
stop_token iosfwd
stop_token version
streambuf algorithm
diff --git a/libcxx/test/libcxx/transitive_includes/cxx17.csv b/libcxx/test/libcxx/transitive_includes/cxx17.csv
index 332cb62f35b5f..534776e6f0526 100644
--- a/libcxx/test/libcxx/transitive_includes/cxx17.csv
+++ b/libcxx/test/libcxx/transitive_includes/cxx17.csv
@@ -122,15 +122,19 @@ atomic ratio
atomic type_traits
atomic version
barrier atomic
+barrier cctype
barrier climits
barrier cmath
barrier compare
barrier concepts
barrier cstddef
barrier cstdint
+barrier cstdio
barrier cstdlib
barrier cstring
barrier ctime
+barrier cwchar
+barrier cwctype
barrier exception
barrier initializer_list
barrier iosfwd
@@ -2085,6 +2089,7 @@ stdexcept new
stdexcept type_traits
stdexcept typeinfo
stdexcept version
+stop_token cstddef
stop_token iosfwd
stop_token version
streambuf algorithm
diff --git a/libcxx/test/std/double_include.gen.py b/libcxx/test/std/double_include.gen.py
index f019710be55b2..21ca2faab80da 100644
--- a/libcxx/test/std/double_include.gen.py
+++ b/libcxx/test/std/double_include.gen.py
@@ -17,7 +17,6 @@
import sys
sys.path.append(sys.argv[1])
from libcxx.header_information import (
- lit_header_restrictions,
lit_header_undeprecations,
public_headers,
)
@@ -26,7 +25,6 @@
print(
f"""\
//--- {header}.sh.cpp
-{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}
// RUN: %{{cxx}} -c %s -o %t.first.o %{{flags}} %{{compile_flags}}
diff --git a/libcxx/test/std/header_inclusions.gen.py b/libcxx/test/std/header_inclusions.gen.py
index cebff94fdd1ab..45b397587a9c6 100644
--- a/libcxx/test/std/header_inclusions.gen.py
+++ b/libcxx/test/std/header_inclusions.gen.py
@@ -21,7 +21,6 @@
sys.path.append(sys.argv[1])
from libcxx.header_information import (
- lit_header_restrictions,
lit_header_undeprecations,
public_headers,
mandatory_inclusions,
@@ -51,7 +50,6 @@
print(
f"""\
//--- {header}.compile.pass.cpp
-{lit_header_restrictions.get(header, '')}
{lit_header_undeprecations.get(header, '')}
#include <{header}>
>From 29b7de854c543ded7052b4cbe8d67c7c085eeb19 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 8 Jun 2026 13:24:18 +0800
Subject: [PATCH 2/5] Guard contents for `istream_view.h`
---
libcxx/include/__ranges/istream_view.h | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/libcxx/include/__ranges/istream_view.h b/libcxx/include/__ranges/istream_view.h
index ab05cb6ef1fe3..9050f1f49bffb 100644
--- a/libcxx/include/__ranges/istream_view.h
+++ b/libcxx/include/__ranges/istream_view.h
@@ -24,11 +24,13 @@
#include <__type_traits/remove_cvref.h>
#include <__utility/forward.h>
-#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-#endif
+#if _LIBCPP_HAS_LOCALIZATION
-#if _LIBCPP_STD_VER >= 20
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
+
+# if _LIBCPP_STD_VER >= 20
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -99,10 +101,10 @@ class basic_istream_view<_Val, _CharT, _Traits>::__iterator {
template <class _Val>
using istream_view = basic_istream_view<_Val, char>;
-# if _LIBCPP_HAS_WIDE_CHARACTERS
+# if _LIBCPP_HAS_WIDE_CHARACTERS
template <class _Val>
using wistream_view = basic_istream_view<_Val, wchar_t>;
-# endif
+# endif
namespace views {
namespace __istream {
@@ -136,6 +138,8 @@ inline constexpr auto istream = __istream::__fn<_Tp>{};
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER >= 20
+# endif // _LIBCPP_STD_VER >= 20
+
+#endif // _LIBCPP_HAS_LOCALIZATION
#endif // _LIBCPP___RANGES_ISTREAM_VIEW_H
>From 487046aae79989925a77a811607c7c825163765b Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 8 Jun 2026 13:25:24 +0800
Subject: [PATCH 3/5] Avoid guarding includes with `_LIBCXX_HAS_*` (mostly)
---
libcxx/include/__algorithm/find.h | 5 +-
.../__algorithm/lexicographical_compare.h | 5 +-
libcxx/include/__algorithm/pstl.h | 23 +++--
libcxx/include/__chrono/exception.h | 20 ++--
libcxx/include/__chrono/formatter.h | 93 +++++++++----------
libcxx/include/__chrono/gps_clock.h | 14 +--
libcxx/include/__chrono/leap_second.h | 20 ++--
libcxx/include/__chrono/local_info.h | 6 +-
libcxx/include/__chrono/ostream.h | 53 ++++++-----
.../include/__chrono/parser_std_format_spec.h | 13 ++-
libcxx/include/__chrono/tai_clock.h | 14 +--
libcxx/include/__chrono/time_zone.h | 24 ++---
libcxx/include/__chrono/time_zone_link.h | 12 +--
libcxx/include/__chrono/tzdb.h | 22 ++---
libcxx/include/__chrono/tzdb_list.h | 14 +--
libcxx/include/__chrono/utc_clock.h | 18 ++--
libcxx/include/__chrono/zoned_time.h | 34 +++----
libcxx/include/__filesystem/path.h | 5 +-
libcxx/include/__format/format_context.h | 7 +-
libcxx/include/__format/format_functions.h | 5 +-
.../__format/formatter_floating_point.h | 5 +-
libcxx/include/__format/formatter_integral.h | 5 +-
libcxx/include/__locale | 43 +++++----
.../locale_base_api/bsd_locale_fallbacks.h | 5 +-
libcxx/include/__locale_dir/pad_and_output.h | 7 +-
libcxx/include/__locale_dir/support/aix.h | 2 +-
libcxx/include/__locale_dir/support/linux.h | 2 +-
libcxx/include/__locale_dir/support/newlib.h | 2 +-
.../support/no_locale/characters.h | 6 +-
.../support/no_locale/conversions.h | 4 +-
libcxx/include/__numeric/pstl.h | 25 +++--
libcxx/include/__ostream/basic_ostream.h | 39 ++++----
libcxx/include/__ostream/print.h | 15 ++-
.../__ostream/put_character_sequence.h | 11 +--
libcxx/include/__pstl/backend.h | 4 +-
libcxx/include/__pstl/backend_fwd.h | 4 +-
libcxx/include/__pstl/dispatch.h | 4 +-
libcxx/include/__pstl/handle_exception.h | 4 +-
libcxx/include/__string/char_traits.h | 5 +-
libcxx/include/__thread/thread.h | 5 +-
.../include/__thread/timed_backoff_policy.h | 5 +-
libcxx/include/barrier | 19 ++--
libcxx/include/chrono | 38 +++-----
libcxx/include/codecvt | 5 +-
libcxx/include/complex | 5 +-
libcxx/include/cwchar | 36 +++----
libcxx/include/cwctype | 20 ++--
libcxx/include/format | 4 +-
libcxx/include/fstream | 37 ++++----
libcxx/include/future | 89 +++++++++---------
libcxx/include/iomanip | 15 ++-
libcxx/include/ios | 23 +++--
libcxx/include/istream | 31 +++----
libcxx/include/latch | 15 ++-
libcxx/include/locale | 19 ++--
libcxx/include/ostream | 14 ++-
libcxx/include/ranges | 4 +-
libcxx/include/regex | 43 +++++----
libcxx/include/semaphore | 21 ++---
libcxx/include/shared_mutex | 27 +++---
libcxx/include/sstream | 21 ++---
libcxx/include/stop_token | 15 ++-
libcxx/include/streambuf | 21 ++---
libcxx/include/string | 7 +-
libcxx/include/strstream | 9 +-
libcxx/include/syncstream | 20 ++--
libcxx/include/thread | 26 +++---
libcxx/include/vector | 4 +-
68 files changed, 559 insertions(+), 638 deletions(-)
diff --git a/libcxx/include/__algorithm/find.h b/libcxx/include/__algorithm/find.h
index f677fb2c7392d..91b9bf8d64b23 100644
--- a/libcxx/include/__algorithm/find.h
+++ b/libcxx/include/__algorithm/find.h
@@ -30,12 +30,9 @@
#include <__type_traits/is_integral.h>
#include <__type_traits/is_signed.h>
#include <__utility/move.h>
+#include <cwchar>
#include <limits>
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__algorithm/lexicographical_compare.h b/libcxx/include/__algorithm/lexicographical_compare.h
index a12add69d4d2c..c972023c6f53c 100644
--- a/libcxx/include/__algorithm/lexicographical_compare.h
+++ b/libcxx/include/__algorithm/lexicographical_compare.h
@@ -25,10 +25,7 @@
#include <__type_traits/is_integral.h>
#include <__type_traits/is_trivially_lexicographically_comparable.h>
#include <__type_traits/is_volatile.h>
-
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
-#endif
+#include <cwchar>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__algorithm/pstl.h b/libcxx/include/__algorithm/pstl.h
index 10625ea3f8e3d..efca44dd25f4e 100644
--- a/libcxx/include/__algorithm/pstl.h
+++ b/libcxx/include/__algorithm/pstl.h
@@ -10,6 +10,17 @@
#define _LIBCPP___ALGORITHM_PSTL_H
#include <__config>
+#include <__functional/operations.h>
+#include <__iterator/cpp17_iterator_concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__pstl/backend.h>
+#include <__pstl/dispatch.h>
+#include <__pstl/handle_exception.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_execution_policy.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,18 +31,6 @@ _LIBCPP_PUSH_MACROS
#if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
-# include <__functional/operations.h>
-# include <__iterator/cpp17_iterator_concepts.h>
-# include <__iterator/iterator_traits.h>
-# include <__pstl/backend.h>
-# include <__pstl/dispatch.h>
-# include <__pstl/handle_exception.h>
-# include <__type_traits/enable_if.h>
-# include <__type_traits/is_execution_policy.h>
-# include <__type_traits/remove_cvref.h>
-# include <__utility/forward.h>
-# include <__utility/move.h>
-
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ExecutionPolicy,
diff --git a/libcxx/include/__chrono/exception.h b/libcxx/include/__chrono/exception.h
index 27fbfd6b57a2b..cf3a25a7da94d 100644
--- a/libcxx/include/__chrono/exception.h
+++ b/libcxx/include/__chrono/exception.h
@@ -12,20 +12,20 @@
#ifndef _LIBCPP___CHRONO_EXCEPTION_H
#define _LIBCPP___CHRONO_EXCEPTION_H
+#include <__chrono/calendar.h>
+#include <__chrono/local_info.h>
+#include <__chrono/time_point.h>
+#include <__config>
+#include <__configuration/availability.h>
+#include <__verbose_abort>
+#include <format>
+#include <stdexcept>
+#include <string>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__chrono/calendar.h>
-# include <__chrono/local_info.h>
-# include <__chrono/time_point.h>
-# include <__config>
-# include <__configuration/availability.h>
-# include <__verbose_abort>
-# include <format>
-# include <stdexcept>
-# include <string>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/formatter.h b/libcxx/include/__chrono/formatter.h
index 49758397f6185..f103e514a01a4 100644
--- a/libcxx/include/__chrono/formatter.h
+++ b/libcxx/include/__chrono/formatter.h
@@ -10,57 +10,56 @@
#ifndef _LIBCPP___CHRONO_FORMATTER_H
#define _LIBCPP___CHRONO_FORMATTER_H
+#include <__algorithm/ranges_copy.h>
+#include <__chrono/calendar.h>
+#include <__chrono/concepts.h>
+#include <__chrono/convert_to_tm.h>
+#include <__chrono/day.h>
+#include <__chrono/duration.h>
+#include <__chrono/file_clock.h>
+#include <__chrono/gps_clock.h>
+#include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
+#include <__chrono/month.h>
+#include <__chrono/month_weekday.h>
+#include <__chrono/monthday.h>
+#include <__chrono/ostream.h>
+#include <__chrono/parser_std_format_spec.h>
+#include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/tai_clock.h>
+#include <__chrono/time_point.h>
+#include <__chrono/utc_clock.h>
+#include <__chrono/weekday.h>
+#include <__chrono/year.h>
+#include <__chrono/year_month.h>
+#include <__chrono/year_month_day.h>
+#include <__chrono/year_month_weekday.h>
+#include <__chrono/zoned_time.h>
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_error.h>
+#include <__format/format_functions.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/parser_std_format_spec.h>
+#include <__format/write_escaped.h>
+#include <__iterator/istreambuf_iterator.h>
+#include <__iterator/ostreambuf_iterator.h>
+#include <__locale_dir/time.h>
+#include <__memory/addressof.h>
+#include <__type_traits/is_specialization.h>
+#include <cmath>
+#include <ctime>
+#include <limits>
+#include <sstream>
+#include <string_view>
#if _LIBCPP_HAS_LOCALIZATION
-# include <__algorithm/ranges_copy.h>
-# include <__chrono/calendar.h>
-# include <__chrono/concepts.h>
-# include <__chrono/convert_to_tm.h>
-# include <__chrono/day.h>
-# include <__chrono/duration.h>
-# include <__chrono/file_clock.h>
-# include <__chrono/gps_clock.h>
-# include <__chrono/hh_mm_ss.h>
-# include <__chrono/local_info.h>
-# include <__chrono/month.h>
-# include <__chrono/month_weekday.h>
-# include <__chrono/monthday.h>
-# include <__chrono/ostream.h>
-# include <__chrono/parser_std_format_spec.h>
-# include <__chrono/statically_widen.h>
-# include <__chrono/sys_info.h>
-# include <__chrono/system_clock.h>
-# include <__chrono/tai_clock.h>
-# include <__chrono/time_point.h>
-# include <__chrono/utc_clock.h>
-# include <__chrono/weekday.h>
-# include <__chrono/year.h>
-# include <__chrono/year_month.h>
-# include <__chrono/year_month_day.h>
-# include <__chrono/year_month_weekday.h>
-# include <__chrono/zoned_time.h>
-# include <__concepts/arithmetic.h>
-# include <__concepts/same_as.h>
-# include <__format/concepts.h>
-# include <__format/format_error.h>
-# include <__format/format_functions.h>
-# include <__format/format_parse_context.h>
-# include <__format/formatter.h>
-# include <__format/parser_std_format_spec.h>
-# include <__format/write_escaped.h>
-# include <__iterator/istreambuf_iterator.h>
-# include <__iterator/ostreambuf_iterator.h>
-# include <__locale_dir/time.h>
-# include <__memory/addressof.h>
-# include <__type_traits/is_specialization.h>
-# include <cmath>
-# include <ctime>
-# include <limits>
-# include <sstream>
-# include <string_view>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/gps_clock.h b/libcxx/include/__chrono/gps_clock.h
index 2e220cab946e3..bf88f1135fd79 100644
--- a/libcxx/include/__chrono/gps_clock.h
+++ b/libcxx/include/__chrono/gps_clock.h
@@ -10,17 +10,17 @@
#ifndef _LIBCPP___CHRONO_GPS_CLOCK_H
#define _LIBCPP___CHRONO_GPS_CLOCK_H
+#include <__assert>
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
+#include <__chrono/utc_clock.h>
+#include <__config>
+#include <__type_traits/common_type.h>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__assert>
-# include <__chrono/duration.h>
-# include <__chrono/time_point.h>
-# include <__chrono/utc_clock.h>
-# include <__config>
-# include <__type_traits/common_type.h>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/leap_second.h b/libcxx/include/__chrono/leap_second.h
index 9e9df6b5950ae..0f3d279c77c41 100644
--- a/libcxx/include/__chrono/leap_second.h
+++ b/libcxx/include/__chrono/leap_second.h
@@ -12,20 +12,20 @@
#ifndef _LIBCPP___CHRONO_LEAP_SECOND_H
#define _LIBCPP___CHRONO_LEAP_SECOND_H
+#include <__chrono/duration.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__compare/ordering.h>
+#include <__compare/three_way_comparable.h>
+#include <__config>
+#include <__cstddef/size_t.h>
+#include <__functional/hash.h>
+#include <__utility/private_constructor_tag.h>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__chrono/duration.h>
-# include <__chrono/system_clock.h>
-# include <__chrono/time_point.h>
-# include <__compare/ordering.h>
-# include <__compare/three_way_comparable.h>
-# include <__config>
-# include <__cstddef/size_t.h>
-# include <__functional/hash.h>
-# include <__utility/private_constructor_tag.h>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/local_info.h b/libcxx/include/__chrono/local_info.h
index 31cf77761d6ae..9d13fdac2c372 100644
--- a/libcxx/include/__chrono/local_info.h
+++ b/libcxx/include/__chrono/local_info.h
@@ -12,13 +12,13 @@
#ifndef _LIBCPP___CHRONO_LOCAL_INFO_H
#define _LIBCPP___CHRONO_LOCAL_INFO_H
+#include <__chrono/sys_info.h>
+#include <__config>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__chrono/sys_info.h>
-# include <__config>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/ostream.h b/libcxx/include/__chrono/ostream.h
index 7a01b186780cb..755774828d0e1 100644
--- a/libcxx/include/__chrono/ostream.h
+++ b/libcxx/include/__chrono/ostream.h
@@ -10,37 +10,36 @@
#ifndef _LIBCPP___CHRONO_OSTREAM_H
#define _LIBCPP___CHRONO_OSTREAM_H
+#include <__chrono/calendar.h>
+#include <__chrono/day.h>
+#include <__chrono/duration.h>
+#include <__chrono/file_clock.h>
+#include <__chrono/gps_clock.h>
+#include <__chrono/hh_mm_ss.h>
+#include <__chrono/local_info.h>
+#include <__chrono/month.h>
+#include <__chrono/month_weekday.h>
+#include <__chrono/monthday.h>
+#include <__chrono/statically_widen.h>
+#include <__chrono/sys_info.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/tai_clock.h>
+#include <__chrono/utc_clock.h>
+#include <__chrono/weekday.h>
+#include <__chrono/year.h>
+#include <__chrono/year_month.h>
+#include <__chrono/year_month_day.h>
+#include <__chrono/year_month_weekday.h>
+#include <__chrono/zoned_time.h>
+#include <__concepts/same_as.h>
#include <__config>
+#include <__format/format_functions.h>
+#include <__fwd/ostream.h>
+#include <ratio>
+#include <sstream>
#if _LIBCPP_HAS_LOCALIZATION
-# include <__chrono/calendar.h>
-# include <__chrono/day.h>
-# include <__chrono/duration.h>
-# include <__chrono/file_clock.h>
-# include <__chrono/gps_clock.h>
-# include <__chrono/hh_mm_ss.h>
-# include <__chrono/local_info.h>
-# include <__chrono/month.h>
-# include <__chrono/month_weekday.h>
-# include <__chrono/monthday.h>
-# include <__chrono/statically_widen.h>
-# include <__chrono/sys_info.h>
-# include <__chrono/system_clock.h>
-# include <__chrono/tai_clock.h>
-# include <__chrono/utc_clock.h>
-# include <__chrono/weekday.h>
-# include <__chrono/year.h>
-# include <__chrono/year_month.h>
-# include <__chrono/year_month_day.h>
-# include <__chrono/year_month_weekday.h>
-# include <__chrono/zoned_time.h>
-# include <__concepts/same_as.h>
-# include <__format/format_functions.h>
-# include <__fwd/ostream.h>
-# include <ratio>
-# include <sstream>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/parser_std_format_spec.h b/libcxx/include/__chrono/parser_std_format_spec.h
index 8ecc19f3c7821..18fe70c5f6ef3 100644
--- a/libcxx/include/__chrono/parser_std_format_spec.h
+++ b/libcxx/include/__chrono/parser_std_format_spec.h
@@ -11,16 +11,15 @@
#define _LIBCPP___CHRONO_PARSER_STD_FORMAT_SPEC_H
#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter_string.h>
+#include <__format/parser_std_format_spec.h>
+#include <string_view>
#if _LIBCPP_HAS_LOCALIZATION
-# include <__format/concepts.h>
-# include <__format/format_error.h>
-# include <__format/format_parse_context.h>
-# include <__format/formatter_string.h>
-# include <__format/parser_std_format_spec.h>
-# include <string_view>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/tai_clock.h b/libcxx/include/__chrono/tai_clock.h
index 14c8b70a94af5..4cedeb405fe1e 100644
--- a/libcxx/include/__chrono/tai_clock.h
+++ b/libcxx/include/__chrono/tai_clock.h
@@ -10,17 +10,17 @@
#ifndef _LIBCPP___CHRONO_TAI_CLOCK_H
#define _LIBCPP___CHRONO_TAI_CLOCK_H
+#include <__assert>
+#include <__chrono/duration.h>
+#include <__chrono/time_point.h>
+#include <__chrono/utc_clock.h>
+#include <__config>
+#include <__type_traits/common_type.h>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__assert>
-# include <__chrono/duration.h>
-# include <__chrono/time_point.h>
-# include <__chrono/utc_clock.h>
-# include <__config>
-# include <__type_traits/common_type.h>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/time_zone.h b/libcxx/include/__chrono/time_zone.h
index 20f3297f772b9..4aac7dcc9c66e 100644
--- a/libcxx/include/__chrono/time_zone.h
+++ b/libcxx/include/__chrono/time_zone.h
@@ -12,22 +12,22 @@
#ifndef _LIBCPP___CHRONO_TIME_ZONE_H
#define _LIBCPP___CHRONO_TIME_ZONE_H
+#include <__chrono/calendar.h>
+#include <__chrono/duration.h>
+#include <__chrono/exception.h>
+#include <__chrono/local_info.h>
+#include <__chrono/sys_info.h>
+#include <__chrono/system_clock.h>
+#include <__compare/strong_order.h>
+#include <__config>
+#include <__memory/unique_ptr.h>
+#include <__type_traits/common_type.h>
+#include <string_view>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__chrono/calendar.h>
-# include <__chrono/duration.h>
-# include <__chrono/exception.h>
-# include <__chrono/local_info.h>
-# include <__chrono/sys_info.h>
-# include <__chrono/system_clock.h>
-# include <__compare/strong_order.h>
-# include <__config>
-# include <__memory/unique_ptr.h>
-# include <__type_traits/common_type.h>
-# include <string_view>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/time_zone_link.h b/libcxx/include/__chrono/time_zone_link.h
index cae40b07c2ca6..24b76dfc1998d 100644
--- a/libcxx/include/__chrono/time_zone_link.h
+++ b/libcxx/include/__chrono/time_zone_link.h
@@ -12,16 +12,16 @@
#ifndef _LIBCPP___CHRONO_TIME_ZONE_LINK_H
#define _LIBCPP___CHRONO_TIME_ZONE_LINK_H
+#include <__compare/strong_order.h>
+#include <__config>
+#include <__utility/private_constructor_tag.h>
+#include <string>
+#include <string_view>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__compare/strong_order.h>
-# include <__config>
-# include <__utility/private_constructor_tag.h>
-# include <string>
-# include <string_view>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/tzdb.h b/libcxx/include/__chrono/tzdb.h
index 2fa04604b91f7..d08920d220c55 100644
--- a/libcxx/include/__chrono/tzdb.h
+++ b/libcxx/include/__chrono/tzdb.h
@@ -12,21 +12,21 @@
#ifndef _LIBCPP___CHRONO_TZDB_H
#define _LIBCPP___CHRONO_TZDB_H
+#include <__algorithm/ranges_lower_bound.h>
+#include <__chrono/leap_second.h>
+#include <__chrono/time_zone.h>
+#include <__chrono/time_zone_link.h>
+#include <__config>
+#include <__memory/addressof.h>
+#include <__vector/vector.h>
+#include <stdexcept>
+#include <string>
+#include <string_view>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__algorithm/ranges_lower_bound.h>
-# include <__chrono/leap_second.h>
-# include <__chrono/time_zone.h>
-# include <__chrono/time_zone_link.h>
-# include <__config>
-# include <__memory/addressof.h>
-# include <__vector/vector.h>
-# include <stdexcept>
-# include <string>
-# include <string_view>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/tzdb_list.h b/libcxx/include/__chrono/tzdb_list.h
index 997599ac74964..649cbdd86b2f9 100644
--- a/libcxx/include/__chrono/tzdb_list.h
+++ b/libcxx/include/__chrono/tzdb_list.h
@@ -12,17 +12,17 @@
#ifndef _LIBCPP___CHRONO_TZDB_LIST_H
#define _LIBCPP___CHRONO_TZDB_LIST_H
+#include <__chrono/time_zone.h>
+#include <__chrono/tzdb.h>
+#include <__config>
+#include <__fwd/string.h>
+#include <forward_list>
+#include <string_view>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__chrono/time_zone.h>
-# include <__chrono/tzdb.h>
-# include <__config>
-# include <__fwd/string.h>
-# include <forward_list>
-# include <string_view>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/utc_clock.h b/libcxx/include/__chrono/utc_clock.h
index 2207b89c92c59..76bf2025a8363 100644
--- a/libcxx/include/__chrono/utc_clock.h
+++ b/libcxx/include/__chrono/utc_clock.h
@@ -10,19 +10,19 @@
#ifndef _LIBCPP___CHRONO_UTC_CLOCK_H
#define _LIBCPP___CHRONO_UTC_CLOCK_H
+#include <__chrono/duration.h>
+#include <__chrono/leap_second.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_point.h>
+#include <__chrono/tzdb.h>
+#include <__chrono/tzdb_list.h>
+#include <__config>
+#include <__type_traits/common_type.h>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__chrono/duration.h>
-# include <__chrono/leap_second.h>
-# include <__chrono/system_clock.h>
-# include <__chrono/time_point.h>
-# include <__chrono/tzdb.h>
-# include <__chrono/tzdb_list.h>
-# include <__config>
-# include <__type_traits/common_type.h>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__chrono/zoned_time.h b/libcxx/include/__chrono/zoned_time.h
index e63528e57d1cc..16ba18291d5d2 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -12,27 +12,27 @@
#ifndef _LIBCPP___CHRONO_ZONED_TIME_H
#define _LIBCPP___CHRONO_ZONED_TIME_H
+#include <__chrono/calendar.h>
+#include <__chrono/duration.h>
+#include <__chrono/sys_info.h>
+#include <__chrono/system_clock.h>
+#include <__chrono/time_zone.h>
+#include <__chrono/tzdb_list.h>
+#include <__concepts/constructible.h>
+#include <__config>
+#include <__cstddef/size_t.h>
+#include <__functional/hash.h>
+#include <__type_traits/common_type.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/declval.h>
+#include <__utility/move.h>
+#include <string_view>
#include <version>
+
// Enable the contents of the header only when libc++ was built with experimental features enabled.
#if _LIBCPP_HAS_EXPERIMENTAL_TZDB
-# include <__chrono/calendar.h>
-# include <__chrono/duration.h>
-# include <__chrono/sys_info.h>
-# include <__chrono/system_clock.h>
-# include <__chrono/time_zone.h>
-# include <__chrono/tzdb_list.h>
-# include <__concepts/constructible.h>
-# include <__config>
-# include <__cstddef/size_t.h>
-# include <__functional/hash.h>
-# include <__type_traits/common_type.h>
-# include <__type_traits/conditional.h>
-# include <__type_traits/remove_cvref.h>
-# include <__utility/declval.h>
-# include <__utility/move.h>
-# include <string_view>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index a63c4ee611ebf..ad0c6b478f87a 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -25,13 +25,10 @@
#include <__type_traits/remove_pointer.h>
#include <__type_traits/void_t.h>
#include <__utility/move.h>
+#include <iomanip> // for quoted
#include <string>
#include <string_view>
-#if _LIBCPP_HAS_LOCALIZATION
-# include <iomanip> // for quoted
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h
index cf3131b80e52f..ae49b1257f1e9 100644
--- a/libcxx/include/__format/format_context.h
+++ b/libcxx/include/__format/format_context.h
@@ -20,14 +20,11 @@
#include <__fwd/format.h>
#include <__iterator/back_insert_iterator.h>
#include <__iterator/concepts.h>
+#include <__locale>
#include <__memory/addressof.h>
#include <__utility/move.h>
#include <__variant/monostate.h>
-
-#if _LIBCPP_HAS_LOCALIZATION
-# include <__locale>
-# include <optional>
-#endif
+#include <optional>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
index b58e487d7511e..61ae92bbf2132 100644
--- a/libcxx/include/__format/format_functions.h
+++ b/libcxx/include/__format/format_functions.h
@@ -36,16 +36,13 @@
#include <__iterator/concepts.h>
#include <__iterator/incrementable_traits.h>
#include <__iterator/iterator_traits.h> // iter_value_t
+#include <__locale>
#include <__variant/monostate.h>
#include <array>
#include <optional>
#include <string>
#include <string_view>
-#if _LIBCPP_HAS_LOCALIZATION
-# include <__locale>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__format/formatter_floating_point.h b/libcxx/include/__format/formatter_floating_point.h
index f4de8b927651a..9a1d00b9d3116 100644
--- a/libcxx/include/__format/formatter_floating_point.h
+++ b/libcxx/include/__format/formatter_floating_point.h
@@ -32,6 +32,7 @@
#include <__format/formatter_output.h>
#include <__format/parser_std_format_spec.h>
#include <__iterator/concepts.h>
+#include <__locale>
#include <__math/traits.h>
#include <__memory/allocator.h>
#include <__system_error/errc.h>
@@ -39,10 +40,6 @@
#include <__utility/move.h>
#include <__utility/unreachable.h>
-#if _LIBCPP_HAS_LOCALIZATION
-# include <__locale>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__format/formatter_integral.h b/libcxx/include/__format/formatter_integral.h
index 85f509fad4f5d..3028eaa808a02 100644
--- a/libcxx/include/__format/formatter_integral.h
+++ b/libcxx/include/__format/formatter_integral.h
@@ -22,6 +22,7 @@
#include <__format/parser_std_format_spec.h>
#include <__iterator/concepts.h>
#include <__iterator/iterator_traits.h>
+#include <__locale>
#include <__memory/pointer_traits.h>
#include <__system_error/errc.h>
#include <__type_traits/make_unsigned.h>
@@ -32,10 +33,6 @@
#include <string>
#include <string_view>
-#if _LIBCPP_HAS_LOCALIZATION
-# include <__locale>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index 52066f5f84d24..ac9c52e2b3e27 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -11,31 +11,30 @@
#define _LIBCPP___LOCALE
#include <__config>
-
-#if _LIBCPP_HAS_LOCALIZATION
-
-# include <__locale_dir/locale_base_api.h>
-# include <__memory/addressof.h>
-# include <__memory/shared_count.h>
-# include <__mutex/once_flag.h>
-# include <__type_traits/make_unsigned.h>
-# include <__utility/no_destroy.h>
-# include <__utility/private_constructor_tag.h>
-# include <cctype>
-# include <clocale>
-# include <cstdint>
-# include <cstdlib>
-# include <string>
+#include <__locale_dir/locale_base_api.h>
+#include <__memory/addressof.h>
+#include <__memory/shared_count.h>
+#include <__mutex/once_flag.h>
+#include <__type_traits/make_unsigned.h>
+#include <__utility/no_destroy.h>
+#include <__utility/private_constructor_tag.h>
+#include <cctype>
+#include <clocale>
+#include <cstdint>
+#include <cstdlib>
+#include <string>
// Some platforms require more includes than others. Keep the includes on all plaforms for now.
-# include <cstddef>
-# include <cstring>
+#include <cstddef>
+#include <cstring>
-# if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
-# else
-# include <__std_mbstate_t.h>
-# endif
+#if _LIBCPP_HAS_WIDE_CHARACTERS
+# include <cwchar>
+#else
+# include <__std_mbstate_t.h>
+#endif
+
+#if _LIBCPP_HAS_LOCALIZATION
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h b/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h
index 8cdbe0cd15051..6fce088822775 100644
--- a/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h
+++ b/libcxx/include/__locale_dir/locale_base_api/bsd_locale_fallbacks.h
@@ -13,15 +13,12 @@
#ifndef _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H
#define _LIBCPP___LOCALE_DIR_LOCALE_BASE_API_BSD_LOCALE_FALLBACKS_H
+#include <cwchar>
#include <locale.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__locale_dir/pad_and_output.h b/libcxx/include/__locale_dir/pad_and_output.h
index 4b845792a3087..eec8b2097d072 100644
--- a/libcxx/include/__locale_dir/pad_and_output.h
+++ b/libcxx/include/__locale_dir/pad_and_output.h
@@ -9,14 +9,13 @@
#ifndef _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
#define _LIBCPP___LOCALE_DIR_PAD_AND_OUTPUT_H
+#include <__algorithm/copy.h>
+#include <__algorithm/fill_n.h>
#include <__config>
+#include <ios>
#if _LIBCPP_HAS_LOCALIZATION
-# include <__algorithm/copy.h>
-# include <__algorithm/fill_n.h>
-# include <ios>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__locale_dir/support/aix.h b/libcxx/include/__locale_dir/support/aix.h
index 8e1a4843900da..074f7849df7e6 100644
--- a/libcxx/include/__locale_dir/support/aix.h
+++ b/libcxx/include/__locale_dir/support/aix.h
@@ -17,10 +17,10 @@
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
+#include <cwchar>
#include <string.h>
#include <time.h>
#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
# include <wctype.h>
#endif
diff --git a/libcxx/include/__locale_dir/support/linux.h b/libcxx/include/__locale_dir/support/linux.h
index 2fe3f6bb8124f..ee27434c91fa1 100644
--- a/libcxx/include/__locale_dir/support/linux.h
+++ b/libcxx/include/__locale_dir/support/linux.h
@@ -17,11 +17,11 @@
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
+#include <cwchar>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
# include <wctype.h>
#endif
diff --git a/libcxx/include/__locale_dir/support/newlib.h b/libcxx/include/__locale_dir/support/newlib.h
index 6ea12c3bc3e1f..89c9eefc83cf0 100644
--- a/libcxx/include/__locale_dir/support/newlib.h
+++ b/libcxx/include/__locale_dir/support/newlib.h
@@ -16,11 +16,11 @@
#include <cstdio>
#include <cstdlib>
#include <ctype.h>
+#include <cwchar>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
# include <wctype.h>
#endif
diff --git a/libcxx/include/__locale_dir/support/no_locale/characters.h b/libcxx/include/__locale_dir/support/no_locale/characters.h
index 52e842d8f494f..23f8ee2226be7 100644
--- a/libcxx/include/__locale_dir/support/no_locale/characters.h
+++ b/libcxx/include/__locale_dir/support/no_locale/characters.h
@@ -15,10 +15,8 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
-# include <cwctype>
-#endif
+#include <cwchar>
+#include <cwctype>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__locale_dir/support/no_locale/conversions.h b/libcxx/include/__locale_dir/support/no_locale/conversions.h
index 64a50df4a50b9..fb9d2b0dba181 100644
--- a/libcxx/include/__locale_dir/support/no_locale/conversions.h
+++ b/libcxx/include/__locale_dir/support/no_locale/conversions.h
@@ -13,9 +13,7 @@
#include <__cstddef/size_t.h>
#include <__std_mbstate_t.h>
#include <cstdlib>
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
-#endif
+#include <cwchar>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/__numeric/pstl.h b/libcxx/include/__numeric/pstl.h
index fe7b2cc7a82cc..dec8856e049ee 100644
--- a/libcxx/include/__numeric/pstl.h
+++ b/libcxx/include/__numeric/pstl.h
@@ -10,6 +10,18 @@
#define _LIBCPP___NUMERIC_PSTL_H
#include <__config>
+#include <__functional/identity.h>
+#include <__functional/operations.h>
+#include <__iterator/cpp17_iterator_concepts.h>
+#include <__iterator/iterator_traits.h>
+#include <__pstl/backend.h>
+#include <__pstl/dispatch.h>
+#include <__pstl/handle_exception.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_execution_policy.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
@@ -20,19 +32,6 @@ _LIBCPP_PUSH_MACROS
#if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
-# include <__functional/identity.h>
-# include <__functional/operations.h>
-# include <__iterator/cpp17_iterator_concepts.h>
-# include <__iterator/iterator_traits.h>
-# include <__pstl/backend.h>
-# include <__pstl/dispatch.h>
-# include <__pstl/handle_exception.h>
-# include <__type_traits/enable_if.h>
-# include <__type_traits/is_execution_policy.h>
-# include <__type_traits/remove_cvref.h>
-# include <__utility/forward.h>
-# include <__utility/move.h>
-
_LIBCPP_BEGIN_NAMESPACE_STD
template <class _ExecutionPolicy,
diff --git a/libcxx/include/__ostream/basic_ostream.h b/libcxx/include/__ostream/basic_ostream.h
index 43c9399758bf1..41a17790296ec 100644
--- a/libcxx/include/__ostream/basic_ostream.h
+++ b/libcxx/include/__ostream/basic_ostream.h
@@ -10,29 +10,28 @@
#define _LIBCPP___OSTREAM_BASIC_OSTREAM_H
#include <__config>
+#include <__exception/operations.h>
+#include <__fwd/memory.h>
+#include <__iterator/ostreambuf_iterator.h>
+#include <__locale_dir/num.h>
+#include <__locale_dir/pad_and_output.h>
+#include <__memory/addressof.h>
+#include <__memory/unique_ptr.h>
+#include <__new/exceptions.h>
+#include <__ostream/put_character_sequence.h>
+#include <__system_error/error_code.h>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_base_of.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
+#include <bitset>
+#include <ios>
+#include <streambuf>
+#include <string_view>
#if _LIBCPP_HAS_LOCALIZATION
-# include <__exception/operations.h>
-# include <__fwd/memory.h>
-# include <__iterator/ostreambuf_iterator.h>
-# include <__locale_dir/num.h>
-# include <__locale_dir/pad_and_output.h>
-# include <__memory/addressof.h>
-# include <__memory/unique_ptr.h>
-# include <__new/exceptions.h>
-# include <__ostream/put_character_sequence.h>
-# include <__system_error/error_code.h>
-# include <__type_traits/conjunction.h>
-# include <__type_traits/enable_if.h>
-# include <__type_traits/is_base_of.h>
-# include <__type_traits/void_t.h>
-# include <__utility/declval.h>
-# include <bitset>
-# include <ios>
-# include <streambuf>
-# include <string_view>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__ostream/print.h b/libcxx/include/__ostream/print.h
index 5b4ab60a45eea..846fbcadfe829 100644
--- a/libcxx/include/__ostream/print.h
+++ b/libcxx/include/__ostream/print.h
@@ -10,17 +10,16 @@
#define _LIBCPP___OSTREAM_PRINT_H
#include <__config>
+#include <__fwd/ostream.h>
+#include <__iterator/ostreambuf_iterator.h>
+#include <__ostream/basic_ostream.h>
+#include <format>
+#include <ios>
+#include <print>
+#include <streambuf>
#if _LIBCPP_HAS_LOCALIZATION
-# include <__fwd/ostream.h>
-# include <__iterator/ostreambuf_iterator.h>
-# include <__ostream/basic_ostream.h>
-# include <format>
-# include <ios>
-# include <print>
-# include <streambuf>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__ostream/put_character_sequence.h b/libcxx/include/__ostream/put_character_sequence.h
index aa771b34d58b5..ad0f127e927f6 100644
--- a/libcxx/include/__ostream/put_character_sequence.h
+++ b/libcxx/include/__ostream/put_character_sequence.h
@@ -10,15 +10,14 @@
#define _LIBCPP___OSTREAM_PUT_CHARACTER_SEQUENCE_H
#include <__config>
+#include <__cstddef/size_t.h>
+#include <__fwd/ostream.h>
+#include <__iterator/ostreambuf_iterator.h>
+#include <__locale_dir/pad_and_output.h>
+#include <ios>
#if _LIBCPP_HAS_LOCALIZATION
-# include <__cstddef/size_t.h>
-# include <__fwd/ostream.h>
-# include <__iterator/ostreambuf_iterator.h>
-# include <__locale_dir/pad_and_output.h>
-# include <ios>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/__pstl/backend.h b/libcxx/include/__pstl/backend.h
index 5980b0708cd34..640826a7f57fd 100644
--- a/libcxx/include/__pstl/backend.h
+++ b/libcxx/include/__pstl/backend.h
@@ -19,7 +19,7 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
# if defined(_LIBCPP_PSTL_BACKEND_SERIAL)
# include <__pstl/backends/default.h>
@@ -32,7 +32,7 @@ _LIBCPP_PUSH_MACROS
# include <__pstl/backends/libdispatch.h>
# endif
-#endif // _LIBCPP_STD_VER >= 17
+#endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/__pstl/backend_fwd.h b/libcxx/include/__pstl/backend_fwd.h
index a52e6db954d0c..e663d11f9537f 100644
--- a/libcxx/include/__pstl/backend_fwd.h
+++ b/libcxx/include/__pstl/backend_fwd.h
@@ -39,7 +39,7 @@ _LIBCPP_PUSH_MACROS
// the user.
//
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {
@@ -306,7 +306,7 @@ struct __is_sorted;
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER >= 17
+#endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/__pstl/dispatch.h b/libcxx/include/__pstl/dispatch.h
index 828842368e339..bd9aacd33b6c1 100644
--- a/libcxx/include/__pstl/dispatch.h
+++ b/libcxx/include/__pstl/dispatch.h
@@ -23,7 +23,7 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {
@@ -64,7 +64,7 @@ using __dispatch _LIBCPP_NODEBUG =
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER >= 17
+#endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/__pstl/handle_exception.h b/libcxx/include/__pstl/handle_exception.h
index 3b5fca86902b0..ccf2aa67e5d26 100644
--- a/libcxx/include/__pstl/handle_exception.h
+++ b/libcxx/include/__pstl/handle_exception.h
@@ -22,7 +22,7 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-#if _LIBCPP_STD_VER >= 17
+#if _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __pstl {
@@ -54,7 +54,7 @@ _LIBCPP_HIDE_FROM_ABI auto __handle_exception(_Args&&... __args) {
} // namespace __pstl
_LIBCPP_END_NAMESPACE_STD
-#endif // _LIBCPP_STD_VER >= 17
+#endif // _LIBCPP_HAS_EXPERIMENTAL_PSTL && _LIBCPP_STD_VER >= 17
_LIBCPP_POP_MACROS
diff --git a/libcxx/include/__string/char_traits.h b/libcxx/include/__string/char_traits.h
index d98595030e6a5..d8b350f812f37 100644
--- a/libcxx/include/__string/char_traits.h
+++ b/libcxx/include/__string/char_traits.h
@@ -27,12 +27,9 @@
#include <__utility/is_pointer_in_range.h>
#include <cstdint>
#include <cstdio>
+#include <cwchar> // for wmemcpy
#include <iosfwd>
-#if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar> // for wmemcpy
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__thread/thread.h b/libcxx/include/__thread/thread.h
index ee7a65212f31d..b32ee63455b4c 100644
--- a/libcxx/include/__thread/thread.h
+++ b/libcxx/include/__thread/thread.h
@@ -31,12 +31,9 @@
#include <__type_traits/remove_cvref.h>
#include <__utility/exchange.h>
#include <__utility/forward.h>
+#include <sstream>
#include <tuple>
-#if _LIBCPP_HAS_LOCALIZATION
-# include <sstream>
-#endif
-
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
diff --git a/libcxx/include/__thread/timed_backoff_policy.h b/libcxx/include/__thread/timed_backoff_policy.h
index 01fe2dd045e58..51149e9e20ce8 100644
--- a/libcxx/include/__thread/timed_backoff_policy.h
+++ b/libcxx/include/__thread/timed_backoff_policy.h
@@ -10,14 +10,13 @@
#ifndef _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
#define _LIBCPP___THREAD_TIMED_BACKOFF_POLICY_H
+#include <__chrono/duration.h>
#include <__config>
#include <__thread/poll_with_backoff.h>
+#include <__thread/support.h>
#if _LIBCPP_HAS_THREADS
-# include <__chrono/duration.h>
-# include <__thread/support.h>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/barrier b/libcxx/include/barrier
index 7fda4c8e06179..9cfb7dd40ef69 100644
--- a/libcxx/include/barrier
+++ b/libcxx/include/barrier
@@ -48,20 +48,19 @@ namespace std
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/__config>
#else
+# include <__assert>
+# include <__atomic/atomic.h>
+# include <__atomic/memory_order.h>
# include <__config>
+# include <__cstddef/ptrdiff_t.h>
+# include <__memory/unique_ptr.h>
+# include <__utility/move.h>
+# include <cstdint>
+# include <limits>
+# include <version>
# if _LIBCPP_HAS_THREADS
-# include <__assert>
-# include <__atomic/atomic.h>
-# include <__atomic/memory_order.h>
-# include <__cstddef/ptrdiff_t.h>
-# include <__memory/unique_ptr.h>
-# include <__utility/move.h>
-# include <cstdint>
-# include <limits>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 39822d5e74f79..cca7e6875041b 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -1102,38 +1102,32 @@ namespace std {
# include <__chrono/calendar.h>
# include <__chrono/day.h>
# include <__chrono/exception.h>
+# include <__chrono/formatter.h>
+# include <__chrono/gps_clock.h>
# include <__chrono/hh_mm_ss.h>
# include <__chrono/is_clock.h>
+# include <__chrono/leap_second.h>
# include <__chrono/literals.h>
# include <__chrono/local_info.h>
# include <__chrono/month.h>
# include <__chrono/month_weekday.h>
# include <__chrono/monthday.h>
+# include <__chrono/ostream.h>
+# include <__chrono/parser_std_format_spec.h>
+# include <__chrono/statically_widen.h>
# include <__chrono/sys_info.h>
+# include <__chrono/tai_clock.h>
+# include <__chrono/time_zone.h>
+# include <__chrono/time_zone_link.h>
+# include <__chrono/tzdb.h>
+# include <__chrono/tzdb_list.h>
+# include <__chrono/utc_clock.h>
# include <__chrono/weekday.h>
# include <__chrono/year.h>
# include <__chrono/year_month.h>
# include <__chrono/year_month_day.h>
# include <__chrono/year_month_weekday.h>
-
-# if _LIBCPP_HAS_LOCALIZATION
-# include <__chrono/formatter.h>
-# include <__chrono/ostream.h>
-# include <__chrono/parser_std_format_spec.h>
-# include <__chrono/statically_widen.h>
-# endif
-
-# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
-# include <__chrono/gps_clock.h>
-# include <__chrono/leap_second.h>
-# include <__chrono/tai_clock.h>
-# include <__chrono/time_zone.h>
-# include <__chrono/time_zone_link.h>
-# include <__chrono/tzdb.h>
-# include <__chrono/tzdb_list.h>
-# include <__chrono/utc_clock.h>
-# include <__chrono/zoned_time.h>
-# endif
+# include <__chrono/zoned_time.h>
# endif
@@ -1166,10 +1160,8 @@ namespace std {
# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER == 20
# include <charconv>
-# if _LIBCPP_HAS_LOCALIZATION
-# include <locale>
-# include <ostream>
-# endif
+# include <locale>
+# include <ostream>
# endif
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
diff --git a/libcxx/include/codecvt b/libcxx/include/codecvt
index ea7c0f876f61a..53ce5bbb819f9 100644
--- a/libcxx/include/codecvt
+++ b/libcxx/include/codecvt
@@ -58,12 +58,11 @@ class codecvt_utf8_utf16
# include <__cxx03/codecvt>
#else
# include <__config>
+# include <__locale>
+# include <version>
# if _LIBCPP_HAS_LOCALIZATION
-# include <__locale>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/complex b/libcxx/include/complex
index f1ba85eb9624e..c5f6c6f1e0d53 100644
--- a/libcxx/include/complex
+++ b/libcxx/include/complex
@@ -268,12 +268,9 @@ template<class T> complex<T> tanh (const complex<T>&);
# include <__type_traits/conditional.h>
# include <__utility/move.h>
# include <cmath>
+# include <sstream> // for std::basic_ostringstream
# include <version>
-# if _LIBCPP_HAS_LOCALIZATION
-# include <sstream> // for std::basic_ostringstream
-# endif
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/cwchar b/libcxx/include/cwchar
index e2534977a7a3c..b7d26821cabad 100644
--- a/libcxx/include/cwchar
+++ b/libcxx/include/cwchar
@@ -115,19 +115,21 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len,
# include <__type_traits/remove_cv.h>
# include <cwctype>
-# include <wchar.h>
+# if _LIBCPP_HAS_WIDE_CHARACTERS
-# ifndef _LIBCPP_WCHAR_H
+# include <wchar.h>
+
+# ifndef _LIBCPP_WCHAR_H
# error <cwchar> tried including <wchar.h> but didn't find libc++'s <wchar.h> header. \
This usually means that your header search paths are not configured properly. \
The header search paths should contain the C++ Standard Library headers before \
any C Standard Library, and you are probably using compiler flags that make that \
not be the case.
-# endif
+# endif
-# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-# endif
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -198,9 +200,9 @@ using ::vwprintf _LIBCPP_USING_IF_EXISTS;
using ::wprintf _LIBCPP_USING_IF_EXISTS;
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wcslen(const wchar_t* __str) {
-# if __has_builtin(__builtin_wcslen)
+# if __has_builtin(__builtin_wcslen)
return __builtin_wcslen(__str);
-# else
+# else
if (!__libcpp_is_constant_evaluated())
return std::wcslen(__str);
@@ -208,14 +210,14 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 size_t __constexpr_wc
for (; *__str != L'\0'; ++__str)
++__len;
return __len;
-# endif
+# endif
}
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int
__constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count) {
-# if __has_builtin(__builtin_wmemcmp)
+# if __has_builtin(__builtin_wmemcmp)
return __builtin_wmemcmp(__lhs, __rhs, __count);
-# else
+# else
if (!__libcpp_is_constant_evaluated())
return std::wmemcmp(__lhs, __rhs, __count);
@@ -226,7 +228,7 @@ __constexpr_wmemcmp(const wchar_t* __lhs, const wchar_t* __rhs, size_t __count)
return 1;
}
return 0;
-# endif
+# endif
}
template <class _Tp, class _Up>
@@ -235,18 +237,18 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
__is_trivially_equality_comparable_v<_Tp, _Tp>,
"Calling wmemchr on non-trivially equality comparable types is unsafe.");
-# if __has_builtin(__builtin_wmemchr)
+# if __has_builtin(__builtin_wmemchr)
if (!__libcpp_is_constant_evaluated()) {
wchar_t __value_buffer = 0;
__builtin_memcpy(&__value_buffer, std::addressof(__value), sizeof(wchar_t));
return reinterpret_cast<_Tp*>(
__builtin_wmemchr(reinterpret_cast<__copy_cv_t<_Tp, wchar_t>*>(__str), __value_buffer, __count));
}
-# if _LIBCPP_STD_VER >= 17
+# if _LIBCPP_STD_VER >= 17
else if constexpr (is_same_v<remove_cv_t<_Tp>, wchar_t>)
return __builtin_wmemchr(__str, __value, __count);
-# endif
-# endif // __has_builtin(__builtin_wmemchr)
+# endif
+# endif // __has_builtin(__builtin_wmemchr)
for (; __count; --__count) {
if (*__str == __value)
@@ -258,6 +260,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp* __constexpr_wmemchr(_Tp
_LIBCPP_END_NAMESPACE_STD
+# endif // _LIBCPP_HAS_WIDE_CHARACTERS
+
# if defined(_LIBCPP_KEEP_TRANSITIVE_INCLUDES_LLVM23) && _LIBCPP_STD_VER <= 20
# include <cstddef>
# endif
diff --git a/libcxx/include/cwctype b/libcxx/include/cwctype
index b7f9cbb835e32..42d4b73ca3d09 100644
--- a/libcxx/include/cwctype
+++ b/libcxx/include/cwctype
@@ -55,23 +55,25 @@ wctrans_t wctrans(const char* property);
# include <__config>
# include <cctype>
-# include <wctype.h>
+# if _LIBCPP_HAS_WIDE_CHARACTERS
-# ifndef _LIBCPP_WCTYPE_H
+# include <wctype.h>
+
+# ifndef _LIBCPP_WCTYPE_H
# error <cwctype> tried including <wctype.h> but didn't find libc++'s <wctype.h> header. \
This usually means that your header search paths are not configured properly. \
The header search paths should contain the C++ Standard Library headers before \
any C Standard Library, and you are probably using compiler flags that make that \
not be the case.
-# endif
+# endif
-# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-# pragma GCC system_header
-# endif
+# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+# endif
_LIBCPP_BEGIN_NAMESPACE_STD
-# if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H)
+# if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H)
using ::wint_t _LIBCPP_USING_IF_EXISTS;
using ::wctrans_t _LIBCPP_USING_IF_EXISTS;
using ::wctype_t _LIBCPP_USING_IF_EXISTS;
@@ -93,10 +95,12 @@ using ::towlower _LIBCPP_USING_IF_EXISTS;
using ::towupper _LIBCPP_USING_IF_EXISTS;
using ::towctrans _LIBCPP_USING_IF_EXISTS;
using ::wctrans _LIBCPP_USING_IF_EXISTS;
-# endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
+# endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H
_LIBCPP_END_NAMESPACE_STD
+# endif // _LIBCPP_HAS_WIDE_CHARACTERS
+
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
#endif // _LIBCPP_CWCTYPE
diff --git a/libcxx/include/format b/libcxx/include/format
index fcfb70d78c2a1..a92e1d337dffe 100644
--- a/libcxx/include/format
+++ b/libcxx/include/format
@@ -246,6 +246,7 @@ namespace std {
# include <cstdint>
# include <cstdlib>
# include <cstring>
+# include <cwchar>
# include <initializer_list>
# include <limits>
# include <locale>
@@ -258,9 +259,6 @@ namespace std {
# include <string_view>
# include <tuple>
-# if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
-# endif
# endif
#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index b5fb65820628a..4e86d4be2ffd5 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -189,29 +189,28 @@ typedef basic_fstream<wchar_t> wfstream;
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/fstream>
#else
+# include <__algorithm/max.h>
+# include <__assert>
# include <__config>
+# include <__filesystem/path.h>
+# include <__fwd/fstream.h>
+# include <__locale>
+# include <__memory/addressof.h>
+# include <__memory/unique_ptr.h>
+# include <__ostream/basic_ostream.h>
+# include <__type_traits/enable_if.h>
+# include <__type_traits/is_same.h>
+# include <__utility/move.h>
+# include <__utility/swap.h>
+# include <__utility/unreachable.h>
+# include <cstdio>
+# include <istream>
+# include <streambuf>
+# include <typeinfo>
+# include <version>
# if _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
-# include <__algorithm/max.h>
-# include <__assert>
-# include <__filesystem/path.h>
-# include <__fwd/fstream.h>
-# include <__locale>
-# include <__memory/addressof.h>
-# include <__memory/unique_ptr.h>
-# include <__ostream/basic_ostream.h>
-# include <__type_traits/enable_if.h>
-# include <__type_traits/is_same.h>
-# include <__utility/move.h>
-# include <__utility/swap.h>
-# include <__utility/unreachable.h>
-# include <cstdio>
-# include <istream>
-# include <streambuf>
-# include <typeinfo>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/future b/libcxx/include/future
index c169c6c182d83..3e7d59e3117e2 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -363,55 +363,54 @@ template <class R, class Alloc> struct uses_allocator<packaged_task<R>, Alloc>;
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/future>
#else
+# include <__assert>
+# include <__chrono/duration.h>
+# include <__chrono/steady_clock.h>
+# include <__chrono/time_point.h>
+# include <__condition_variable/condition_variable.h>
# include <__config>
+# include <__cstddef/nullptr_t.h>
+# include <__exception/exception_ptr.h>
+# include <__memory/addressof.h>
+# include <__memory/allocator.h>
+# include <__memory/allocator_arg_t.h>
+# include <__memory/allocator_destructor.h>
+# include <__memory/allocator_traits.h>
+# include <__memory/compressed_pair.h>
+# include <__memory/pointer_traits.h>
+# include <__memory/shared_count.h>
+# include <__memory/unique_ptr.h>
+# include <__memory/uses_allocator.h>
+# include <__mutex/lock_guard.h>
+# include <__mutex/mutex.h>
+# include <__mutex/unique_lock.h>
+# include <__system_error/error_category.h>
+# include <__system_error/error_code.h>
+# include <__system_error/error_condition.h>
+# include <__thread/thread.h>
+# include <__type_traits/add_reference.h>
+# include <__type_traits/aligned_storage.h>
+# include <__type_traits/conditional.h>
+# include <__type_traits/decay.h>
+# include <__type_traits/enable_if.h>
+# include <__type_traits/invoke.h>
+# include <__type_traits/is_constructible.h>
+# include <__type_traits/is_same.h>
+# include <__type_traits/remove_cvref.h>
+# include <__type_traits/remove_reference.h>
+# include <__type_traits/strip_signature.h>
+# include <__type_traits/underlying_type.h>
+# include <__utility/auto_cast.h>
+# include <__utility/exception_guard.h>
+# include <__utility/forward.h>
+# include <__utility/move.h>
+# include <__utility/swap.h>
+# include <stdexcept>
+# include <tuple>
+# include <version>
# if _LIBCPP_HAS_THREADS
-# include <__assert>
-# include <__chrono/duration.h>
-# include <__chrono/steady_clock.h>
-# include <__chrono/time_point.h>
-# include <__condition_variable/condition_variable.h>
-# include <__cstddef/nullptr_t.h>
-# include <__exception/exception_ptr.h>
-# include <__memory/addressof.h>
-# include <__memory/allocator.h>
-# include <__memory/allocator_arg_t.h>
-# include <__memory/allocator_destructor.h>
-# include <__memory/allocator_traits.h>
-# include <__memory/compressed_pair.h>
-# include <__memory/pointer_traits.h>
-# include <__memory/shared_count.h>
-# include <__memory/unique_ptr.h>
-# include <__memory/uses_allocator.h>
-# include <__mutex/lock_guard.h>
-# include <__mutex/mutex.h>
-# include <__mutex/unique_lock.h>
-# include <__system_error/error_category.h>
-# include <__system_error/error_code.h>
-# include <__system_error/error_condition.h>
-# include <__thread/thread.h>
-# include <__type_traits/add_reference.h>
-# include <__type_traits/aligned_storage.h>
-# include <__type_traits/conditional.h>
-# include <__type_traits/decay.h>
-# include <__type_traits/enable_if.h>
-# include <__type_traits/invoke.h>
-# include <__type_traits/is_constructible.h>
-# include <__type_traits/is_same.h>
-# include <__type_traits/remove_cvref.h>
-# include <__type_traits/remove_reference.h>
-# include <__type_traits/strip_signature.h>
-# include <__type_traits/underlying_type.h>
-# include <__utility/auto_cast.h>
-# include <__utility/exception_guard.h>
-# include <__utility/forward.h>
-# include <__utility/move.h>
-# include <__utility/swap.h>
-# include <stdexcept>
-# include <tuple>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/iomanip b/libcxx/include/iomanip
index eec62bb4e5dd0..a470b1e67aefe 100644
--- a/libcxx/include/iomanip
+++ b/libcxx/include/iomanip
@@ -46,17 +46,16 @@ template <class charT, class traits, class Allocator>
# include <__cxx03/iomanip>
#else
# include <__config>
+# include <__iterator/istreambuf_iterator.h>
+# include <__locale_dir/money.h>
+# include <__locale_dir/time.h>
+# include <__ostream/put_character_sequence.h>
+# include <ios>
+# include <iosfwd>
+# include <version>
# if _LIBCPP_HAS_LOCALIZATION
-# include <__iterator/istreambuf_iterator.h>
-# include <__locale_dir/money.h>
-# include <__locale_dir/time.h>
-# include <__ostream/put_character_sequence.h>
-# include <ios>
-# include <iosfwd>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/ios b/libcxx/include/ios
index 0c14a2a098557..ed7c1eb668f25 100644
--- a/libcxx/include/ios
+++ b/libcxx/include/ios
@@ -215,6 +215,17 @@ storage-class-specifier const error_category& iostream_category() noexcept;
# include <__cxx03/ios>
#else
# include <__config>
+# include <__fwd/ios.h>
+# include <__ios/fpos.h>
+# include <__locale>
+# include <__memory/addressof.h>
+# include <__system_error/error_category.h>
+# include <__system_error/error_code.h>
+# include <__system_error/error_condition.h>
+# include <__system_error/system_error.h>
+# include <__utility/swap.h>
+# include <__verbose_abort>
+# include <version>
// standard-mandated includes
@@ -223,18 +234,6 @@ storage-class-specifier const error_category& iostream_category() noexcept;
# if _LIBCPP_HAS_LOCALIZATION
-# include <__fwd/ios.h>
-# include <__ios/fpos.h>
-# include <__locale>
-# include <__memory/addressof.h>
-# include <__system_error/error_category.h>
-# include <__system_error/error_code.h>
-# include <__system_error/error_condition.h>
-# include <__system_error/system_error.h>
-# include <__utility/swap.h>
-# include <__verbose_abort>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 640cd9f4e29fb..d0ecff6714322 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -163,25 +163,24 @@ template <class Stream, class T>
# include <__cxx03/istream>
#else
# include <__config>
+# include <__fwd/istream.h>
+# include <__iterator/istreambuf_iterator.h>
+# include <__locale_dir/num.h>
+# include <__ostream/basic_ostream.h>
+# include <__type_traits/conjunction.h>
+# include <__type_traits/enable_if.h>
+# include <__type_traits/is_base_of.h>
+# include <__type_traits/is_same.h>
+# include <__type_traits/make_unsigned.h>
+# include <__utility/declval.h>
+# include <__utility/forward.h>
+# include <bitset>
+# include <ios>
+# include <streambuf>
+# include <version>
# if _LIBCPP_HAS_LOCALIZATION
-# include <__fwd/istream.h>
-# include <__iterator/istreambuf_iterator.h>
-# include <__locale_dir/num.h>
-# include <__ostream/basic_ostream.h>
-# include <__type_traits/conjunction.h>
-# include <__type_traits/enable_if.h>
-# include <__type_traits/is_base_of.h>
-# include <__type_traits/is_same.h>
-# include <__type_traits/make_unsigned.h>
-# include <__utility/declval.h>
-# include <__utility/forward.h>
-# include <bitset>
-# include <ios>
-# include <streambuf>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/latch b/libcxx/include/latch
index 77177e5a42923..757742866ce1a 100644
--- a/libcxx/include/latch
+++ b/libcxx/include/latch
@@ -43,18 +43,17 @@ namespace std
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/__config>
#else
+# include <__assert>
+# include <__atomic/atomic.h>
+# include <__atomic/atomic_sync.h>
+# include <__atomic/memory_order.h>
# include <__config>
+# include <__cstddef/ptrdiff_t.h>
+# include <limits>
+# include <version>
# if _LIBCPP_HAS_THREADS
-# include <__assert>
-# include <__atomic/atomic.h>
-# include <__atomic/atomic_sync.h>
-# include <__atomic/memory_order.h>
-# include <__cstddef/ptrdiff_t.h>
-# include <limits>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/locale b/libcxx/include/locale
index 06338102c61b0..bfce8cdf6f2eb 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -191,19 +191,18 @@ template <class charT> class messages_byname;
# include <__cxx03/locale>
#else
# include <__config>
+# include <__locale>
+# include <__locale_dir/messages.h>
+# include <__locale_dir/money.h>
+# include <__locale_dir/num.h>
+# include <__locale_dir/time.h>
+# include <__locale_dir/wbuffer_convert.h>
+# include <__locale_dir/wstring_convert.h>
+# include <ios>
+# include <version>
# if _LIBCPP_HAS_LOCALIZATION
-# include <__locale>
-# include <__locale_dir/messages.h>
-# include <__locale_dir/money.h>
-# include <__locale_dir/num.h>
-# include <__locale_dir/time.h>
-# include <__locale_dir/wbuffer_convert.h>
-# include <__locale_dir/wstring_convert.h>
-# include <ios>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/ostream b/libcxx/include/ostream
index 3fa9a3a5437e1..eda323f531d36 100644
--- a/libcxx/include/ostream
+++ b/libcxx/include/ostream
@@ -176,16 +176,14 @@ void vprint_nonunicode(ostream& os, string_view fmt, format_args args);
# include <__cxx03/ostream>
#else
# include <__config>
+# include <__ostream/basic_ostream.h>
+# include <version>
-# if _LIBCPP_HAS_LOCALIZATION
-
-# include <__ostream/basic_ostream.h>
-
-# if _LIBCPP_STD_VER >= 23
-# include <__ostream/print.h>
-# endif
+# if _LIBCPP_STD_VER >= 23
+# include <__ostream/print.h>
+# endif
-# include <version>
+# if _LIBCPP_HAS_LOCALIZATION
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/ranges b/libcxx/include/ranges
index d82a41942327b..e9189f57c62c5 100644
--- a/libcxx/include/ranges
+++ b/libcxx/include/ranges
@@ -488,6 +488,7 @@ namespace std {
# include <__ranges/enable_view.h>
# include <__ranges/filter_view.h>
# include <__ranges/iota_view.h>
+# include <__ranges/istream_view.h>
# include <__ranges/join_view.h>
# include <__ranges/lazy_split_view.h>
# include <__ranges/rbegin.h>
@@ -504,9 +505,6 @@ namespace std {
# include <__ranges/view_interface.h>
# include <__ranges/views.h>
-# if _LIBCPP_HAS_LOCALIZATION
-# include <__ranges/istream_view.h>
-# endif
# endif
# if _LIBCPP_STD_VER >= 23
diff --git a/libcxx/include/regex b/libcxx/include/regex
index c72ea585702cc..cc71c487300c5 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -792,7 +792,28 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/regex>
#else
+# include <__algorithm/find.h>
+# include <__algorithm/search.h>
+# include <__assert>
# include <__config>
+# include <__iterator/back_insert_iterator.h>
+# include <__iterator/default_sentinel.h>
+# include <__iterator/wrap_iter.h>
+# include <__locale>
+# include <__memory/addressof.h>
+# include <__memory/pointer_traits.h>
+# include <__memory/shared_ptr.h>
+# include <__memory_resource/polymorphic_allocator.h>
+# include <__type_traits/is_swappable.h>
+# include <__utility/move.h>
+# include <__utility/pair.h>
+# include <__utility/swap.h>
+# include <__verbose_abort>
+# include <deque>
+# include <stdexcept>
+# include <string>
+# include <vector>
+# include <version>
// standard-mandated includes
@@ -809,28 +830,6 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
# if _LIBCPP_HAS_LOCALIZATION
-# include <__algorithm/find.h>
-# include <__algorithm/search.h>
-# include <__assert>
-# include <__iterator/back_insert_iterator.h>
-# include <__iterator/default_sentinel.h>
-# include <__iterator/wrap_iter.h>
-# include <__locale>
-# include <__memory/addressof.h>
-# include <__memory/pointer_traits.h>
-# include <__memory/shared_ptr.h>
-# include <__memory_resource/polymorphic_allocator.h>
-# include <__type_traits/is_swappable.h>
-# include <__utility/move.h>
-# include <__utility/pair.h>
-# include <__utility/swap.h>
-# include <__verbose_abort>
-# include <deque>
-# include <stdexcept>
-# include <string>
-# include <vector>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/semaphore b/libcxx/include/semaphore
index ae63cc7ad0960..6726bd310cda4 100644
--- a/libcxx/include/semaphore
+++ b/libcxx/include/semaphore
@@ -48,21 +48,20 @@ using binary_semaphore = counting_semaphore<1>; // since C++20
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/__config>
#else
+# include <__assert>
+# include <__atomic/atomic.h>
+# include <__atomic/atomic_sync.h>
+# include <__atomic/atomic_sync_timed.h>
+# include <__atomic/memory_order.h>
+# include <__chrono/time_point.h>
# include <__config>
+# include <__cstddef/ptrdiff_t.h>
+# include <__thread/support.h>
+# include <limits>
+# include <version>
# if _LIBCPP_HAS_THREADS
-# include <__assert>
-# include <__atomic/atomic.h>
-# include <__atomic/atomic_sync.h>
-# include <__atomic/atomic_sync_timed.h>
-# include <__atomic/memory_order.h>
-# include <__chrono/time_point.h>
-# include <__cstddef/ptrdiff_t.h>
-# include <__thread/support.h>
-# include <limits>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/shared_mutex b/libcxx/include/shared_mutex
index 9479f0aa616f8..eb30c9d0e0ee2 100644
--- a/libcxx/include/shared_mutex
+++ b/libcxx/include/shared_mutex
@@ -125,24 +125,23 @@ template <class Mutex>
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/__config>
#else
+# include <__chrono/duration.h>
+# include <__chrono/steady_clock.h>
+# include <__chrono/time_point.h>
+# include <__condition_variable/condition_variable.h>
# include <__config>
+# include <__memory/addressof.h>
+# include <__mutex/mutex.h>
+# include <__mutex/tag_types.h>
+# include <__mutex/unique_lock.h>
+# include <__system_error/throw_system_error.h>
+# include <__utility/move.h>
+# include <__utility/swap.h>
+# include <cerrno>
+# include <version>
# if _LIBCPP_HAS_THREADS
-# include <__chrono/duration.h>
-# include <__chrono/steady_clock.h>
-# include <__chrono/time_point.h>
-# include <__condition_variable/condition_variable.h>
-# include <__memory/addressof.h>
-# include <__mutex/mutex.h>
-# include <__mutex/tag_types.h>
-# include <__mutex/unique_lock.h>
-# include <__system_error/throw_system_error.h>
-# include <__utility/move.h>
-# include <__utility/swap.h>
-# include <cerrno>
-# include <version>
-
_LIBCPP_PUSH_MACROS
# include <__undef_macros>
diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index d13ba265b4674..a8ed69a55c527 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -316,20 +316,19 @@ typedef basic_stringstream<wchar_t> wstringstream;
# include <__cxx03/sstream>
#else
# include <__config>
+# include <__fwd/sstream.h>
+# include <__ostream/basic_ostream.h>
+# include <__type_traits/is_convertible.h>
+# include <__utility/swap.h>
+# include <ios>
+# include <istream>
+# include <streambuf>
+# include <string>
+# include <string_view>
+# include <version>
# if _LIBCPP_HAS_LOCALIZATION
-# include <__fwd/sstream.h>
-# include <__ostream/basic_ostream.h>
-# include <__type_traits/is_convertible.h>
-# include <__utility/swap.h>
-# include <ios>
-# include <istream>
-# include <streambuf>
-# include <string>
-# include <string_view>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/stop_token b/libcxx/include/stop_token
index dcfa6d44788ba..eb1655bc5991f 100644
--- a/libcxx/include/stop_token
+++ b/libcxx/include/stop_token
@@ -35,16 +35,15 @@ namespace std {
# include <__cxx03/__config>
#else
# include <__config>
+# include <version>
-# if _LIBCPP_HAS_THREADS
-
-# if _LIBCPP_STD_VER >= 20
-# include <__stop_token/stop_callback.h>
-# include <__stop_token/stop_source.h>
-# include <__stop_token/stop_token.h>
-# endif
+# if _LIBCPP_STD_VER >= 20
+# include <__stop_token/stop_callback.h>
+# include <__stop_token/stop_source.h>
+# include <__stop_token/stop_token.h>
+# endif
-# include <version>
+# if _LIBCPP_HAS_THREADS
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/streambuf b/libcxx/include/streambuf
index e0db304771a1e..b7f2ff85c16c1 100644
--- a/libcxx/include/streambuf
+++ b/libcxx/include/streambuf
@@ -110,21 +110,20 @@ protected:
#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/streambuf>
#else
+# include <__assert>
# include <__config>
+# include <__fwd/streambuf.h>
+# include <__locale>
+# include <__memory/valid_range.h>
+# include <__type_traits/is_same.h>
+# include <__utility/scope_guard.h>
+# include <climits>
+# include <ios>
+# include <iosfwd>
+# include <version>
# if _LIBCPP_HAS_LOCALIZATION
-# include <__assert>
-# include <__fwd/streambuf.h>
-# include <__locale>
-# include <__memory/valid_range.h>
-# include <__type_traits/is_same.h>
-# include <__utility/scope_guard.h>
-# include <climits>
-# include <ios>
-# include <iosfwd>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/string b/libcxx/include/string
index a201d2ca44354..11e1c5ddce631 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -654,15 +654,12 @@ basic_string<char32_t> operator""s( const char32_t *str, size_t len );
# include <climits>
# include <cstdio> // EOF
# include <cstring>
+# include <cwchar>
# include <limits>
# include <stdexcept>
# include <string_view>
# include <version>
-# if _LIBCPP_HAS_WIDE_CHARACTERS
-# include <cwchar>
-# endif
-
// standard-mandated includes
// [iterator.range]
@@ -932,7 +929,7 @@ private:
return std::__make_bounded_iter(__p, __get_pointer(), __get_pointer() + size());
# else
return const_iterator(__p);
-# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
+# endif // _LIBCPP_ABI_BOUNDED_ITERATORS_IN_STRING
}
public:
diff --git a/libcxx/include/strstream b/libcxx/include/strstream
index cd1eb286b138c..0982702c07636 100644
--- a/libcxx/include/strstream
+++ b/libcxx/include/strstream
@@ -133,14 +133,13 @@ private:
# include <__cxx03/strstream>
#else
# include <__config>
+# include <__ostream/basic_ostream.h>
+# include <istream>
+# include <streambuf>
+# include <version>
# if _LIBCPP_HAS_LOCALIZATION
-# include <__ostream/basic_ostream.h>
-# include <istream>
-# include <streambuf>
-# include <version>
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/syncstream b/libcxx/include/syncstream
index bd64453683c7c..1848e2b986969 100644
--- a/libcxx/include/syncstream
+++ b/libcxx/include/syncstream
@@ -121,6 +121,15 @@ namespace std {
# include <__cxx03/__config>
#else
# include <__config>
+# include <__mutex/lock_guard.h>
+# include <__utility/move.h>
+# include <ios>
+# include <iosfwd> // required for declaration of default arguments
+# include <map>
+# include <shared_mutex>
+# include <streambuf>
+# include <string>
+# include <version>
// standard-mandated includes
@@ -129,17 +138,6 @@ namespace std {
# if _LIBCPP_HAS_LOCALIZATION
-# include <__mutex/lock_guard.h>
-# include <__utility/move.h>
-# include <ios>
-# include <iosfwd> // required for declaration of default arguments
-# include <streambuf>
-# include <string>
-# if _LIBCPP_HAS_THREADS
-# include <map>
-# include <shared_mutex>
-# endif
-
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
# endif
diff --git a/libcxx/include/thread b/libcxx/include/thread
index 1c804bdd55dd6..5dd44e1214cc1 100644
--- a/libcxx/include/thread
+++ b/libcxx/include/thread
@@ -90,26 +90,24 @@ void sleep_for(const chrono::duration<Rep, Period>& rel_time);
# include <__cxx03/thread>
#else
# include <__config>
+# include <__thread/this_thread.h>
+# include <__thread/thread.h>
+# include <version>
-# if _LIBCPP_HAS_THREADS
-
-# include <__thread/this_thread.h>
-# include <__thread/thread.h>
-
-# if _LIBCPP_STD_VER >= 20
-# include <__thread/jthread.h>
-# endif
-
-# if _LIBCPP_STD_VER >= 23
-# include <__thread/formatter.h>
-# endif
+# if _LIBCPP_STD_VER >= 20
+# include <__thread/jthread.h>
+# endif
-# include <version>
+# if _LIBCPP_STD_VER >= 23
+# include <__thread/formatter.h>
+# endif
// standard-mandated includes
// [thread.syn]
-# include <compare>
+# include <compare>
+
+# if _LIBCPP_HAS_THREADS
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
diff --git a/libcxx/include/vector b/libcxx/include/vector
index f289013a682bc..b79dbcb0e5f2f 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -364,9 +364,7 @@ template<class T, class charT> requires is-vector-bool-reference<T> // Since C++
# include <concepts>
# include <cstdint>
# include <iosfwd>
-# if _LIBCPP_HAS_LOCALIZATION
-# include <locale>
-# endif
+# include <locale>
# include <optional>
# include <string>
# include <string_view>
>From ef5e22bfcdae5e4c9e060847dbf64d8fe0b909d9 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 8 Jun 2026 16:45:00 +0800
Subject: [PATCH 4/5] Always include `<ctime>` and `<ratio>` in
`<__thread/support.h>`
---
libcxx/include/__thread/support.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/libcxx/include/__thread/support.h b/libcxx/include/__thread/support.h
index 50a18daf2b685..506302419a28e 100644
--- a/libcxx/include/__thread/support.h
+++ b/libcxx/include/__thread/support.h
@@ -12,6 +12,11 @@
#include <__config>
+// https://llvm.org/PR202246
+// These headers are unconditionally included to harmonize transitive includes between configurations.
+#include <ctime>
+#include <ratio>
+
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
# pragma GCC system_header
#endif
>From a6e05df13b384c1a34c126ebc4b0024fdbe6cfa7 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 8 Jun 2026 16:34:01 +0800
Subject: [PATCH 5/5] Fix module builds
---
libcxx/include/module.modulemap.in | 1 +
1 file changed, 1 insertion(+)
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 29f3818c39671..a49890ddf953e 100644
--- a/libcxx/include/module.modulemap.in
+++ b/libcxx/include/module.modulemap.in
@@ -2335,6 +2335,7 @@ module std [system] {
module backends {
module default {
header "__pstl/backends/default.h"
+ export std.pstl.backend_fwd
export std_core.utility_core.empty
}
module libdispatch {
More information about the libcxx-commits
mailing list