[libcxx-commits] [libcxx] [libc++] Cover support for header inclusion in all modes (PR #202246)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Jun 7 19:08:11 PDT 2026
https://github.com/frederick-vs-ja created https://github.com/llvm/llvm-project/pull/202246
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`.
>From 8492f02e34e46487997afcb911cfed5f439f35ca 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] [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}>
More information about the libcxx-commits
mailing list