Skip to content

Commit 5e2c522

Browse files
ian-twilightcodertru
authored andcommitted
[libc++][Modules] Generate the __std_clang_module header
Use header_information to generate the __std_clang_module header. Instead of using lit_header_restrictions like the manually written header did, make a new header_include_requirements to codify what can be included rather than what can be fully tested. Reviewed By: Mordante, #libc Differential Revision: https://reviews.llvm.org/D157364 # Conflicts: # libcxx/utils/libcxx/header_information.py
1 parent ae49840 commit 5e2c522

File tree

5 files changed

+215
-115
lines changed

5 files changed

+215
-115
lines changed

libcxx/include/__std_clang_module

Lines changed: 79 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10+
// WARNING, this entire header is generated by
11+
// utils/generate_std_clang_module_header.py
12+
// DO NOT MODIFY!
13+
1014
// This header should not be directly included, it's exclusively to import all
1115
// of the libc++ public clang modules for the `std` clang module to export. In
1216
// other words, it's to facilitate `@import std;` in Objective-C++ and `import std`
@@ -17,7 +21,6 @@
1721
# error "Do not include this header directly, include individual headers instead"
1822
#endif
1923

20-
#include <__availability>
2124
#include <__config>
2225

2326
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -27,52 +30,109 @@
2730
#include <algorithm>
2831
#include <any>
2932
#include <array>
30-
#include <atomic>
3133
#include <bit>
3234
#include <bitset>
35+
#include <cassert>
36+
#include <ccomplex>
37+
#include <cctype>
38+
#include <cerrno>
39+
#include <cfenv>
40+
#include <cfloat>
3341
#include <charconv>
3442
#include <chrono>
43+
#include <cinttypes>
44+
#include <ciso646>
45+
#include <climits>
46+
#include <cmath>
3547
#include <compare>
48+
#include <complex.h>
3649
#include <complex>
3750
#include <concepts>
3851
#include <condition_variable>
52+
#include <coroutine>
53+
#include <csetjmp>
54+
#include <csignal>
55+
#include <cstdarg>
56+
#include <cstdbool>
57+
#include <cstddef>
58+
#include <cstdint>
59+
#include <cstdio>
60+
#include <cstdlib>
61+
#include <cstring>
62+
#include <ctgmath>
63+
#include <ctime>
64+
#include <ctype.h>
65+
#include <cuchar>
3966
#include <deque>
67+
#include <errno.h>
4068
#include <exception>
4169
#include <execution>
4270
#include <expected>
71+
#include <experimental/deque>
72+
#include <experimental/forward_list>
73+
#include <experimental/iterator>
74+
#include <experimental/list>
75+
#include <experimental/map>
76+
#include <experimental/memory_resource>
77+
#include <experimental/propagate_const>
78+
#include <experimental/set>
79+
#include <experimental/simd>
80+
#include <experimental/string>
81+
#include <experimental/type_traits>
82+
#include <experimental/unordered_map>
83+
#include <experimental/unordered_set>
84+
#include <experimental/utility>
85+
#include <experimental/vector>
86+
#include <fenv.h>
87+
#include <filesystem>
88+
#include <float.h>
4389
#include <format>
4490
#include <forward_list>
4591
#include <functional>
4692
#include <initializer_list>
93+
#include <inttypes.h>
4794
#include <iosfwd>
4895
#include <iterator>
96+
#include <limits.h>
4997
#include <limits>
5098
#include <list>
5199
#include <map>
100+
#include <math.h>
52101
#include <mdspan>
53102
#include <memory>
54103
#include <memory_resource>
104+
#include <mutex>
55105
#include <new>
56106
#include <numbers>
57107
#include <numeric>
58108
#include <optional>
109+
#include <print>
59110
#include <queue>
60111
#include <random>
61112
#include <ranges>
62113
#include <ratio>
63114
#include <scoped_allocator>
64115
#include <set>
116+
#include <setjmp.h>
65117
#include <source_location>
66118
#include <span>
67119
#include <stack>
120+
#include <stdbool.h>
121+
#include <stddef.h>
68122
#include <stdexcept>
123+
#include <stdint.h>
124+
#include <stdio.h>
125+
#include <stdlib.h>
126+
#include <string.h>
69127
#include <string>
70128
#include <string_view>
71129
#include <system_error>
130+
#include <tgmath.h>
72131
#include <tuple>
73132
#include <type_traits>
74133
#include <typeindex>
75134
#include <typeinfo>
135+
#include <uchar.h>
76136
#include <unordered_map>
77137
#include <unordered_set>
78138
#include <utility>
@@ -81,132 +141,42 @@
81141
#include <vector>
82142
#include <version>
83143

