brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · cebff94 Raw
61 lines · python
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-exception6#7# ===----------------------------------------------------------------------===##8 9# Test that all headers include all the other headers they're supposed to, as10# prescribed by the Standard.11 12# UNSUPPORTED: FROZEN-CXX03-HEADERS-FIXME13 14# TODO: This is currently a libc++-specific way of testing the includes, but is a requirement for all implementation15# REQUIRES: stdlib=libc++16 17# RUN: %{python} %s %{libcxx-dir}/utils18# END.19 20import sys21 22sys.path.append(sys.argv[1])23from libcxx.header_information import (24    lit_header_restrictions,25    lit_header_undeprecations,26    public_headers,27    mandatory_inclusions,28)29 30for header in public_headers:31    header_guard = (32        lambda h: f"_LIBCPP_{str(h).upper().replace('.', '_').replace('/', '_')}"33    )34 35    # <cassert> has no header guards36    if header == "cassert":37        checks = ""38    else:39        checks = f"""40#ifndef {header_guard(header)}41# error <{header}> was expected to define a header guard {header_guard(header)}42#endif43"""44    for includee in mandatory_inclusions.get(header, []):45        checks += f"""46#ifndef {header_guard(includee)}47# error <{header}> was expected to include <{includee}>48#endif49"""50 51    print(52        f"""\53//--- {header}.compile.pass.cpp54{lit_header_restrictions.get(header, '')}55{lit_header_undeprecations.get(header, '')}56 57#include <{header}>58{checks}59"""60    )61