• 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 // Prevent <ext/hash_map> from generating deprecated warnings for this test.
13 #if defined(__DEPRECATED)
14 #    undef __DEPRECATED
15 #endif
16 
17 #define NASTY_MACRO This should not be expanded!!!
18 
19 // libc++ does not use single-letter names as a matter of principle.
20 // But Windows' own <wchar.h>, <math.h>, and <exception> use many of these
21 // (at least C,E,F,I,M,N,P,S,X,Y,Z) as uglified function parameter names,
22 // so don't define these on Windows.
23 //
24 #ifndef _WIN32
25 #define _A NASTY_MACRO
26 #define _B NASTY_MACRO
27 #define _C NASTY_MACRO
28 #define _D NASTY_MACRO
29 #define _E NASTY_MACRO
30 #define _F NASTY_MACRO
31 #define _G NASTY_MACRO
32 #define _H NASTY_MACRO
33 #define _I NASTY_MACRO
34 #define _J NASTY_MACRO
35 #define _K NASTY_MACRO
36 #define _L NASTY_MACRO
37 #define _M NASTY_MACRO
38 #define _N NASTY_MACRO
39 #define _O NASTY_MACRO
40 #define _P NASTY_MACRO
41 #define _Q NASTY_MACRO
42 #define _R NASTY_MACRO
43 #define _S NASTY_MACRO
44 #define _T NASTY_MACRO
45 #define _U NASTY_MACRO
46 #define _V NASTY_MACRO
47 #define _W NASTY_MACRO
48 #define _X NASTY_MACRO
49 #define _Y NASTY_MACRO
50 #define _Z NASTY_MACRO
51 #endif
52 
53 // FreeBSD's <sys/types.h> uses _M
54 //
55 #ifdef __FreeBSD__
56 # undef _M
57 #endif
58 
59 // Test that libc++ doesn't use names that collide with FreeBSD system macros.
60 #ifndef __FreeBSD__
61 #  define __null_sentinel NASTY_MACRO
62 #endif
63 
64 // tchar.h defines these macros on Windows
65 #ifndef _WIN32
66 # define _UI   NASTY_MACRO
67 # define _PUC  NASTY_MACRO
68 # define _CPUC NASTY_MACRO
69 # define _PC   NASTY_MACRO
70 # define _CRPC NASTY_MACRO
71 # define _CPC  NASTY_MACRO
72 #endif
73 
74 // yvals.h on MINGW defines this macro
75 #ifndef _WIN32
76 # define _C2 NASTY_MACRO
77 #endif
78 
79 // Test that libc++ doesn't use names that collide with Win32 API macros.
80 // Obviously we can only define these on non-Windows platforms.
81 #ifndef _WIN32
82 # define __allocator NASTY_MACRO
83 # define __bound NASTY_MACRO
84 # define __deallocate NASTY_MACRO
85 # define __deref NASTY_MACRO
86 # define __format_string NASTY_MACRO
87 # define __full NASTY_MACRO
88 # define __in NASTY_MACRO
89 # define __inout NASTY_MACRO
90 # define __nz NASTY_MACRO
91 # define __out NASTY_MACRO
92 # define __part NASTY_MACRO
93 # define __post NASTY_MACRO
94 # define __pre NASTY_MACRO
95 #endif
96 
97 #define __input NASTY_MACRO
98 #define __output NASTY_MACRO
99 
100 #define __acquire NASTY_MACRO
101 #define __release NASTY_MACRO
102 
103 // These names are not reserved, so the user can macro-define them.
104 // These are intended to find improperly _Uglified template parameters.
105 #define A NASTY_MACRO
106 #define Arg NASTY_MACRO
107 #define Args NASTY_MACRO
108 #define As NASTY_MACRO
109 #define B NASTY_MACRO
110 #define Bs NASTY_MACRO
111 #define C NASTY_MACRO
112 #define Cp NASTY_MACRO
113 #define Cs NASTY_MACRO
114 // Windows setjmp.h contains a struct member named 'D' on ARM/AArch64.
115 #ifndef _WIN32
116 # define D NASTY_MACRO
117 #endif
118 #define Dp NASTY_MACRO
119 #define Ds NASTY_MACRO
120 #define E NASTY_MACRO
121 #define Ep NASTY_MACRO
122 #define Es NASTY_MACRO
123 #define R NASTY_MACRO
124 #define Rp NASTY_MACRO
125 #define Rs NASTY_MACRO
126 #define T NASTY_MACRO
127 #define Tp NASTY_MACRO
128 #define Ts NASTY_MACRO
129 #define Type NASTY_MACRO
130 #define Types NASTY_MACRO
131 #define U NASTY_MACRO
132 #define Up NASTY_MACRO
133 #define Us NASTY_MACRO
134 #define V NASTY_MACRO
135 #define Vp NASTY_MACRO
136 #define Vs NASTY_MACRO
137 #define X NASTY_MACRO
138 #define Xp NASTY_MACRO
139 #define Xs NASTY_MACRO
140 
141 // The classic Windows min/max macros
142 #define min NASTY_MACRO
143 #define max NASTY_MACRO
144 
145 /*
146 BEGIN-SCRIPT
147 
148 for header in public_headers:
149   print("{}#{}include <{}>{}".format(
150     '#if ' + header_restrictions[header] + '\n' if header in header_restrictions else '',
151     3 * ' ' if header in header_restrictions else '',
152     header,
153     '\n#endif' if header in header_restrictions else ''
154   ))
155 
156 END-SCRIPT
157 */
158 
159 // DO NOT MANUALLY EDIT ANYTHING BETWEEN THE MARKERS BELOW
160 // GENERATED-MARKER
161 #include <algorithm>
162 #include <any>
163 #include <array>
164 #include <atomic>
165 #if !defined(_LIBCPP_HAS_NO_THREADS)
166 #   include <barrier>
167 #endif
168 #include <bit>
169 #include <bitset>
170 #include <cassert>
171 #include <ccomplex>
172 #include <cctype>
173 #include <cerrno>
174 #include <cfenv>
175 #include <cfloat>
176 #include <charconv>
177 #include <chrono>
178 #include <cinttypes>
179 #include <ciso646>
180 #include <climits>
181 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
182 #   include <clocale>
183 #endif
184 #include <cmath>
185 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
186 #   include <codecvt>
187 #endif
188 #include <compare>
189 #include <complex>
190 #include <complex.h>
191 #include <concepts>
192 #include <condition_variable>
193 #if (defined(__cpp_impl_coroutine) && __cpp_impl_coroutine >= 201902L) || (defined(__cpp_coroutines) && __cpp_coroutines >= 201703L)
194 #   include <coroutine>
195 #endif
196 #include <csetjmp>
197 #include <csignal>
198 #include <cstdarg>
199 #include <cstdbool>
200 #include <cstddef>
201 #include <cstdint>
202 #include <cstdio>
203 #include <cstdlib>
204 #include <cstring>
205 #include <ctgmath>
206 #include <ctime>
207 #include <ctype.h>
208 #include <cuchar>
209 #if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
210 #   include <cwchar>
211 #endif
212 #if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
213 #   include <cwctype>
214 #endif
215 #include <deque>
216 #include <errno.h>
217 #include <exception>
218 #include <execution>
219 #include <expected>
220 #include <fenv.h>
221 #if !defined(_LIBCPP_HAS_NO_FILESYSTEM_LIBRARY)
222 #   include <filesystem>
223 #endif
224 #include <float.h>
225 #include <format>
226 #include <forward_list>
227 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && !defined(_LIBCPP_HAS_NO_FSTREAM)
228 #   include <fstream>
229 #endif
230 #include <functional>
231 #if !defined(_LIBCPP_HAS_NO_THREADS)
232 #   include <future>
233 #endif
234 #include <initializer_list>
235 #include <inttypes.h>
236 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
237 #   include <iomanip>
238 #endif
239 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
240 #   include <ios>
241 #endif
242 #include <iosfwd>
243 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
244 #   include <iostream>
245 #endif
246 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
247 #   include <istream>
248 #endif
249 #include <iterator>
250 #if !defined(_LIBCPP_HAS_NO_THREADS)
251 #   include <latch>
252 #endif
253 #include <limits>
254 #include <limits.h>
255 #include <list>
256 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
257 #   include <locale>
258 #endif
259 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
260 #   include <locale.h>
261 #endif
262 #include <map>
263 #include <math.h>
264 #include <memory>
265 #include <memory_resource>
266 #if !defined(_LIBCPP_HAS_NO_THREADS)
267 #   include <mutex>
268 #endif
269 #include <new>
270 #include <numbers>
271 #include <numeric>
272 #include <optional>
273 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
274 #   include <ostream>
275 #endif
276 #include <queue>
277 #include <random>
278 #include <ranges>
279 #include <ratio>
280 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
281 #   include <regex>
282 #endif
283 #include <scoped_allocator>
284 #if !defined(_LIBCPP_HAS_NO_THREADS)
285 #   include <semaphore>
286 #endif
287 #include <set>
288 #include <setjmp.h>
289 #if !defined(_LIBCPP_HAS_NO_THREADS)
290 #   include <shared_mutex>
291 #endif
292 #include <source_location>
293 #include <span>
294 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
295 #   include <sstream>
296 #endif
297 #include <stack>
298 #if __cplusplus > 202002L && !defined(_LIBCPP_HAS_NO_THREADS)
299 #   include <stdatomic.h>
300 #endif
301 #include <stdbool.h>
302 #include <stddef.h>
303 #include <stdexcept>
304 #include <stdint.h>
305 #include <stdio.h>
306 #include <stdlib.h>
307 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
308 #   include <streambuf>
309 #endif
310 #include <string>
311 #include <string.h>
312 #include <string_view>
313 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
314 #   include <strstream>
315 #endif
316 #include <system_error>
317 #include <tgmath.h>
318 #if !defined(_LIBCPP_HAS_NO_THREADS)
319 #   include <thread>
320 #endif
321 #include <tuple>
322 #include <type_traits>
323 #include <typeindex>
324 #include <typeinfo>
325 #include <uchar.h>
326 #include <unordered_map>
327 #include <unordered_set>
328 #include <utility>
329 #include <valarray>
330 #include <variant>
331 #include <vector>
332 #include <version>
333 #if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
334 #   include <wchar.h>
335 #endif
336 #if !defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)
337 #   include <wctype.h>
338 #endif
339 #if __cplusplus >= 201103L
340 #   include <experimental/deque>
341 #endif
342 #if __cplusplus >= 201103L
343 #   include <experimental/forward_list>
344 #endif
345 #if __cplusplus >= 201103L
346 #   include <experimental/iterator>
347 #endif
348 #if __cplusplus >= 201103L
349 #   include <experimental/list>
350 #endif
351 #if __cplusplus >= 201103L
352 #   include <experimental/map>
353 #endif
354 #if __cplusplus >= 201103L
355 #   include <experimental/memory_resource>
356 #endif
357 #if __cplusplus >= 201103L
358 #   include <experimental/propagate_const>
359 #endif
360 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && __cplusplus >= 201103L
361 #   include <experimental/regex>
362 #endif
363 #if __cplusplus >= 201103L
364 #   include <experimental/set>
365 #endif
366 #if __cplusplus >= 201103L
367 #   include <experimental/simd>
368 #endif
369 #if __cplusplus >= 201103L
370 #   include <experimental/string>
371 #endif
372 #if __cplusplus >= 201103L
373 #   include <experimental/type_traits>
374 #endif
375 #if __cplusplus >= 201103L
376 #   include <experimental/unordered_map>
377 #endif
378 #if __cplusplus >= 201103L
379 #   include <experimental/unordered_set>
380 #endif
381 #if __cplusplus >= 201103L
382 #   include <experimental/utility>
383 #endif
384 #if __cplusplus >= 201103L
385 #   include <experimental/vector>
386 #endif
387 #include <ext/hash_map>
388 #include <ext/hash_set>
389 // GENERATED-MARKER
390