[libcxx-commits] [libcxx] [libc++] Add missing includes in the locale headers (PR #213035)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Jul 30 07:29:15 PDT 2026


https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/213035

Several headers use entities from <__locale> but rely on picking them up transitively, in most cases through <ios>. Fix this in preparation for splitting up <__locale>.

>From 904f21bca314370854c8c22793a83fc4ef2b272a Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 30 Jul 2026 09:38:51 -0400
Subject: [PATCH] [libc++] Add missing includes in the locale headers

Several headers use entities from <__locale> but rely on picking them up
transitively, in most cases through <ios>. Fix this in preparation for
splitting up <__locale>.
---
 libcxx/include/__filesystem/path.h            | 3 ++-
 libcxx/include/__locale                       | 2 ++
 libcxx/include/__locale_dir/num.h             | 1 +
 libcxx/include/__locale_dir/time.h            | 1 +
 libcxx/include/__locale_dir/wbuffer_convert.h | 1 +
 libcxx/include/sstream                        | 1 +
 6 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h
index a63c4ee611ebf..68250d8f0e04d 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -29,7 +29,8 @@
 #include <string_view>
 
 #if _LIBCPP_HAS_LOCALIZATION
-#  include <iomanip> // for quoted
+#  include <__locale> // for __narrow_to_utf8 and __widen_from_utf8
+#  include <iomanip>  // for quoted
 #endif
 
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
diff --git a/libcxx/include/__locale b/libcxx/include/__locale
index 28bc17f8368a6..87307ea008a89 100644
--- a/libcxx/include/__locale
+++ b/libcxx/include/__locale
@@ -15,6 +15,7 @@
 
 #if _LIBCPP_HAS_LOCALIZATION
 
+#  include <__fwd/ios.h>
 #  include <__locale_dir/locale_base_api.h>
 #  include <__memory/addressof.h>
 #  include <__memory/shared_count.h>
@@ -26,6 +27,7 @@
 #  include <clocale>
 #  include <cstdint>
 #  include <cstdlib>
+#  include <stdexcept>
 #  include <string>
 #  include <text_encoding>
 
diff --git a/libcxx/include/__locale_dir/num.h b/libcxx/include/__locale_dir/num.h
index d50d0e9ba4ab8..3c341c7779ab1 100644
--- a/libcxx/include/__locale_dir/num.h
+++ b/libcxx/include/__locale_dir/num.h
@@ -18,6 +18,7 @@
 #include <__config>
 #include <__iterator/istreambuf_iterator.h>
 #include <__iterator/ostreambuf_iterator.h>
+#include <__locale>
 #include <__locale_dir/check_grouping.h>
 #include <__locale_dir/get_c_locale.h>
 #include <__locale_dir/pad_and_output.h>
diff --git a/libcxx/include/__locale_dir/time.h b/libcxx/include/__locale_dir/time.h
index 7db1cc660cd30..4c082e0e40944 100644
--- a/libcxx/include/__locale_dir/time.h
+++ b/libcxx/include/__locale_dir/time.h
@@ -11,6 +11,7 @@
 
 #include <__algorithm/copy.h>
 #include <__config>
+#include <__locale>
 #include <__locale_dir/get_c_locale.h>
 #include <__locale_dir/scan_keyword.h>
 #include <ios>
diff --git a/libcxx/include/__locale_dir/wbuffer_convert.h b/libcxx/include/__locale_dir/wbuffer_convert.h
index 9c87fac6cf193..08df30a1183f0 100644
--- a/libcxx/include/__locale_dir/wbuffer_convert.h
+++ b/libcxx/include/__locale_dir/wbuffer_convert.h
@@ -11,6 +11,7 @@
 
 #include <__algorithm/reverse.h>
 #include <__config>
+#include <__locale>
 #include <__string/char_traits.h>
 #include <ios>
 #include <streambuf>
diff --git a/libcxx/include/sstream b/libcxx/include/sstream
index d13ba265b4674..0c1aa65904241 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -320,6 +320,7 @@ typedef basic_stringstream<wchar_t> wstringstream;
 #  if _LIBCPP_HAS_LOCALIZATION
 
 #    include <__fwd/sstream.h>
+#    include <__locale>
 #    include <__ostream/basic_ostream.h>
 #    include <__type_traits/is_convertible.h>
 #    include <__utility/swap.h>



More information about the libcxx-commits mailing list