Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / utils / generate_std_clang_module_header.py
blobafdc9f653c2a259f2e643bbded227844355a232b
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 import libcxx.header_information
14 header_restrictions = libcxx.header_information.header_restrictions
16 libcxx_include_directory = os.path.join(
17 os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "include"
19 with open(
20 os.path.join(libcxx_include_directory, "__std_clang_module"), "w"
21 ) as std_clang_module_header:
22 std_clang_module_header.write(
23 """\
24 // -*- C++ -*-
25 //===----------------------------------------------------------------------===//
27 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
28 // See https://llvm.org/LICENSE.txt for license information.
29 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
31 //===----------------------------------------------------------------------===//
33 // WARNING, this entire header is generated by
34 // utils/generate_std_clang_module_header.py
35 // DO NOT MODIFY!
37 // This header should not be directly included, it's exclusively to import all
38 // of the libc++ public clang modules for the `std` clang module to export. In
39 // other words, it's to facilitate `@import std;` in Objective-C++ and `import std`
40 // in Swift to expose all of the libc++ interfaces. This is generally not
41 // recommended, however there are some clients that need to import all of libc++
42 // without knowing what "all" is.
43 #if !__building_module(std)
44 # error "Do not include this header directly, include individual headers instead"
45 #endif
47 #include <__config>
49 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50 # pragma GCC system_header
51 #endif
53 """
55 # Include the angle brackets in sorting so that <a.h> sorts before <a>
56 # like check-format wants.
57 for include, header in sorted([(f"<{header}>", header) for header in libcxx.header_information.public_headers]):
58 header_restriction = header_restrictions.get(header)
59 if header_restriction:
60 std_clang_module_header.write(f"#if {header_restriction}\n")
61 std_clang_module_header.write(f"# include {include}\n")
62 std_clang_module_header.write(f"#endif\n")
63 else:
64 std_clang_module_header.write(f"#include {include}\n")