• 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# This test ensures that we produce a diagnostic when we use a private header
10# from user code.
11
12# RUN: %{python} %s %{libcxx}/utils
13
14import sys
15sys.path.append(sys.argv[1])
16from libcxx.test.header_information import lit_header_restrictions, private_headers, private_headers_still_public_in_modules
17
18for header in private_headers:
19  # Skip headers that are not private yet in the modulemap
20  if header in private_headers_still_public_in_modules:
21    continue
22
23  # Skip private headers that start with __support -- those are not in the modulemap yet
24  if header.startswith('__support'):
25    continue
26
27  # Skip the locale API headers, since they are platform-specific and thus inherently non-modular
28  if 'locale_base_api' in header:
29    continue
30
31  # TODO: Stop skipping PSTL headers once their integration is finished.
32  if header.startswith('__pstl'):
33    continue
34
35  BLOCKLIT = '' # block Lit from interpreting a RUN/XFAIL/etc inside the generation script
36  print(f"""\
37//--- {header}.verify.cpp
38// REQUIRES{BLOCKLIT}: modules-build
39{lit_header_restrictions.get(header, '')}
40
41#include <{header}> // expected-error@*:* {{{{use of private header from outside its module: '{header}'}}}}
42""")
43