[libcxx-commits] [libcxx] [libc++] Don't skip localization-related headers in header tests (PR #134877)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 6 12:57:46 PDT 2025


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/134877

>From f2da8e3790d54574d56f60a53f80c46f3881860b Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 8 Apr 2025 12:17:51 -0400
Subject: [PATCH 1/2] [libc++] Don't skip localization-related headers in
 header tests

When localization is disabled, we used to skip testing a lot of headers.
However, these headers are now "no-ops" when localization is disabled,
so they can actually be included. As such, we should test their inclusion
in our usual header inclusion tests.
---
 libcxx/include/ios                        | 10 ++++----
 libcxx/include/regex                      | 30 +++++++++++-----------
 libcxx/include/syncstream                 | 11 ++++----
 libcxx/utils/libcxx/header_information.py | 31 -----------------------
 4 files changed, 25 insertions(+), 57 deletions(-)

diff --git a/libcxx/include/ios b/libcxx/include/ios
index 9e48ec88ce59d..78fc9d610987d 100644
--- a/libcxx/include/ios
+++ b/libcxx/include/ios
@@ -216,6 +216,11 @@ storage-class-specifier const error_category& iostream_category() noexcept;
 #else
 #  include <__config>
 
+// standard-mandated includes
+
+// [ios.syn]
+#  include <iosfwd>
+
 #  if _LIBCPP_HAS_LOCALIZATION
 
 #    include <__fwd/ios.h>
@@ -230,11 +235,6 @@ storage-class-specifier const error_category& iostream_category() noexcept;
 #    include <__verbose_abort>
 #    include <version>
 
-// standard-mandated includes
-
-// [ios.syn]
-#    include <iosfwd>
-
 #    if _LIBCPP_HAS_ATOMIC_HEADER
 #      include <__atomic/atomic.h> // for __xindex_
 #    endif
diff --git a/libcxx/include/regex b/libcxx/include/regex
index 12fc0787dcd5f..7e50b16af3ced 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -794,6 +794,19 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
 #else
 #  include <__config>
 
+// standard-mandated includes
+
+// [iterator.range]
+#  include <__iterator/access.h>
+#  include <__iterator/data.h>
+#  include <__iterator/empty.h>
+#  include <__iterator/reverse_access.h>
+#  include <__iterator/size.h>
+
+// [re.syn]
+#  include <compare>
+#  include <initializer_list>
+
 #  if _LIBCPP_HAS_LOCALIZATION
 
 #    include <__algorithm/find.h>
@@ -817,19 +830,6 @@ typedef regex_token_iterator<wstring::const_iterator> wsregex_token_iterator;
 #    include <vector>
 #    include <version>
 
-// standard-mandated includes
-
-// [iterator.range]
-#    include <__iterator/access.h>
-#    include <__iterator/data.h>
-#    include <__iterator/empty.h>
-#    include <__iterator/reverse_access.h>
-#    include <__iterator/size.h>
-
-// [re.syn]
-#    include <compare>
-#    include <initializer_list>
-
 #    if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #      pragma GCC system_header
 #    endif
@@ -5336,8 +5336,8 @@ typedef regex_iterator<wstring::const_iterator> wsregex_iterator;
 
 template <class _BidirectionalIterator, class _CharT, class _Traits>
 class _LIBCPP_PREFERRED_NAME(cregex_iterator) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wcregex_iterator))