84-
#include <cassert>
85-
#include <ccomplex>
86-
#include <cctype>
87-
#include <cerrno>
88-
#include <cfenv>
89-
#include <cfloat>
90-
#include <cinttypes>
91-
#include <ciso646>
92-
#include <climits>
93-
#include <cmath>
94-
#include <csetjmp>
95-
#include <csignal>
96-
#include <cstdarg>
97-
#include <cstdbool>
98-
#include <cstddef>
99-
#include <cstdint>
100-
#include <cstdio>
101-
#include <cstdlib>
102-
#include <cstring>
103-
#include <ctgmath>
104-
#include <ctime>
105-
#include <cuchar>
106-
107-
#include <complex.h>
108-
#include <ctype.h>
109-
#include <errno.h>
110-
#include <fenv.h>
111-
#include <float.h>
112-
#include <inttypes.h>
113-
#include <limits.h>
114-
#include <math.h>
115-
#include <setjmp.h>
116-
#include <stdbool.h>
117-
#include <stddef.h>
118-
#include <stdint.h>
119-
#include <stdio.h>
120-
#include <stdlib.h>
121-
#include <string.h>
122-
#include <tgmath.h>
123-
#include <uchar.h>
144+
#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
145+
# include <atomic>
146+
# include <stdatomic.h>
147+
#endif
124148

125149
#ifndef _LIBCPP_HAS_NO_LOCALIZATION
150+
# include <clocale>
126151
# include <codecvt>
127-
# ifndef _LIBCPP_HAS_NO_FILESYSTEM
128-
# include <fstream>
129-
# endif
152+
# include <experimental/regex>
153+
# include <fstream>
130154
# include <iomanip>
131155
# include <ios>
132156
# include <iostream>
133157
# include <istream>
158+
# include <locale.h>
134159
# include <locale>
135160
# include <ostream>
136161
# include <regex>
137162
# include <sstream>
138163
# include <streambuf>
139164
# include <strstream>
165+
#endif
140166

141-
# include <clocale>
142-
143-
# include <locale.h>
167+
#ifndef _LIBCPP_HAS_NO_THREADS
168+
# include <barrier>
169+
# include <future>
170+
# include <latch>
171+
# include <semaphore>
172+
# include <shared_mutex>
173+
# include <stop_token>
174+
# include <thread>
144175
#endif
145176

