• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ===----------------------------------------------------------------------===##
2#
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
6#
7# ===----------------------------------------------------------------------===##
8
9# Test that all headers include all the other headers they're supposed to, as
10# prescribed by the Standard.
11
12# RUN: %{python} %s %{libcxx-dir}/utils
13
14import sys
15
16sys.path.append(sys.argv[1])
17from libcxx.header_information import (
18    lit_header_restrictions,
19    lit_header_undeprecations,
20    public_headers,
21    mandatory_inclusions,
22)
23
24for header in public_headers:
25    header_guard = (
26        lambda h: f"_LIBCPP_{str(h).upper().replace('.', '_').replace('/', '_')}"
27    )
28
29    # <cassert> has no header guards
30    if header == "cassert":
31        checks = ""
32    else:
33        checks = f"""
34#ifndef {header_guard(header)}
35# error <{header}> was expected to define a header guard {header_guard(header)}
36#endif
37"""
38    for includee in mandatory_inclusions.get(header, []):
39        checks += f"""
40#ifndef {header_guard(includee)}
41# error <{header}> was expected to include <{includee}>
42#endif
43"""
44
45    print(
46        f"""\
47//--- {header}.compile.pass.cpp
48{lit_header_restrictions.get(header, '')}
49{lit_header_undeprecations.get(header, '')}
50
51#include <{header}>
52{checks}
53"""
54    )
55