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}/utils 13 14import sys 15sys.path.append(sys.argv[1]) 16from libcxx.header_information import lit_header_restrictions, public_headers, mandatory_inclusions 17 18for header in public_headers: 19 header_guard = lambda h: f"_LIBCPP_{h.upper().replace('.', '_').replace('/', '_')}" 20 21 # <cassert> has no header guards 22 if header == 'cassert': 23 checks = '' 24 else: 25 checks = f''' 26#ifndef {header_guard(header)} 27# error <{header}> was expected to define a header guard {header_guard(header)} 28#endif 29''' 30 for includee in mandatory_inclusions.get(header, []): 31 checks += f''' 32#ifndef {header_guard(includee)} 33# error <{header}> was expected to include <{includee}> 34#endif 35''' 36 37 print(f"""\ 38//--- {header}.compile.pass.cpp 39{lit_header_restrictions.get(header, '')} 40 41#include <{header}> 42{checks} 43""") 44