-    _LIBCPP_PREFERRED_NAME(sregex_iterator)
-        _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator)) regex_iterator {
+    _LIBCPP_PREFERRED_NAME(sregex_iterator) _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wsregex_iterator))
+        regex_iterator {
 public:
   typedef basic_regex<_CharT, _Traits> regex_type;
   typedef match_results<_BidirectionalIterator> value_type;
diff --git a/libcxx/include/syncstream b/libcxx/include/syncstream
index ffa0ed8001efd..1f7605e06aa21 100644
--- a/libcxx/include/syncstream
+++ b/libcxx/include/syncstream
@@ -122,6 +122,11 @@ namespace std {
 #else
 #  include <__config>
 
+// standard-mandated includes
+
+// [syncstream.syn]
+#  include <ostream>
+
 #  if _LIBCPP_HAS_LOCALIZATION
 
 #    include <__mutex/lock_guard.h>
@@ -130,17 +135,11 @@ namespace std {
 #    include <iosfwd> // required for declaration of default arguments
 #    include <streambuf>
 #    include <string>
-
 #    if _LIBCPP_HAS_THREADS
 #      include <map>
 #      include <shared_mutex>
 #    endif
 
-// standard-mandated includes
-
-// [syncstream.syn]
-#    include <ostream>
-
 #    if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #      pragma GCC system_header
 #    endif
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index a505d37b65b81..d06271a7908cc 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -179,29 +179,10 @@ def __hash__(self) -> int:
     # headers with #error directives
     "atomic": "_LIBCPP_HAS_ATOMIC_HEADER",
     "stdatomic.h": "_LIBCPP_HAS_ATOMIC_HEADER",
-
-    # headers with #error directives
-    "ios": "_LIBCPP_HAS_LOCALIZATION",
-    # transitive includers of the above headers
-    "clocale": "_LIBCPP_HAS_LOCALIZATION",
-    "codecvt": "_LIBCPP_HAS_LOCALIZATION",
-    "fstream": "_LIBCPP_HAS_LOCALIZATION",
-    "iomanip": "_LIBCPP_HAS_LOCALIZATION",
-    "iostream": "_LIBCPP_HAS_LOCALIZATION",
-    "istream": "_LIBCPP_HAS_LOCALIZATION",
-    "locale": "_LIBCPP_HAS_LOCALIZATION",
-    "ostream": "_LIBCPP_HAS_LOCALIZATION",
-    "regex": "_LIBCPP_HAS_LOCALIZATION",
-    "sstream": "_LIBCPP_HAS_LOCALIZATION",
-    "streambuf": "_LIBCPP_HAS_LOCALIZATION",
-    "strstream": "_LIBCPP_HAS_LOCALIZATION",
-    "syncstream": "_LIBCPP_HAS_LOCALIZATION",
 }
 
 lit_header_restrictions = {
     "barrier": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17",
-    "clocale": "// UNSUPPORTED: no-localization",
-    "codecvt": "// UNSUPPORTED: no-localization",
     "coroutine": "// UNSUPPORTED: c++03, c++11, c++14, c++17",
     "cwchar": "// UNSUPPORTED: no-wide-characters",
     "cwctype": "// UNSUPPORTED: no-wide-characters",
@@ -211,26 +192,14 @@ def __hash__(self) -> int:
     "experimental/type_traits": "// UNSUPPORTED: c++03",
     "experimental/utility": "// UNSUPPORTED: c++03",
     "filesystem": "// UNSUPPORTED: no-filesystem, c++03, c++11, c++14",
-    "fstream": "// UNSUPPORTED: no-localization, no-filesystem",
     "future": "// UNSUPPORTED: no-threads, c++03",
-    "iomanip": "// UNSUPPORTED: no-localization",
-    "ios": "// UNSUPPORTED: no-localization",
-    "iostream": "// UNSUPPORTED: no-localization",
-    "istream": "// UNSUPPORTED: no-localization",
     "latch": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17",
-    "locale": "// UNSUPPORTED: no-localization",
     "mutex": "// UNSUPPORTED: no-threads, c++03",
-    "ostream": "// UNSUPPORTED: no-localization",
     "print": "// UNSUPPORTED: no-filesystem, c++03, c++11, c++14, c++17, c++20, availability-fp_to_chars-missing", # TODO PRINT investigate
-    "regex": "// UNSUPPORTED: no-localization",
     "semaphore": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17",
     "shared_mutex": "// UNSUPPORTED: no-threads, c++03, c++11",
-    "sstream": "// UNSUPPORTED: no-localization",
     "stdatomic.h": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17, c++20",
     "stop_token": "// UNSUPPORTED: no-threads, c++03, c++11, c++14, c++17",
-    "streambuf": "// UNSUPPORTED: no-localization",
-    "strstream": "// UNSUPPORTED: no-localization",
-    "syncstream": "// UNSUPPORTED: no-localization",
     "thread": "// UNSUPPORTED: no-threads, c++03",
     "wchar.h": "// UNSUPPORTED: no-wide-characters",
     "wctype.h": "// UNSUPPORTED: no-wide-characters",

>From 3775afb58a72f8cc31725221328220647d6acf2a Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 6 May 2025 15:56:23 -0400
Subject: [PATCH 2/2] Regenerate files

---
 libcxx/modules/std.compat.cppm.in |  4 +--
 libcxx/modules/std.cppm.in        | 56 ++++++++-----------------------
 2 files changed, 15 insertions(+), 45 deletions(-)

diff --git a/libcxx/modules/std.compat.cppm.in b/libcxx/modules/std.compat.cppm.in
index 95931447ccdc6..dd7385bf33a42 100644
--- a/libcxx/modules/std.compat.cppm.in
+++ b/libcxx/modules/std.compat.cppm.in
@@ -24,9 +24,7 @@ module;
 #include <cfloat>
 #include <cinttypes>
 #include <climits>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <clocale>
-#endif
+#include <clocale>
 #include <cmath>
 #include <csetjmp>
 #include <csignal>
diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in
index 5c523691bff4e..984b18321923c 100644
--- a/libcxx/modules/std.cppm.in
+++ b/libcxx/modules/std.cppm.in
@@ -35,13 +35,9 @@ module;
 #include <chrono>
 #include <cinttypes>
 #include <climits>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <clocale>
-#endif
+#include <clocale>
 #include <cmath>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <codecvt>
-#endif
+#include <codecvt>
 #include <compare>
 #include <complex>
 #include <concepts>
@@ -68,32 +64,20 @@ module;
 #include <flat_set>
 #include <format>
 #include <forward_list>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <fstream>
-#endif
+#include <fstream>
 #include <functional>
 #include <future>
 #include <initializer_list>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <iomanip>
-#endif
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <ios>
-#endif
+#include <iomanip>
+#include <ios>
 #include <iosfwd>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <iostream>
-#endif
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <istream>
-#endif
+#include <iostream>
+#include <istream>
 #include <iterator>
 #include <latch>
 #include <limits>
 #include <list>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <locale>
-#endif
+#include <locale>
 #include <map>
 #include <mdspan>
 #include <memory>
@@ -103,40 +87,28 @@ module;
 #include <numbers>
 #include <numeric>
 #include <optional>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <ostream>
-#endif
+#include <ostream>
 #include <print>
 #include <queue>
 #include <random>
 #include <ranges>
 #include <ratio>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <regex>
-#endif
+#include <regex>
 #include <scoped_allocator>
 #include <semaphore>
 #include <set>
 #include <shared_mutex>
 #include <source_location>
 #include <span>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <sstream>
-#endif
+#include <sstream>
 #include <stack>
 #include <stdexcept>
 #include <stop_token>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <streambuf>
-#endif
+#include <streambuf>
 #include <string>
 #include <string_view>
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <strstream>
-#endif
-#if _LIBCPP_HAS_LOCALIZATION
-#  include <syncstream>
-#endif
+#include <strstream>
+#include <syncstream>
 #include <system_error>
 #include <thread>
 #include <tuple>



More information about the libcxx-commits mailing list