146177
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
147178
# include <cwchar>
148179
# include <cwctype>
149-
150180
# include <wchar.h>
151181
# include <wctype.h>
152182
#endif
153-
154-
#ifdef _LIBCPP_AVAILABILITY_TO_CHARS_FLOATING_POINT
155-
# include <print>
156-
#endif
157-
158-
#ifndef _LIBCPP_CXX03_LANG
159-
# ifndef _LIBCPP_HAS_NO_THREADS
160-
# include <future>
161-
# include <mutex>
162-
# include <thread>
163-
# endif
164-
165-
# include <experimental/deque>
166-
# include <experimental/forward_list>
167-
# include <experimental/iterator>
168-
# include <experimental/list>
169-
# include <experimental/map>
170-
# include <experimental/memory_resource>
171-
# include <experimental/propagate_const>
172-
# ifndef _LIBCPP_HAS_NO_LOCALIZATION
173-
# include <experimental/regex>
174-
# endif
175-
# include <experimental/set>
176-
# include <experimental/simd>
177-
# include <experimental/string>
178-
# include <experimental/type_traits>
179-
# include <experimental/unordered_map>
180-
# include <experimental/unordered_set>
181-
# include <experimental/utility>
182-
# include <experimental/vector>
183-
#endif
184-
185-
#if _LIBCPP_STD_VER >= 14
186-
# ifndef _LIBCPP_HAS_NO_THREADS
187-
# include <shared_mutex>
188-
# endif
189-
#endif
190-
191-
#if _LIBCPP_STD_VER >= 17
192-
# ifndef _LIBCPP_HAS_NO_FILESYSTEM
193-
# include <filesystem>
194-
# endif
195-
#endif
196-
197-
#if _LIBCPP_STD_VER >= 20
198-
# include <coroutine>
199-
200-
# ifndef _LIBCPP_HAS_NO_THREADS
201-
# include <barrier>
202-
# include <latch>
203-
# include <semaphore>
204-
# include <stop_token>
205-
# endif
206-
#endif
207-
208-
#if _LIBCPP_STD_VER >= 23
209-
# ifndef _LIBCPP_HAS_NO_THREADS
210-
# include <stdatomic.h>
211-
# endif
212-
#endif

libcxx/test/libcxx/modules_include.gen.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
sys.path.append(sys.argv[1])
1717
from libcxx.header_information import lit_header_restrictions, public_headers
1818

19+
BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
20+
1921
for header in public_headers:
20-
BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
2122
print(f"""\
2223
//--- {header}.compile.pass.cpp
2324
// RUN{BLOCKLIT}: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only
@@ -45,7 +46,7 @@
4546
#include <{header}>
4647
""")
4748

48-
print(f"""
49+
print(f"""\
4950
//--- __std_clang_module.compile.pass.mm
5051
// RUN{BLOCKLIT}: %{{cxx}} %s %{{flags}} %{{compile_flags}} -fmodules -fcxx-modules -fmodules-cache-path=%t -fsyntax-only
5152
@@ -68,10 +69,6 @@
6869
// TODO: Investigate this failure
6970
// UNSUPPORTED{BLOCKLIT}: LIBCXX-FREEBSD-FIXME
7071
71-
// Lit seems to compile this twice: once with the default flags and once with with
72-
// the flags specified in the RUN directive. Guard the first compile from failing.
73-
#if __has_feature(modules)
7472
@import std;
75-
#endif
7673
7774
""")

libcxx/utils/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ add_custom_target(libcxx-generate-feature-test-macros
22
COMMAND "${Python3_EXECUTABLE}" "${LIBCXX_SOURCE_DIR}/utils/generate_feature_test_macro_components.py"
33
COMMENT "Generate the <version> header and tests for feature test macros.")
44

5+
add_custom_target(libcxx-generate-std-clang-module-header
6+
COMMAND "${Python3_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/generate_std_clang_module_header.py"
7+
COMMENT "Generate the <__std_clang_module> header")
8+
59
add_custom_target(libcxx-generate-extended-grapheme-cluster-tables
610
COMMAND
711
"${Python3_EXECUTABLE}"
@@ -38,6 +42,7 @@ add_custom_target(libcxx-generate-iwyu-mapping
3842

3943
add_custom_target(libcxx-generate-files
4044
DEPENDS libcxx-generate-feature-test-macros
45+
libcxx-generate-std-clang-module-header
4146
libcxx-generate-extended-grapheme-cluster-tables
4247
libcxx-generate-extended-grapheme-cluster-tests
4348
libcxx-generate-escaped-output-table

0 commit comments

Comments
 (0)