• 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 headers are not tripped up by the surrounding code defining various
10# alphabetic macros.
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, public_headers
17
18for header in public_headers:
19  print(f"""\
20//--- {header}.compile.pass.cpp
21{lit_header_restrictions.get(header, '')}
22
23#define NASTY_MACRO This should not be expanded!!!
24
25// libc++ does not use single-letter names as a matter of principle.
26// But Windows' own <wchar.h>, <math.h>, and <exception> use many of these
27// (at least C,E,F,I,M,N,P,S,X,Y,Z) as uglified function parameter names,
28// so don't define these on Windows.
29//
30#ifndef _WIN32
31#define _A NASTY_MACRO
32#define _B NASTY_MACRO
33#define _C NASTY_MACRO
34#define _D NASTY_MACRO
35#define _E NASTY_MACRO
36#define _F NASTY_MACRO
37#define _G NASTY_MACRO
38#define _H NASTY_MACRO
39#define _I NASTY_MACRO
40#define _J NASTY_MACRO
41#define _K NASTY_MACRO
42#define _L NASTY_MACRO
43#define _M NASTY_MACRO
44#define _N NASTY_MACRO
45#define _O NASTY_MACRO
46#define _P NASTY_MACRO
47#define _Q NASTY_MACRO
48#define _R NASTY_MACRO
49#define _S NASTY_MACRO
50#define _T NASTY_MACRO
51#define _U NASTY_MACRO
52#define _V NASTY_MACRO
53#define _W NASTY_MACRO
54#define _X NASTY_MACRO
55#define _Y NASTY_MACRO
56#define _Z NASTY_MACRO
57#endif
58
59// FreeBSD's <sys/types.h> uses _M
60//
61#ifdef __FreeBSD__
62# undef _M
63#endif
64
65// Test that libc++ doesn't use names that collide with FreeBSD system macros.
66#ifndef __FreeBSD__
67#  define __null_sentinel NASTY_MACRO
68#  define __generic
69#endif
70
71// tchar.h defines these macros on Windows
72#ifndef _WIN32
73# define _UI   NASTY_MACRO
74# define _PUC  NASTY_MACRO
75# define _CPUC NASTY_MACRO
76# define _PC   NASTY_MACRO
77# define _CRPC NASTY_MACRO
78# define _CPC  NASTY_MACRO
79#endif
80
81// yvals.h on MINGW defines this macro
82#ifndef _WIN32
83# define _C2 NASTY_MACRO
84#endif
85
86// Test that libc++ doesn't use names that collide with Win32 API macros.
87// Obviously we can only define these on non-Windows platforms.
88#ifndef _WIN32
89# define __allocator NASTY_MACRO
90# define __bound NASTY_MACRO
91# define __deallocate NASTY_MACRO
92# define __deref NASTY_MACRO
93# define __format_string NASTY_MACRO
94# define __full NASTY_MACRO
95# define __in NASTY_MACRO
96# define __inout NASTY_MACRO
97# define __nz NASTY_MACRO
98# define __out NASTY_MACRO
99# define __part NASTY_MACRO
100# define __post NASTY_MACRO
101# define __pre NASTY_MACRO
102#endif
103
104#define __input NASTY_MACRO
105#define __output NASTY_MACRO
106
107#define __acquire NASTY_MACRO
108#define __release NASTY_MACRO
109
110// These names are not reserved, so the user can macro-define them.
111// These are intended to find improperly _Uglified template parameters.
112#define A NASTY_MACRO
113#define Arg NASTY_MACRO
114#define Args NASTY_MACRO
115#define As NASTY_MACRO
116#define B NASTY_MACRO
117#define Bs NASTY_MACRO
118#define C NASTY_MACRO
119#define Cp NASTY_MACRO
120#define Cs NASTY_MACRO
121// Windows setjmp.h contains a struct member named 'D' on ARM/AArch64.
122#ifndef _WIN32
123# define D NASTY_MACRO
124#endif
125#define Dp NASTY_MACRO
126#define Ds NASTY_MACRO
127#define E NASTY_MACRO
128#define Ep NASTY_MACRO
129#define Es NASTY_MACRO
130#define R NASTY_MACRO
131#define Rp NASTY_MACRO
132#define Rs NASTY_MACRO
133#define T NASTY_MACRO
134#define Tp NASTY_MACRO
135#define Ts NASTY_MACRO
136#define Type NASTY_MACRO
137#define Types NASTY_MACRO
138#define U NASTY_MACRO
139#define Up NASTY_MACRO
140#define Us NASTY_MACRO
141#define V NASTY_MACRO
142#define Vp NASTY_MACRO
143#define Vs NASTY_MACRO
144#define X NASTY_MACRO
145#define Xp NASTY_MACRO
146#define Xs NASTY_MACRO
147
148// The classic Windows min/max macros
149#define min NASTY_MACRO
150#define max NASTY_MACRO
151
152#include <{header}>
153""")
154