Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / utils / generate_std_cppm_in.py
blob522f1dd8161aea247f32bbf2576c9dda3ac90af1
1 # ===----------------------------------------------------------------------===##
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 # ===----------------------------------------------------------------------===##
9 import operator
10 import os.path
12 from libcxx.header_information import module_headers
13 from libcxx.header_information import header_restrictions
14 from libcxx.header_information import headers_not_available
17 libcxx_module_directory = os.path.join(
18 os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "modules"
20 with open(
21 os.path.join(libcxx_module_directory, "std.cppm.in"), "w"
22 ) as std_module_cpp_in:
23 std_module_cpp_in.write(
24 """\
25 // -*- C++ -*-
26 //===----------------------------------------------------------------------===//
28 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
29 // See https://llvm.org/LICENSE.txt for license information.
30 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
32 //===----------------------------------------------------------------------===//
34 // WARNING, this entire header is generated by
35 // utils/generate_std_cppm_in.py
36 // DO NOT MODIFY!
38 module;
40 #include <__config>
42 // The headers of Table 24: C++ library headers [tab:headers.cpp]
43 // and the headers of Table 25: C++ headers for C library facilities [tab:headers.cpp.c]
44 """
46 for header in module_headers:
47 if header in header_restrictions:
48 std_module_cpp_in.write(
49 f"""\
50 #if {header_restrictions[header]}
51 # include <{header}>
52 #endif
53 """
55 else:
56 std_module_cpp_in.write(f"#include <{header}>\n")
58 std_module_cpp_in.write("\n// *** Headers not yet available ***\n")
59 for header in sorted(headers_not_available):
60 std_module_cpp_in.write(
61 f"""\
62 #if __has_include(<{header}>)
63 # error "update the header information for <{header}> in libcxx/utils/generate_std_cppm_in.py"
64 #endif // __has_include(<{header}>)
65 """
68 std_module_cpp_in.write(
69 """
70 export module std;
72 @LIBCXX_MODULE_STD_INCLUDE_SOURCES@
73 """