Warning: This file is not a C or C++ file. It does not have highlighting.
| 1 | // -*- C++ -*- |
|---|---|
| 2 | //===----------------------------------------------------------------------===// |
| 3 | // |
| 4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef SUPPORT_TEST_MACROS_HPP |
| 11 | #define SUPPORT_TEST_MACROS_HPP |
| 12 | |
| 13 | #ifdef __has_include |
| 14 | # if __has_include(<version>) |
| 15 | # include <version> |
| 16 | # else |
| 17 | # include <ciso646> |
| 18 | # endif |
| 19 | #else |
| 20 | # include <ciso646> |
| 21 | #endif |
| 22 | |
| 23 | #define TEST_STRINGIZE_IMPL(...) #__VA_ARGS__ |
| 24 | #define TEST_STRINGIZE(...) TEST_STRINGIZE_IMPL(__VA_ARGS__) |
| 25 | |
| 26 | #define TEST_CONCAT1(X, Y) X##Y |
| 27 | #define TEST_CONCAT(X, Y) TEST_CONCAT1(X, Y) |
| 28 | |
| 29 | #ifdef __has_feature |
| 30 | #define TEST_HAS_FEATURE(X) __has_feature(X) |
| 31 | #else |
| 32 | #define TEST_HAS_FEATURE(X) 0 |
| 33 | #endif |
| 34 | |
| 35 | #ifndef __has_include |
| 36 | #define __has_include(...) 0 |
| 37 | #endif |
| 38 | |
| 39 | #ifdef __has_extension |
| 40 | #define TEST_HAS_EXTENSION(X) __has_extension(X) |
| 41 | #else |
| 42 | #define TEST_HAS_EXTENSION(X) 0 |
| 43 | #endif |
| 44 | |
| 45 | #ifdef __has_warning |
| 46 | #define TEST_HAS_WARNING(X) __has_warning(X) |
| 47 | #else |
| 48 | #define TEST_HAS_WARNING(X) 0 |
| 49 | #endif |
| 50 | |
| 51 | #ifdef __has_builtin |
| 52 | #define TEST_HAS_BUILTIN(X) __has_builtin(X) |
| 53 | #else |
| 54 | #define TEST_HAS_BUILTIN(X) 0 |
| 55 | #endif |
| 56 | #ifdef __is_identifier |
| 57 | // '__is_identifier' returns '0' if '__x' is a reserved identifier provided by |
| 58 | // the compiler and '1' otherwise. |
| 59 | #define TEST_HAS_BUILTIN_IDENTIFIER(X) !__is_identifier(X) |
| 60 | #else |
| 61 | #define TEST_HAS_BUILTIN_IDENTIFIER(X) 0 |
| 62 | #endif |
| 63 | |
| 64 | #if defined(__EDG__) |
| 65 | # define TEST_COMPILER_EDG |
| 66 | #elif defined(__clang__) |
| 67 | # define TEST_COMPILER_CLANG |
| 68 | # if defined(__apple_build_version__) |
| 69 | # define TEST_COMPILER_APPLE_CLANG |
| 70 | # endif |
| 71 | #elif defined(_MSC_VER) |
| 72 | # define TEST_COMPILER_MSVC |
| 73 | #elif defined(__GNUC__) |
| 74 | # define TEST_COMPILER_GCC |
| 75 | #endif |
| 76 | |
| 77 | #if defined(__apple_build_version__) |
| 78 | // Given AppleClang XX.Y.Z, TEST_APPLE_CLANG_VER is XXYZ (e.g. AppleClang 14.0.3 => 1403) |
| 79 | #define TEST_APPLE_CLANG_VER (__apple_build_version__ / 10000) |
| 80 | #elif defined(__clang_major__) |
| 81 | #define TEST_CLANG_VER (__clang_major__ * 100) + __clang_minor__ |
| 82 | #elif defined(__GNUC__) |
| 83 | // Given GCC XX.YY.ZZ, TEST_GCC_VER is XXYYZZ |
| 84 | #define TEST_GCC_VER ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__) |
| 85 | #endif |
| 86 | |
| 87 | /* Make a nice name for the standard version */ |
| 88 | #ifndef TEST_STD_VER |
| 89 | #if __cplusplus <= 199711L |
| 90 | # define TEST_STD_VER 3 |
| 91 | #elif __cplusplus <= 201103L |
| 92 | # define TEST_STD_VER 11 |
| 93 | #elif __cplusplus <= 201402L |
| 94 | # define TEST_STD_VER 14 |
| 95 | #elif __cplusplus <= 201703L |
| 96 | # define TEST_STD_VER 17 |
| 97 | #elif __cplusplus <= 202002L |
| 98 | # define TEST_STD_VER 20 |
| 99 | #elif __cplusplus <= 202302L |
| 100 | # define TEST_STD_VER 23 |
| 101 | #else |
| 102 | # define TEST_STD_VER 99 // greater than current standard |
| 103 | // This is deliberately different than _LIBCPP_STD_VER to discourage matching them up. |
| 104 | #endif |
| 105 | #endif |
| 106 | |
| 107 | // Attempt to deduce the GLIBC version |
| 108 | #if (defined(__has_include) && __has_include(<features.h>)) || \ |
| 109 | defined(__linux__) |
| 110 | #include <features.h> |
| 111 | #if defined(__GLIBC_PREREQ) |
| 112 | #define TEST_HAS_GLIBC |
| 113 | #define TEST_GLIBC_PREREQ(major, minor) __GLIBC_PREREQ(major, minor) |
| 114 | #endif |
| 115 | #endif |
| 116 | |
| 117 | #if TEST_STD_VER >= 11 |
| 118 | # define TEST_ALIGNOF(...) alignof(__VA_ARGS__) |
| 119 | # define TEST_ALIGNAS(...) alignas(__VA_ARGS__) |
| 120 | # define TEST_CONSTEXPR constexpr |
| 121 | # define TEST_NOEXCEPT noexcept |
| 122 | # define TEST_NOEXCEPT_FALSE noexcept(false) |
| 123 | # define TEST_NOEXCEPT_COND(...) noexcept(__VA_ARGS__) |
| 124 | #else |
| 125 | # if defined(TEST_COMPILER_CLANG) |
| 126 | # define TEST_ALIGNOF(...) _Alignof(__VA_ARGS__) |
| 127 | # else |
| 128 | # define TEST_ALIGNOF(...) __alignof(__VA_ARGS__) |
| 129 | # endif |
| 130 | # define TEST_ALIGNAS(...) __attribute__((__aligned__(__VA_ARGS__))) |
| 131 | # define TEST_CONSTEXPR |
| 132 | # define TEST_NOEXCEPT throw() |
| 133 | # define TEST_NOEXCEPT_FALSE |
| 134 | # define TEST_NOEXCEPT_COND(...) |
| 135 | #endif |
| 136 | |
| 137 | #if TEST_STD_VER >= 11 |
| 138 | # define TEST_THROW_SPEC(...) |
| 139 | #else |
| 140 | # define TEST_THROW_SPEC(...) throw(__VA_ARGS__) |
| 141 | #endif |
| 142 | |
| 143 | #if defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811L |
| 144 | # define TEST_IS_CONSTANT_EVALUATED std::is_constant_evaluated() |
| 145 | #elif TEST_HAS_BUILTIN(__builtin_is_constant_evaluated) |
| 146 | # define TEST_IS_CONSTANT_EVALUATED __builtin_is_constant_evaluated() |
| 147 | #else |
| 148 | # define TEST_IS_CONSTANT_EVALUATED false |
| 149 | #endif |
| 150 | |
| 151 | #if TEST_STD_VER >= 20 |
| 152 | # define TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED true |
| 153 | #else |
| 154 | # define TEST_STD_AT_LEAST_20_OR_RUNTIME_EVALUATED (!TEST_IS_CONSTANT_EVALUATED) |
| 155 | #endif |
| 156 | |
| 157 | #if TEST_STD_VER >= 23 |
| 158 | # define TEST_STD_AT_LEAST_23_OR_RUNTIME_EVALUATED true |
| 159 | #else |
| 160 | # define TEST_STD_AT_LEAST_23_OR_RUNTIME_EVALUATED (!TEST_IS_CONSTANT_EVALUATED) |
| 161 | #endif |
| 162 | |
| 163 | #if TEST_STD_VER >= 26 |
| 164 | # define TEST_STD_AT_LEAST_26_OR_RUNTIME_EVALUATED true |
| 165 | #else |
| 166 | # define TEST_STD_AT_LEAST_26_OR_RUNTIME_EVALUATED (!TEST_IS_CONSTANT_EVALUATED) |
| 167 | #endif |
| 168 | |
| 169 | #if TEST_STD_VER >= 14 |
| 170 | # define TEST_CONSTEXPR_CXX14 constexpr |
| 171 | #else |
| 172 | # define TEST_CONSTEXPR_CXX14 |
| 173 | #endif |
| 174 | |
| 175 | #if TEST_STD_VER >= 17 |
| 176 | # define TEST_CONSTEXPR_CXX17 constexpr |
| 177 | #else |
| 178 | # define TEST_CONSTEXPR_CXX17 |
| 179 | #endif |
| 180 | |
| 181 | #if TEST_STD_VER >= 20 |
| 182 | # define TEST_CONSTEXPR_CXX20 constexpr |
| 183 | #else |
| 184 | # define TEST_CONSTEXPR_CXX20 |
| 185 | #endif |
| 186 | |
| 187 | #if TEST_STD_VER >= 23 |
| 188 | # define TEST_CONSTEXPR_CXX23 constexpr |
| 189 | #else |
| 190 | # define TEST_CONSTEXPR_CXX23 |
| 191 | #endif |
| 192 | |
| 193 | #if TEST_STD_VER >= 26 |
| 194 | # define TEST_CONSTEXPR_CXX26 constexpr |
| 195 | #else |
| 196 | # define TEST_CONSTEXPR_CXX26 |
| 197 | #endif |
| 198 | |
| 199 | #define TEST_ALIGNAS_TYPE(...) TEST_ALIGNAS(TEST_ALIGNOF(__VA_ARGS__)) |
| 200 | |
| 201 | #if !TEST_HAS_FEATURE(cxx_rtti) && !defined(__cpp_rtti) \ |
| 202 | && !defined(__GXX_RTTI) |
| 203 | #define TEST_HAS_NO_RTTI |
| 204 | #endif |
| 205 | |
| 206 | #if !defined(TEST_HAS_NO_RTTI) |
| 207 | # define RTTI_ASSERT(X) assert(X) |
| 208 | #else |
| 209 | # define RTTI_ASSERT(X) |
| 210 | #endif |
| 211 | |
| 212 | #if !TEST_HAS_FEATURE(cxx_exceptions) && !defined(__cpp_exceptions) \ |
| 213 | && !defined(__EXCEPTIONS) |
| 214 | #define TEST_HAS_NO_EXCEPTIONS |
| 215 | #endif |
| 216 | |
| 217 | #if TEST_HAS_FEATURE(address_sanitizer) || TEST_HAS_FEATURE(hwaddress_sanitizer) || \ |
| 218 | TEST_HAS_FEATURE(memory_sanitizer) || TEST_HAS_FEATURE(thread_sanitizer) |
| 219 | #define TEST_HAS_SANITIZERS |
| 220 | #define TEST_IS_EXECUTED_IN_A_SLOW_ENVIRONMENT |
| 221 | #endif |
| 222 | |
| 223 | #ifdef _LIBCPP_USE_FROZEN_CXX03_HEADERS |
| 224 | # ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION |
| 225 | # define TEST_HAS_NO_ALIGNED_ALLOCATION |
| 226 | # endif |
| 227 | #elif defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_ALIGNED_ALLOCATION |
| 228 | # define TEST_HAS_NO_ALIGNED_ALLOCATION |
| 229 | #elif TEST_STD_VER < 17 && (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606L) |
| 230 | # define TEST_HAS_NO_ALIGNED_ALLOCATION |
| 231 | #endif |
| 232 | |
| 233 | #if TEST_STD_VER > 17 |
| 234 | # define TEST_CONSTINIT constinit |
| 235 | #elif __has_cpp_attribute(clang::require_constant_initialization) |
| 236 | # define TEST_CONSTINIT [[clang::require_constant_initialization]] |
| 237 | #else |
| 238 | # define TEST_CONSTINIT |
| 239 | #endif |
| 240 | |
| 241 | #if TEST_STD_VER < 11 |
| 242 | #define ASSERT_NOEXCEPT(...) |
| 243 | #define ASSERT_NOT_NOEXCEPT(...) |
| 244 | #else |
| 245 | #define ASSERT_NOEXCEPT(...) \ |
| 246 | static_assert(noexcept(__VA_ARGS__), "Operation must be noexcept") |
| 247 | |
| 248 | #define ASSERT_NOT_NOEXCEPT(...) \ |
| 249 | static_assert(!noexcept(__VA_ARGS__), "Operation must NOT be noexcept") |
| 250 | #endif |
| 251 | |
| 252 | /* Macros for testing libc++ specific behavior and extensions */ |
| 253 | #if defined(_LIBCPP_VERSION) |
| 254 | #define LIBCPP_ASSERT(...) assert(__VA_ARGS__) |
| 255 | #define LIBCPP_STATIC_ASSERT(...) static_assert(__VA_ARGS__) |
| 256 | #define LIBCPP_ASSERT_NOEXCEPT(...) ASSERT_NOEXCEPT(__VA_ARGS__) |
| 257 | #define LIBCPP_ASSERT_NOT_NOEXCEPT(...) ASSERT_NOT_NOEXCEPT(__VA_ARGS__) |
| 258 | #define LIBCPP_ONLY(...) __VA_ARGS__ |
| 259 | #else |
| 260 | #define LIBCPP_ASSERT(...) static_assert(true, "") |
| 261 | #define LIBCPP_STATIC_ASSERT(...) static_assert(true, "") |
| 262 | #define LIBCPP_ASSERT_NOEXCEPT(...) static_assert(true, "") |
| 263 | #define LIBCPP_ASSERT_NOT_NOEXCEPT(...) static_assert(true, "") |
| 264 | #define LIBCPP_ONLY(...) static_assert(true, "") |
| 265 | #endif |
| 266 | |
| 267 | #if __has_cpp_attribute(nodiscard) |
| 268 | # define TEST_NODISCARD [[nodiscard]] |
| 269 | #else |
| 270 | # define TEST_NODISCARD |
| 271 | #endif |
| 272 | |
| 273 | #define TEST_IGNORE_NODISCARD (void) |
| 274 | |
| 275 | #ifdef _LIBCPP_USE_FROZEN_CXX03_HEADERS |
| 276 | // from-chars is a C++17 feature, so it's never available anyways |
| 277 | #elif !defined(_LIBCPP_VERSION) || _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT |
| 278 | # define TEST_HAS_FROM_CHARS_FLOATING_POINT |
| 279 | #endif |
| 280 | |
| 281 | namespace test_macros_detail { |
| 282 | template <class T, class U> |
| 283 | struct is_same { enum { value = 0};} ; |
| 284 | template <class T> |
| 285 | struct is_same<T, T> { enum {value = 1}; }; |
| 286 | } // namespace test_macros_detail |
| 287 | |
| 288 | #define ASSERT_SAME_TYPE(...) \ |
| 289 | static_assert((test_macros_detail::is_same<__VA_ARGS__>::value), \ |
| 290 | "Types differ unexpectedly") |
| 291 | |
| 292 | #ifndef TEST_HAS_NO_EXCEPTIONS |
| 293 | #define TEST_THROW(...) throw __VA_ARGS__ |
| 294 | #else |
| 295 | #if defined(__GNUC__) |
| 296 | #define TEST_THROW(...) __builtin_abort() |
| 297 | #else |
| 298 | #include <stdlib.h> |
| 299 | #define TEST_THROW(...) ::abort() |
| 300 | #endif |
| 301 | #endif |
| 302 | |
| 303 | #if defined(__GNUC__) || defined(__clang__) |
| 304 | // This function can be used to hide some objects from compiler optimizations. |
| 305 | // |
| 306 | // For example, this is useful to hide the result of a call to `new` and ensure |
| 307 | // that the compiler doesn't elide the call to new/delete. Otherwise, elliding |
| 308 | // calls to new/delete is allowed by the Standard and compilers actually do it |
| 309 | // when optimizations are enabled. |
| 310 | template <class Tp> |
| 311 | inline Tp const& DoNotOptimize(Tp const& value) { |
| 312 | // The `m` constraint is invalid in the AMDGPU backend. |
| 313 | # if defined(__AMDGPU__) || defined(__NVPTX__) |
| 314 | asm volatile("" : : "r"(value) : "memory"); |
| 315 | # else |
| 316 | asm volatile("" : : "r,m"(value) : "memory"); |
| 317 | # endif |
| 318 | return value; |
| 319 | } |
| 320 | |
| 321 | template <class Tp> |
| 322 | inline Tp& DoNotOptimize(Tp& value) { |
| 323 | // The `m` and `r` output constraint is invalid in the AMDGPU backend as well |
| 324 | // as i8 / i1 arguments, so we just capture the pointer instead. |
| 325 | # if defined(__AMDGPU__) |
| 326 | Tp* tmp = &value; |
| 327 | asm volatile("" : "+v"(tmp) : : "memory"); |
| 328 | # elif defined(__clang__) |
| 329 | asm volatile("" : "+r,m"(value) : : "memory"); |
| 330 | # else |
| 331 | asm volatile("" : "+m,r"(value) : : "memory"); |
| 332 | # endif |
| 333 | return value; |
| 334 | } |
| 335 | #else |
| 336 | #include <intrin.h> |
| 337 | template <class Tp> |
| 338 | inline Tp const& DoNotOptimize(Tp const& value) { |
| 339 | const volatile void* volatile unused = __builtin_addressof(value); |
| 340 | static_cast<void>(unused); |
| 341 | _ReadWriteBarrier(); |
| 342 | return value; |
| 343 | } |
| 344 | #endif |
| 345 | |
| 346 | #if defined(__GNUC__) |
| 347 | #define TEST_ALWAYS_INLINE __attribute__((always_inline)) |
| 348 | #define TEST_NOINLINE __attribute__((noinline)) |
| 349 | #elif defined(_MSC_VER) |
| 350 | #define TEST_ALWAYS_INLINE __forceinline |
| 351 | #define TEST_NOINLINE __declspec(noinline) |
| 352 | #else |
| 353 | #define TEST_ALWAYS_INLINE |
| 354 | #define TEST_NOINLINE |
| 355 | #endif |
| 356 | |
| 357 | #ifdef _WIN32 |
| 358 | #define TEST_NOT_WIN32(...) ((void)0) |
| 359 | #else |
| 360 | #define TEST_NOT_WIN32(...) __VA_ARGS__ |
| 361 | #endif |
| 362 | |
| 363 | #if defined(TEST_WINDOWS_DLL) ||defined(__MVS__) || defined(_AIX) |
| 364 | // Macros for waiving cases when we can't count allocations done within |
| 365 | // the library implementation. |
| 366 | // |
| 367 | // On Windows, when libc++ is built as a DLL, references to operator new/delete |
| 368 | // within the DLL are bound at link time to the operator new/delete within |
| 369 | // the library; replacing them in the user executable doesn't override the |
| 370 | // calls within the library. |
| 371 | // |
| 372 | // The same goes on IBM zOS. |
| 373 | // The same goes on AIX. |
| 374 | #define ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(...) ((void)(__VA_ARGS__)) |
| 375 | #define TEST_SUPPORTS_LIBRARY_INTERNAL_ALLOCATIONS 0 |
| 376 | #else |
| 377 | #define ASSERT_WITH_LIBRARY_INTERNAL_ALLOCATIONS(...) assert(__VA_ARGS__) |
| 378 | #define TEST_SUPPORTS_LIBRARY_INTERNAL_ALLOCATIONS 1 |
| 379 | #endif |
| 380 | |
| 381 | #if (defined(TEST_WINDOWS_DLL) && !defined(_MSC_VER)) || \ |
| 382 | defined(__MVS__) |
| 383 | // Normally, a replaced e.g. 'operator new' ends up used if the user code |
| 384 | // does a call to e.g. 'operator new[]'; it's enough to replace the base |
| 385 | // versions and have it override all of them. |
| 386 | // |
| 387 | // When the fallback operators are located within the libc++ library and we |
| 388 | // can't override the calls within it (see above), this fallback mechanism |
| 389 | // doesn't work either. |
| 390 | // |
| 391 | // On Windows, when using the MSVC vcruntime, the operator new/delete fallbacks |
| 392 | // are linked separately from the libc++ library, linked statically into |
| 393 | // the end user executable, and these fallbacks work even in DLL configurations. |
| 394 | // In MinGW configurations when built as a DLL, and on zOS, these fallbacks |
| 395 | // don't work though. |
| 396 | #define ASSERT_WITH_OPERATOR_NEW_FALLBACKS(...) ((void)(__VA_ARGS__)) |
| 397 | #else |
| 398 | #define ASSERT_WITH_OPERATOR_NEW_FALLBACKS(...) assert(__VA_ARGS__) |
| 399 | #endif |
| 400 | |
| 401 | #ifdef _WIN32 |
| 402 | #define TEST_WIN_NO_FILESYSTEM_PERMS_NONE |
| 403 | #endif |
| 404 | |
| 405 | // Support for carving out parts of the test suite, like removing wide characters, etc. |
| 406 | #if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_WIDE_CHARACTERS |
| 407 | # define TEST_HAS_NO_WIDE_CHARACTERS |
| 408 | #endif |
| 409 | |
| 410 | #if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_UNICODE |
| 411 | # define TEST_HAS_NO_UNICODE |
| 412 | #elif defined(_MSVC_EXECUTION_CHARACTER_SET) && _MSVC_EXECUTION_CHARACTER_SET != 65001 |
| 413 | # define TEST_HAS_NO_UNICODE |
| 414 | #endif |
| 415 | |
| 416 | #ifdef _LIBCPP_USE_FROZEN_CXX03_HEADERS |
| 417 | # ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 418 | # define TEST_HAS_OPEN_WITH_WCHAR |
| 419 | # endif |
| 420 | #elif defined(_LIBCPP_VERSION) && _LIBCPP_HAS_OPEN_WITH_WCHAR |
| 421 | # define TEST_HAS_OPEN_WITH_WCHAR |
| 422 | #endif |
| 423 | |
| 424 | #ifdef _LIBCPP_USE_FROZEN_CXX03_HEADERS |
| 425 | # ifdef _LIBCPP_HAS_NO_INT128 |
| 426 | # define TEST_HAS_NO_INT128 |
| 427 | # endif |
| 428 | #elif (defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_INT128) || defined(_MSVC_STL_VERSION) |
| 429 | # define TEST_HAS_NO_INT128 |
| 430 | #endif |
| 431 | |
| 432 | #if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_LOCALIZATION |
| 433 | # define TEST_HAS_NO_LOCALIZATION |
| 434 | #endif |
| 435 | |
| 436 | #if TEST_STD_VER <= 17 || !defined(__cpp_char8_t) |
| 437 | # define TEST_HAS_NO_CHAR8_T |
| 438 | #endif |
| 439 | |
| 440 | #if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_THREADS |
| 441 | # define TEST_HAS_NO_THREADS |
| 442 | #endif |
| 443 | |
| 444 | #if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_FILESYSTEM |
| 445 | # define TEST_HAS_NO_FILESYSTEM |
| 446 | #endif |
| 447 | |
| 448 | #ifdef _LIBCPP_USE_FROZEN_CXX03_HEADERS |
| 449 | # ifdef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 |
| 450 | # define TEST_HAS_NO_C8RTOMB_MBRTOC8 |
| 451 | # endif |
| 452 | #elif defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_C8RTOMB_MBRTOC8 |
| 453 | # define TEST_HAS_NO_C8RTOMB_MBRTOC8 |
| 454 | #endif |
| 455 | |
| 456 | #if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_RANDOM_DEVICE |
| 457 | # define TEST_HAS_NO_RANDOM_DEVICE |
| 458 | #endif |
| 459 | |
| 460 | #ifdef _LIBCPP_USE_FROZEN_CXX03_HEADERS |
| 461 | // This is a C++20 feature, so it's never available anyways |
| 462 | # define TEST_HAS_NO_EXPERIMENTAL_TZDB |
| 463 | #elif defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_EXPERIMENTAL_TZDB |
| 464 | # define TEST_HAS_NO_EXPERIMENTAL_TZDB |
| 465 | #endif |
| 466 | |
| 467 | #if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_TIME_ZONE_DATABASE |
| 468 | # define TEST_HAS_NO_TIME_ZONE_DATABASE |
| 469 | #endif |
| 470 | |
| 471 | #if defined(TEST_COMPILER_CLANG) |
| 472 | # define TEST_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") |
| 473 | # define TEST_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") |
| 474 | # define TEST_CLANG_DIAGNOSTIC_IGNORED(str) _Pragma(TEST_STRINGIZE(clang diagnostic ignored str)) |
| 475 | # define TEST_GCC_DIAGNOSTIC_IGNORED(str) |
| 476 | # define TEST_MSVC_DIAGNOSTIC_IGNORED(num) |
| 477 | #elif defined(TEST_COMPILER_GCC) |
| 478 | # define TEST_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") |
| 479 | # define TEST_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") |
| 480 | # define TEST_CLANG_DIAGNOSTIC_IGNORED(str) |
| 481 | # define TEST_GCC_DIAGNOSTIC_IGNORED(str) _Pragma(TEST_STRINGIZE(GCC diagnostic ignored str)) |
| 482 | # define TEST_MSVC_DIAGNOSTIC_IGNORED(num) |
| 483 | #elif defined(TEST_COMPILER_MSVC) |
| 484 | # define TEST_DIAGNOSTIC_PUSH _Pragma("warning(push)") |
| 485 | # define TEST_DIAGNOSTIC_POP _Pragma("warning(pop)") |
| 486 | # define TEST_CLANG_DIAGNOSTIC_IGNORED(str) |
| 487 | # define TEST_GCC_DIAGNOSTIC_IGNORED(str) |
| 488 | # define TEST_MSVC_DIAGNOSTIC_IGNORED(num) _Pragma(TEST_STRINGIZE(warning(disable: num))) |
| 489 | #else |
| 490 | # define TEST_DIAGNOSTIC_PUSH |
| 491 | # define TEST_DIAGNOSTIC_POP |
| 492 | # define TEST_CLANG_DIAGNOSTIC_IGNORED(str) |
| 493 | # define TEST_GCC_DIAGNOSTIC_IGNORED(str) |
| 494 | # define TEST_MSVC_DIAGNOSTIC_IGNORED(num) |
| 495 | #endif |
| 496 | |
| 497 | #if __has_cpp_attribute(msvc::no_unique_address) |
| 498 | #define TEST_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]] |
| 499 | #elif __has_cpp_attribute(no_unique_address) |
| 500 | #define TEST_NO_UNIQUE_ADDRESS [[no_unique_address]] |
| 501 | #else |
| 502 | #define TEST_NO_UNIQUE_ADDRESS |
| 503 | #endif |
| 504 | |
| 505 | #ifdef _LIBCPP_SHORT_WCHAR |
| 506 | # define TEST_SHORT_WCHAR |
| 507 | #endif |
| 508 | |
| 509 | #ifdef _LIBCPP_ABI_MICROSOFT |
| 510 | # define TEST_ABI_MICROSOFT |
| 511 | #endif |
| 512 | |
| 513 | // This is a temporary workaround for user-defined `operator new` definitions |
| 514 | // not being picked up on Apple platforms in some circumstances. This is under |
| 515 | // investigation and should be short-lived. |
| 516 | #ifdef __APPLE__ |
| 517 | # define TEST_WORKAROUND_BUG_109234844_WEAK __attribute__((weak)) |
| 518 | #else |
| 519 | # define TEST_WORKAROUND_BUG_109234844_WEAK /* nothing */ |
| 520 | #endif |
| 521 | |
| 522 | #ifdef _AIX |
| 523 | # define TEST_IF_AIX(arg_true, arg_false) arg_true |
| 524 | #else |
| 525 | # define TEST_IF_AIX(arg_true, arg_false) arg_false |
| 526 | #endif |
| 527 | |
| 528 | // Clang-18 has support for deducing this, but it does not set the FTM. |
| 529 | #ifdef _LIBCPP_USE_FROZEN_CXX03_HEADERS |
| 530 | // This is a C++20 featue, so we don't care whether the compiler could support it |
| 531 | #elif defined(_LIBCPP_VERSION) && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER |
| 532 | # define TEST_HAS_EXPLICIT_THIS_PARAMETER |
| 533 | #endif |
| 534 | |
| 535 | // Placement `operator new`/`operator new[]` are not yet constexpr in C++26 |
| 536 | // when using MS ABI, because they are from <vcruntime_new.h>. |
| 537 | #if defined(__cpp_lib_constexpr_new) && __cpp_lib_constexpr_new >= 202406L |
| 538 | # define TEST_CONSTEXPR_OPERATOR_NEW constexpr |
| 539 | #else |
| 540 | # define TEST_CONSTEXPR_OPERATOR_NEW |
| 541 | #endif |
| 542 | |
| 543 | #if defined(_MSC_VER) || __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 544 | # define TEST_LONG_DOUBLE_IS_DOUBLE |
| 545 | #endif |
| 546 | |
| 547 | #if defined(__LDBL_MANT_DIG__) && __LDBL_MANT_DIG__ == 64 |
| 548 | # define TEST_LONG_DOUBLE_IS_80_BIT |
| 549 | #endif |
| 550 | |
| 551 | #endif // SUPPORT_TEST_MACROS_HPP |
| 552 |
Warning: This file is not a C or C++ file. It does not have highlighting.
