diff --git a/libcxx/include/__atomic/aliases.h b/libcxx/include/__atomic/aliases.h index e27e09af6b77d..afc64eaaa69e7 100644 --- a/libcxx/include/__atomic/aliases.h +++ b/libcxx/include/__atomic/aliases.h @@ -37,7 +37,7 @@ using atomic_long = atomic; using atomic_ulong = atomic; using atomic_llong = atomic; using atomic_ullong = atomic; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T using atomic_char8_t = atomic; #endif using atomic_char16_t = atomic; diff --git a/libcxx/include/__atomic/atomic_lock_free.h b/libcxx/include/__atomic/atomic_lock_free.h index 0715439db4503..3ae9b8856e810 100644 --- a/libcxx/include/__atomic/atomic_lock_free.h +++ b/libcxx/include/__atomic/atomic_lock_free.h @@ -18,7 +18,7 @@ #if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE) # define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE # define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T # define ATOMIC_CHAR8_T_LOCK_FREE __CLANG_ATOMIC_CHAR8_T_LOCK_FREE # endif # define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE @@ -32,7 +32,7 @@ #elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE) # define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE # define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T # define ATOMIC_CHAR8_T_LOCK_FREE __GCC_ATOMIC_CHAR8_T_LOCK_FREE # endif # define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE diff --git a/libcxx/include/__bit/byteswap.h b/libcxx/include/__bit/byteswap.h index 6225ecf2f92df..d761e6a6fdb46 100644 --- a/libcxx/include/__bit/byteswap.h +++ b/libcxx/include/__bit/byteswap.h @@ -32,7 +32,7 @@ template return __builtin_bswap32(__val); } else if constexpr (sizeof(_Tp) == 8) { return __builtin_bswap64(__val); -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 } else if constexpr (sizeof(_Tp) == 16) { # if __has_builtin(__builtin_bswap128) return __builtin_bswap128(__val); @@ -40,7 +40,7 @@ template return static_cast<_Tp>(byteswap(static_cast(__val))) << 64 | static_cast<_Tp>(byteswap(static_cast(__val >> 64))); # endif // __has_builtin(__builtin_bswap128) -# endif // _LIBCPP_HAS_NO_INT128 +# endif // _LIBCPP_HAS_INT128 } else { static_assert(sizeof(_Tp) == 0, "byteswap is unimplemented for integral types of this size"); } diff --git a/libcxx/include/__bit/countl.h b/libcxx/include/__bit/countl.h index bb09e8e5b5856..d4df1d049b294 100644 --- a/libcxx/include/__bit/countl.h +++ b/libcxx/include/__bit/countl.h @@ -39,7 +39,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD return __builtin_clzll(__x); } -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) _NOEXCEPT { # if __has_builtin(__builtin_clzg) return __builtin_clzg(__x); @@ -57,7 +57,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x) : __builtin_clzll(static_cast(__x >> 64)); # endif } -#endif // _LIBCPP_HAS_NO_INT128 +#endif // _LIBCPP_HAS_INT128 template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT { diff --git a/libcxx/include/__charconv/tables.h b/libcxx/include/__charconv/tables.h index 6b93536b8c1ba..9568bf841cd02 100644 --- a/libcxx/include/__charconv/tables.h +++ b/libcxx/include/__charconv/tables.h @@ -95,7 +95,7 @@ inline constexpr uint64_t __pow10_64[20] = { UINT64_C(1000000000000000000), UINT64_C(10000000000000000000)}; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 inline constexpr int __pow10_128_offset = 0; inline constexpr __uint128_t __pow10_128[40] = { UINT64_C(0), diff --git a/libcxx/include/__charconv/to_chars_base_10.h b/libcxx/include/__charconv/to_chars_base_10.h index c49f4f6797aa4..06e4e692337df 100644 --- a/libcxx/include/__charconv/to_chars_base_10.h +++ b/libcxx/include/__charconv/to_chars_base_10.h @@ -124,7 +124,7 @@ __base_10_u64(char* __buffer, uint64_t __value) noexcept { return __itoa::__append10(__buffer, __value); } -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 /// \returns 10^\a exp /// /// \pre \a exp [19, 39] diff --git a/libcxx/include/__charconv/to_chars_integral.h b/libcxx/include/__charconv/to_chars_integral.h index ccb5856df1799..fd92be4b4ce91 100644 --- a/libcxx/include/__charconv/to_chars_integral.h +++ b/libcxx/include/__charconv/to_chars_integral.h @@ -71,7 +71,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type) { return {__last, errc::value_too_large}; } -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 template <> inline _LIBCPP_CONSTEXPR_SINCE_CXX23 _LIBCPP_HIDE_FROM_ABI to_chars_result __to_chars_itoa(char* __first, char* __last, __uint128_t __value, false_type) { diff --git a/libcxx/include/__charconv/traits.h b/libcxx/include/__charconv/traits.h index c91c6da324797..2cb37c8cfb023 100644 --- a/libcxx/include/__charconv/traits.h +++ b/libcxx/include/__charconv/traits.h @@ -88,7 +88,7 @@ struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t > { using type = __uint128_t; diff --git a/libcxx/include/__chrono/exception.h b/libcxx/include/__chrono/exception.h index cc408d78a36da..64484fb551b77 100644 --- a/libcxx/include/__chrono/exception.h +++ b/libcxx/include/__chrono/exception.h @@ -73,7 +73,7 @@ class nonexistent_local_time : public runtime_error { template [[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_nonexistent_local_time( [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw nonexistent_local_time(__time, __info); # else _LIBCPP_VERBOSE_ABORT("nonexistent_local_time was thrown in -fno-exceptions mode"); @@ -117,7 +117,7 @@ class ambiguous_local_time : public runtime_error { template [[noreturn]] _LIBCPP_AVAILABILITY_TZDB _LIBCPP_HIDE_FROM_ABI void __throw_ambiguous_local_time( [[maybe_unused]] const local_time<_Duration>& __time, [[maybe_unused]] const local_info& __info) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw ambiguous_local_time(__time, __info); # else _LIBCPP_VERBOSE_ABORT("ambiguous_local_time was thrown in -fno-exceptions mode"); diff --git a/libcxx/include/__chrono/file_clock.h b/libcxx/include/__chrono/file_clock.h index 4dd3f88ce5ba4..b4b7e9dc14e70 100644 --- a/libcxx/include/__chrono/file_clock.h +++ b/libcxx/include/__chrono/file_clock.h @@ -47,7 +47,7 @@ _LIBCPP_END_NAMESPACE_STD #ifndef _LIBCPP_CXX03_LANG _LIBCPP_BEGIN_NAMESPACE_FILESYSTEM struct _FilesystemClock { -# if !defined(_LIBCPP_HAS_NO_INT128) +# if _LIBCPP_HAS_INT128 typedef __int128_t rep; typedef nano period; # else diff --git a/libcxx/include/__condition_variable/condition_variable.h b/libcxx/include/__condition_variable/condition_variable.h index de35aaca1070e..61412541b4b51 100644 --- a/libcxx/include/__condition_variable/condition_variable.h +++ b/libcxx/include/__condition_variable/condition_variable.h @@ -45,7 +45,7 @@ class _LIBCPP_EXPORTED_FROM_ABI condition_variable { public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default; -# ifdef _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION +# if _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION ~condition_variable() = default; # else ~condition_variable(); @@ -83,7 +83,7 @@ class _LIBCPP_EXPORTED_FROM_ABI condition_variable { private: void __do_timed_wait(unique_lock& __lk, chrono::time_point) _NOEXCEPT; -# if defined(_LIBCPP_HAS_COND_CLOCKWAIT) +# if _LIBCPP_HAS_COND_CLOCKWAIT _LIBCPP_HIDE_FROM_ABI void __do_timed_wait(unique_lock& __lk, chrono::time_point) _NOEXCEPT; # endif @@ -180,7 +180,7 @@ cv_status condition_variable::wait_for(unique_lock& __lk, const chrono::d using __ns_rep = nanoseconds::rep; steady_clock::time_point __c_now = steady_clock::now(); -# if defined(_LIBCPP_HAS_COND_CLOCKWAIT) +# if _LIBCPP_HAS_COND_CLOCKWAIT using __clock_tp_ns = time_point; __ns_rep __now_count_ns = std::__safe_nanosecond_cast(__c_now.time_since_epoch()).count(); # else @@ -205,7 +205,7 @@ condition_variable::wait_for(unique_lock& __lk, const chrono::duration<_R return wait_until(__lk, chrono::steady_clock::now() + __d, std::move(__pred)); } -# if defined(_LIBCPP_HAS_COND_CLOCKWAIT) +# if _LIBCPP_HAS_COND_CLOCKWAIT inline void condition_variable::__do_timed_wait( unique_lock& __lk, chrono::time_point __tp) _NOEXCEPT { using namespace chrono; diff --git a/libcxx/include/__config b/libcxx/include/__config index 0d71264611ff6..fcba56f7e3d5b 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -225,9 +225,14 @@ _LIBCPP_HARDENING_MODE_DEBUG # define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif # if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__)) -# define _LIBCPP_HAS_BITSCAN64 +# define _LIBCPP_HAS_BITSCAN64 1 +# else +# define _LIBCPP_HAS_BITSCAN64 0 # endif -# define _LIBCPP_HAS_OPEN_WITH_WCHAR +# define _LIBCPP_HAS_OPEN_WITH_WCHAR 1 +# else +# define _LIBCPP_HAS_OPEN_WITH_WCHAR 0 +# define _LIBCPP_HAS_BITSCAN64 0 # endif // defined(_WIN32) # if defined(_AIX) && !defined(__64BIT__) @@ -318,23 +323,33 @@ typedef __char32_t char32_t; // Objective-C++ features (opt-in) # if __has_feature(objc_arc) -# define _LIBCPP_HAS_OBJC_ARC +# define _LIBCPP_HAS_OBJC_ARC 1 +# else +# define _LIBCPP_HAS_OBJC_ARC 0 # endif # if __has_feature(objc_arc_weak) -# define _LIBCPP_HAS_OBJC_ARC_WEAK +# define _LIBCPP_HAS_OBJC_ARC_WEAK 1 +# else +# define _LIBCPP_HAS_OBJC_ARC_WEAK 0 # endif # if __has_extension(blocks) -# define _LIBCPP_HAS_EXTENSION_BLOCKS +# define _LIBCPP_HAS_EXTENSION_BLOCKS 1 +# else +# define _LIBCPP_HAS_EXTENSION_BLOCKS 0 # endif -# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) && defined(__APPLE__) -# define _LIBCPP_HAS_BLOCKS_RUNTIME +# if _LIBCPP_HAS_EXTENSION_BLOCKS && defined(__APPLE__) +# define _LIBCPP_HAS_BLOCKS_RUNTIME 1 +# else +# define _LIBCPP_HAS_BLOCKS_RUNTIME 0 # endif -# if !__has_feature(address_sanitizer) -# define _LIBCPP_HAS_NO_ASAN +# if __has_feature(address_sanitizer) +# define _LIBCPP_HAS_ASAN 1 +# else +# define _LIBCPP_HAS_ASAN 0 # endif # define _LIBCPP_ALWAYS_INLINE __attribute__((__always_inline__)) @@ -457,7 +472,7 @@ typedef __char32_t char32_t; # define _LIBCPP_HARDENING_SIG n // "none" # endif -# ifdef _LIBCPP_HAS_NO_EXCEPTIONS +# if !_LIBCPP_HAS_EXCEPTIONS # define _LIBCPP_EXCEPTIONS_SIG n # else # define _LIBCPP_EXCEPTIONS_SIG e @@ -597,7 +612,9 @@ typedef __char32_t char32_t; # endif # if !defined(__SIZEOF_INT128__) || defined(_MSC_VER) -# define _LIBCPP_HAS_NO_INT128 +# define _LIBCPP_HAS_INT128 0 +# else +# define _LIBCPP_HAS_INT128 1 # endif # ifdef _LIBCPP_CXX03_LANG @@ -629,33 +646,39 @@ typedef __char32_t char32_t; // If we are getting operator new from the MSVC CRT, then allocation overloads // for align_val_t were added in 19.12, aka VS 2017 version 15.3. # if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912 -# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0 # elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new) // We're deferring to Microsoft's STL to provide aligned new et al. We don't // have it unless the language feature test macro is defined. -# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0 # elif defined(__MVS__) -# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 0 +# else +# define _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION 1 # endif -# if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) -# define _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +# if !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION || (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606) +# define _LIBCPP_HAS_ALIGNED_ALLOCATION 0 +# else +# define _LIBCPP_HAS_ALIGNED_ALLOCATION 1 # endif // It is not yet possible to use aligned_alloc() on all Apple platforms since // 10.15 was the first version to ship an implementation of aligned_alloc(). # if defined(__APPLE__) # if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ - __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) -# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC -# endif -# if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ + __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ + (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && \ __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) -# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC +# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0 +# else +# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 # endif # elif defined(__ANDROID__) && __ANDROID_API__ < 28 // Android only provides aligned_alloc when targeting API 28 or higher. -# define _LIBCPP_HAS_NO_C11_ALIGNED_ALLOC +# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 0 +# else +# define _LIBCPP_HAS_C11_ALIGNED_ALLOC 1 # endif # if defined(__APPLE__) || defined(__FreeBSD__) @@ -667,7 +690,9 @@ typedef __char32_t char32_t; # endif # if _LIBCPP_STD_VER <= 17 || !defined(__cpp_char8_t) -# define _LIBCPP_HAS_NO_CHAR8_T +# define _LIBCPP_HAS_CHAR8_T 0 +# else +# define _LIBCPP_HAS_CHAR8_T 1 # endif // Deprecation macros. @@ -726,7 +751,7 @@ typedef __char32_t char32_t; # define _LIBCPP_DEPRECATED_IN_CXX26 # endif -# if !defined(_LIBCPP_HAS_NO_CHAR8_T) +# if _LIBCPP_HAS_CHAR8_T # define _LIBCPP_DEPRECATED_WITH_CHAR8_T _LIBCPP_DEPRECATED # else # define _LIBCPP_DEPRECATED_WITH_CHAR8_T @@ -821,12 +846,18 @@ typedef __char32_t char32_t; # if defined(_LIBCPP_HAS_THREAD_API_PTHREAD) # if defined(__ANDROID__) && __ANDROID_API__ >= 30 -# define _LIBCPP_HAS_COND_CLOCKWAIT +# define _LIBCPP_HAS_COND_CLOCKWAIT 1 # elif defined(_LIBCPP_GLIBC_PREREQ) # if _LIBCPP_GLIBC_PREREQ(2, 30) -# define _LIBCPP_HAS_COND_CLOCKWAIT +# define _LIBCPP_HAS_COND_CLOCKWAIT 1 +# else +# define _LIBCPP_HAS_COND_CLOCKWAIT 0 # endif +# else +# define _LIBCPP_HAS_COND_CLOCKWAIT 0 # endif +# else +# define _LIBCPP_HAS_COND_CLOCKWAIT 0 # endif # if defined(_LIBCPP_HAS_NO_THREADS) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) @@ -863,7 +894,9 @@ typedef __char32_t char32_t; (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || \ defined(_LIBCPP_HAS_THREAD_API_WIN32) // clang-format on -# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION +# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 1 +# else +# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION 0 # endif // Destroying a condvar is a nop on Windows. @@ -875,7 +908,9 @@ typedef __char32_t char32_t; // TODO(EricWF): This is potentially true for some pthread implementations // as well. # if (defined(_LIBCPP_HAS_THREAD_API_C11) && defined(__Fuchsia__)) || defined(_LIBCPP_HAS_THREAD_API_WIN32) -# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION +# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 1 +# else +# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION 0 # endif # if defined(__BIONIC__) || defined(__NuttX__) || defined(__Fuchsia__) || defined(__wasi__) || \ @@ -891,8 +926,9 @@ typedef __char32_t char32_t; # if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \ !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP) -# define _LIBCPP_HAS_NO_ATOMIC_HEADER +# define _LIBCPP_HAS_ATOMIC_HEADER 0 # else +# define _LIBCPP_HAS_ATOMIC_HEADER 1 # ifndef _LIBCPP_ATOMIC_FLAG_TYPE # define _LIBCPP_ATOMIC_FLAG_TYPE bool # endif @@ -904,19 +940,18 @@ typedef __char32_t char32_t; # define _LIBCPP_NO_THREAD_SAFETY_ANALYSIS # endif -# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) -# if defined(__clang__) && __has_attribute(acquire_capability) // Work around the attribute handling in clang. When both __declspec and // __attribute__ are present, the processing goes awry preventing the definition // of the types. In MinGW mode, __declspec evaluates to __attribute__, and thus // combining the two does work. -# if !defined(_MSC_VER) -# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS -# endif -# endif +# if defined(_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS) && defined(__clang__) && \ + __has_attribute(acquire_capability) && !defined(_MSC_VER) +# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 1 +# else +# define _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS 0 # endif -# ifdef _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS +# if _LIBCPP_HAS_THREAD_SAFETY_ANNOTATIONS # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) __attribute__((x)) # else # define _LIBCPP_THREAD_SAFETY_ANNOTATION(x) @@ -997,7 +1032,7 @@ typedef __char32_t char32_t; // functions is gradually being added to existing C libraries. The conditions // below check for known C library versions and conditions under which these // functions are declared by the C library. -# define _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 +// // GNU libc 2.36 and newer declare c8rtomb() and mbrtoc8() in C++ modes if // __cpp_char8_t is defined or if C2X extensions are enabled. Determining // the latter depends on internal GNU libc details that are not appropriate @@ -1005,8 +1040,12 @@ typedef __char32_t char32_t; // defined are ignored. # if defined(_LIBCPP_GLIBC_PREREQ) # if _LIBCPP_GLIBC_PREREQ(2, 36) && defined(__cpp_char8_t) -# undef _LIBCPP_HAS_NO_C8RTOMB_MBRTOC8 +# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 1 +# else +# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0 # endif +# else +# define _LIBCPP_HAS_C8RTOMB_MBRTOC8 0 # endif // There are a handful of public standard library types that are intended to @@ -1188,7 +1227,9 @@ typedef __char32_t char32_t; // Clang-18 has support for deducing this, but it does not set the FTM. # if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800) -# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1 +# else +# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0 # endif #endif // __cplusplus diff --git a/libcxx/include/__configuration/availability.h b/libcxx/include/__configuration/availability.h index b10f29590a2c9..f42ff460db454 100644 --- a/libcxx/include/__configuration/availability.h +++ b/libcxx/include/__configuration/availability.h @@ -409,10 +409,10 @@ #define _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19 #define _LIBCPP_AVAILABILITY_BAD_EXPECTED_ACCESS_KEY_FUNCTION _LIBCPP_INTRODUCED_IN_LLVM_19_ATTRIBUTE -// Define availability attributes that depend on _LIBCPP_HAS_NO_EXCEPTIONS. +// Define availability attributes that depend on _LIBCPP_HAS_EXCEPTIONS. // Those are defined in terms of the availability attributes above, and // should not be vendor-specific. -#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) +#if !_LIBCPP_HAS_EXCEPTIONS # define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST # define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS # define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS @@ -423,8 +423,8 @@ #endif // Define availability attributes that depend on both -// _LIBCPP_HAS_NO_EXCEPTIONS and _LIBCPP_HAS_NO_RTTI. -#if defined(_LIBCPP_HAS_NO_EXCEPTIONS) || defined(_LIBCPP_HAS_NO_RTTI) +// _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI. +#if !_LIBCPP_HAS_EXCEPTIONS || !_LIBCPP_HAS_RTTI # undef _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION # undef _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION # define _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION 0 diff --git a/libcxx/include/__configuration/language.h b/libcxx/include/__configuration/language.h index fa62a7b6f5c2a..9c224dfa76e40 100644 --- a/libcxx/include/__configuration/language.h +++ b/libcxx/include/__configuration/language.h @@ -35,12 +35,16 @@ #endif // __cplusplus // NOLINTEND(libcpp-cpp-version-check) -#if !defined(__cpp_rtti) || __cpp_rtti < 199711L -# define _LIBCPP_HAS_NO_RTTI +#if defined(__cpp_rtti) && __cpp_rtti >= 199711L +# define _LIBCPP_HAS_RTTI 1 +#else +# define _LIBCPP_HAS_RTTI 0 #endif -#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L -# define _LIBCPP_HAS_NO_EXCEPTIONS +#if defined(__cpp_exceptions) && __cpp_exceptions >= 199711L +# define _LIBCPP_HAS_EXCEPTIONS 1 +#else +# define _LIBCPP_HAS_EXCEPTIONS 0 #endif #endif // _LIBCPP___CONFIGURATION_LANGUAGE_H diff --git a/libcxx/include/__debug_utils/sanitizers.h b/libcxx/include/__debug_utils/sanitizers.h index d8547e3249330..73d192711eabb 100644 --- a/libcxx/include/__debug_utils/sanitizers.h +++ b/libcxx/include/__debug_utils/sanitizers.h @@ -17,7 +17,7 @@ # pragma GCC system_header #endif -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN extern "C" { _LIBCPP_EXPORTED_FROM_ABI void @@ -28,12 +28,12 @@ _LIBCPP_EXPORTED_FROM_ABI int __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*); } -#endif // _LIBCPP_HAS_NO_ASAN +#endif // _LIBCPP_HAS_ASAN _LIBCPP_BEGIN_NAMESPACE_STD // ASan choices -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN # define _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS 1 #endif @@ -57,7 +57,7 @@ _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container( const void* __last_old_contained, const void* __first_new_contained, const void* __last_new_contained) { -#ifdef _LIBCPP_HAS_NO_ASAN +#if !_LIBCPP_HAS_ASAN (void)__first_storage; (void)__last_storage; (void)__first_old_contained; @@ -86,7 +86,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 void __annotate_contiguous_c const void* __last_storage, const void* __old_last_contained, const void* __new_last_contained) { -#ifdef _LIBCPP_HAS_NO_ASAN +#if !_LIBCPP_HAS_ASAN (void)__first_storage; (void)__last_storage; (void)__old_last_contained; diff --git a/libcxx/include/__exception/exception_ptr.h b/libcxx/include/__exception/exception_ptr.h index 9e5351f534a1c..2cb250dfd42da 100644 --- a/libcxx/include/__exception/exception_ptr.h +++ b/libcxx/include/__exception/exception_ptr.h @@ -92,7 +92,7 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr { template _LIBCPP_HIDE_FROM_ABI exception_ptr make_exception_ptr(_Ep __e) _NOEXCEPT { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_AVAILABILITY_HAS_INIT_PRIMARY_EXCEPTION && __cplusplus >= 201103L using _Ep2 = __decay_t<_Ep>; diff --git a/libcxx/include/__exception/nested_exception.h b/libcxx/include/__exception/nested_exception.h index 8e817e1c06978..cc20b038c871b 100644 --- a/libcxx/include/__exception/nested_exception.h +++ b/libcxx/include/__exception/nested_exception.h @@ -49,7 +49,7 @@ struct __nested : public _Tp, public nested_exception { _LIBCPP_HIDE_FROM_ABI explicit __nested(const _Tp& __t) : _Tp(__t) {} }; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS template struct __throw_with_nested; @@ -68,7 +68,7 @@ struct __throw_with_nested<_Tp, _Up, false> { template [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI void throw_with_nested(_Tp&& __t) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS using _Up = __decay_t<_Tp>; static_assert(is_copy_constructible<_Up>::value, "type thrown must be CopyConstructible"); __throw_with_nested<_Tp, diff --git a/libcxx/include/__expected/expected.h b/libcxx/include/__expected/expected.h index e04e17d1ebe69..3d3f11967ee74 100644 --- a/libcxx/include/__expected/expected.h +++ b/libcxx/include/__expected/expected.h @@ -73,7 +73,7 @@ struct __expected_construct_unexpected_from_invoke_tag {}; template _LIBCPP_HIDE_FROM_ABI void __throw_bad_expected_access(_Arg&& __arg) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_expected_access<_Err>(std::forward<_Arg>(__arg)); # else (void)__arg; diff --git a/libcxx/include/__filesystem/filesystem_error.h b/libcxx/include/__filesystem/filesystem_error.h index f43568c2004d2..73592bba31da0 100644 --- a/libcxx/include/__filesystem/filesystem_error.h +++ b/libcxx/include/__filesystem/filesystem_error.h @@ -67,7 +67,7 @@ class _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY _LIBCPP_EXPORTED_FROM_ABI filesyst shared_ptr<_Storage> __storage_; }; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS template [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY void __throw_filesystem_error(_Args&&... __args) { diff --git a/libcxx/include/__filesystem/path.h b/libcxx/include/__filesystem/path.h index f0d39680430ec..2eb60810af02b 100644 --- a/libcxx/include/__filesystem/path.h +++ b/libcxx/include/__filesystem/path.h @@ -60,7 +60,7 @@ struct __can_convert_char { static const bool value = true; using __char_type = wchar_t; }; -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T template <> struct __can_convert_char { static const bool value = true; @@ -87,7 +87,7 @@ _LIBCPP_HIDE_FROM_ABI bool __is_separator(_ECharT __e) { # endif } -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T typedef u8string __u8_string; # else typedef string __u8_string; @@ -366,7 +366,7 @@ struct _PathExport { } }; -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T template <> struct _PathExport { typedef __narrow_to_utf8 _Narrower; @@ -376,7 +376,7 @@ struct _PathExport { _Narrower()(back_inserter(__dest), __src.data(), __src.data() + __src.size()); } }; -# endif /* !_LIBCPP_HAS_NO_CHAR8_T */ +# endif // _LIBCPP_HAS_CHAR8_T # endif /* _LIBCPP_WIN32API */ class _LIBCPP_EXPORTED_FROM_ABI path { @@ -730,7 +730,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path { # else /* _LIBCPP_WIN32API */ _LIBCPP_HIDE_FROM_ABI std::string string() const { return __pn_; } -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T _LIBCPP_HIDE_FROM_ABI std::u8string u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); } # else _LIBCPP_HIDE_FROM_ABI std::string u8string() const { return __pn_; } @@ -756,7 +756,7 @@ class _LIBCPP_EXPORTED_FROM_ABI path { // generic format observers _LIBCPP_HIDE_FROM_ABI std::string generic_string() const { return __pn_; } -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T _LIBCPP_HIDE_FROM_ABI std::u8string generic_u8string() const { return std::u8string(__pn_.begin(), __pn_.end()); } # else _LIBCPP_HIDE_FROM_ABI std::string generic_u8string() const { return __pn_; } diff --git a/libcxx/include/__filesystem/u8path.h b/libcxx/include/__filesystem/u8path.h index dae5823128f02..e13980298d9e9 100644 --- a/libcxx/include/__filesystem/u8path.h +++ b/libcxx/include/__filesystem/u8path.h @@ -34,7 +34,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _InputIt __l) { static_assert( -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T is_same::__char_type, char8_t>::value || # endif is_same::__char_type, char>::value, @@ -56,7 +56,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, _NullSentinel) { static_assert( -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T is_same::__char_type, char8_t>::value || # endif is_same::__char_type, char>::value, @@ -77,7 +77,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f, template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(const _Source& __s) { static_assert( -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T is_same::__char_type, char8_t>::value || # endif is_same::__char_type, char>::value, diff --git a/libcxx/include/__format/format_arg.h b/libcxx/include/__format/format_arg.h index d1ce055874413..3f39d2aec81f7 100644 --- a/libcxx/include/__format/format_arg.h +++ b/libcxx/include/__format/format_arg.h @@ -113,7 +113,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ case __format::__arg_t::__long_long: return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_); case __format::__arg_t::__i128: -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__i128_); # else __libcpp_unreachable(); @@ -123,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ case __format::__arg_t::__unsigned_long_long: return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_); case __format::__arg_t::__u128: -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 return std::invoke(std::forward<_Visitor>(__vis), __arg.__value_.__u128_); # else __libcpp_unreachable(); @@ -148,7 +148,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_ __libcpp_unreachable(); } -# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER template _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { @@ -164,7 +164,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< case __format::__arg_t::__long_long: return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__long_long_); case __format::__arg_t::__i128: -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__i128_); # else __libcpp_unreachable(); @@ -174,7 +174,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< case __format::__arg_t::__unsigned_long_long: return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_); case __format::__arg_t::__u128: -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), __arg.__value_.__u128_); # else __libcpp_unreachable(); @@ -199,7 +199,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg< __libcpp_unreachable(); } -# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER /// Contains the values used in basic_format_arg. /// @@ -237,7 +237,7 @@ class __basic_format_arg_value { unsigned __unsigned_; long long __long_long_; unsigned long long __unsigned_long_long_; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 __int128_t __i128_; __uint128_t __u128_; # endif @@ -261,7 +261,7 @@ class __basic_format_arg_value { _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {} _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept : __unsigned_long_long_(__value) {} -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {} _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {} # endif @@ -284,14 +284,14 @@ class _LIBCPP_TEMPLATE_VIS basic_format_arg { _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; } -# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER // This function is user facing, so it must wrap the non-standard types of // the "variant" in a handle to stay conforming. See __arg_t for more details. template _LIBCPP_HIDE_FROM_ABI decltype(auto) visit(this basic_format_arg __arg, _Visitor&& __vis) { switch (__arg.__type_) { -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 case __format::__arg_t::__i128: { typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_}; return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); @@ -312,7 +312,7 @@ class _LIBCPP_TEMPLATE_VIS basic_format_arg { template _LIBCPP_HIDE_FROM_ABI _Rp visit(this basic_format_arg __arg, _Visitor&& __vis) { switch (__arg.__type_) { -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 case __format::__arg_t::__i128: { typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_}; return std::invoke_r<_Rp>(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); @@ -328,7 +328,7 @@ class _LIBCPP_TEMPLATE_VIS basic_format_arg { } } -# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER private: using char_type = typename _Context::char_type; @@ -370,13 +370,13 @@ class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle { // This function is user facing, so it must wrap the non-standard types of // the "variant" in a handle to stay conforming. See __arg_t for more details. template -# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER _LIBCPP_DEPRECATED_IN_CXX26 # endif _LIBCPP_HIDE_FROM_ABI decltype(auto) visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) { switch (__arg.__type_) { -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 case __format::__arg_t::__i128: { typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_}; return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); @@ -386,7 +386,7 @@ _LIBCPP_DEPRECATED_IN_CXX26 typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_}; return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h}); } -# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER default: return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg); } diff --git a/libcxx/include/__format/format_arg_store.h b/libcxx/include/__format/format_arg_store.h index 9a4a41df6d4e6..847b39d428515 100644 --- a/libcxx/include/__format/format_arg_store.h +++ b/libcxx/include/__format/format_arg_store.h @@ -64,7 +64,7 @@ consteval __arg_t __determine_arg_t() { return __arg_t::__int; else if constexpr (sizeof(_Tp) <= sizeof(long long)) return __arg_t::__long_long; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 else if constexpr (sizeof(_Tp) == sizeof(__int128_t)) return __arg_t::__i128; # endif @@ -79,7 +79,7 @@ consteval __arg_t __determine_arg_t() { return __arg_t::__unsigned; else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long)) return __arg_t::__unsigned_long_long; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 else if constexpr (sizeof(_Tp) == sizeof(__uint128_t)) return __arg_t::__u128; # endif diff --git a/libcxx/include/__format/format_context.h b/libcxx/include/__format/format_context.h index a9be17b855837..019a71011a714 100644 --- a/libcxx/include/__format/format_context.h +++ b/libcxx/include/__format/format_context.h @@ -181,13 +181,13 @@ class _LIBCPP_TEMPLATE_VIS basic_format_context(), __basic_format_arg_value(__arg)}; }; -# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor)); # else _LIBCPP_SUPPRESS_DEPRECATED_PUSH return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id)); _LIBCPP_SUPPRESS_DEPRECATED_POP -# endif // _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER }) { } diff --git a/libcxx/include/__format/format_error.h b/libcxx/include/__format/format_error.h index 1df7dbff2b7df..b92e6d1de00e2 100644 --- a/libcxx/include/__format/format_error.h +++ b/libcxx/include/__format/format_error.h @@ -36,7 +36,7 @@ class _LIBCPP_EXPORTED_FROM_ABI format_error : public runtime_error { _LIBCPP_DIAGNOSTIC_POP [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_format_error(const char* __s) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw format_error(__s); # else _LIBCPP_VERBOSE_ABORT("format_error was thrown in -fno-exceptions mode with message \"%s\"", __s); diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h index 1518ab5768d24..b3cda8bf84491 100644 --- a/libcxx/include/__format/format_functions.h +++ b/libcxx/include/__format/format_functions.h @@ -206,7 +206,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg( case __arg_t::__long_long: return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx); case __arg_t::__i128: -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx); # else std::__throw_format_error("Invalid argument"); @@ -217,7 +217,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg( case __arg_t::__unsigned_long_long: return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx); case __arg_t::__u128: -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx); # else std::__throw_format_error("Invalid argument"); diff --git a/libcxx/include/__format/formatter_integer.h b/libcxx/include/__format/formatter_integer.h index b7f46014c5723..3f51b10d75aac 100644 --- a/libcxx/include/__format/formatter_integer.h +++ b/libcxx/include/__format/formatter_integer.h @@ -67,7 +67,7 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter : public __formatter_integer<_CharT> {}; template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter : public __formatter_integer<_CharT> {}; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter<__int128_t, _CharT> : public __formatter_integer<_CharT> {}; # endif @@ -83,7 +83,7 @@ template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter : public __formatter_integer<_CharT> {}; template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter : public __formatter_integer<_CharT> {}; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 template <__fmt_char_type _CharT> struct _LIBCPP_TEMPLATE_VIS formatter<__uint128_t, _CharT> : public __formatter_integer<_CharT> {}; # endif @@ -99,7 +99,7 @@ template <> inline constexpr bool enable_nonlocking_formatter_optimization = true; template <> inline constexpr bool enable_nonlocking_formatter_optimization = true; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 template <> inline constexpr bool enable_nonlocking_formatter_optimization<__int128_t> = true; # endif @@ -114,7 +114,7 @@ template <> inline constexpr bool enable_nonlocking_formatter_optimization = true; template <> inline constexpr bool enable_nonlocking_formatter_optimization = true; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 template <> inline constexpr bool enable_nonlocking_formatter_optimization<__uint128_t> = true; # endif diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h index 0d95c9a6ef2bb..e3844f86dbd3f 100644 --- a/libcxx/include/__functional/function.h +++ b/libcxx/include/__functional/function.h @@ -79,7 +79,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception { _LIBCPP_DIAGNOSTIC_POP [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_function_call(); # else _LIBCPP_VERBOSE_ABORT("bad_function_call was thrown in -fno-exceptions mode"); @@ -123,7 +123,7 @@ _LIBCPP_HIDE_FROM_ABI bool __not_null(function<_Fp> const& __f) { return !!__f; } -# ifdef _LIBCPP_HAS_EXTENSION_BLOCKS +# if _LIBCPP_HAS_EXTENSION_BLOCKS template _LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) { return __p; @@ -244,10 +244,10 @@ class __base<_Rp(_ArgTypes...)> { virtual void destroy() _NOEXCEPT = 0; virtual void destroy_deallocate() _NOEXCEPT = 0; virtual _Rp operator()(_ArgTypes&&...) = 0; -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI virtual const void* target(const type_info&) const _NOEXCEPT = 0; virtual const std::type_info& target_type() const _NOEXCEPT = 0; -# endif // _LIBCPP_HAS_NO_RTTI +# endif // _LIBCPP_HAS_RTTI }; // __func implements __base for a given functor type. @@ -273,10 +273,10 @@ class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg); -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(const type_info&) const _NOEXCEPT; _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT; -# endif // _LIBCPP_HAS_NO_RTTI +# endif // _LIBCPP_HAS_RTTI }; template @@ -314,7 +314,7 @@ _Rp __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&&... __arg) { return __f_(std::forward<_ArgTypes>(__arg)...); } -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI template const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT { @@ -328,7 +328,7 @@ const std::type_info& __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() cons return typeid(_Fp); } -# endif // _LIBCPP_HAS_NO_RTTI +# endif // _LIBCPP_HAS_RTTI // __value_func creates a value-type from a __func. @@ -465,7 +465,7 @@ class __value_func<_Rp(_ArgTypes...)> { _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; } -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT { if (__f_ == nullptr) return typeid(void); @@ -478,7 +478,7 @@ class __value_func<_Rp(_ArgTypes...)> { return nullptr; return (const _Tp*)__f_->target(typeid(_Tp)); } -# endif // _LIBCPP_HAS_NO_RTTI +# endif // _LIBCPP_HAS_RTTI }; // Storage for a functor object, to be used with __policy to manage copy and @@ -521,7 +521,7 @@ struct __policy { nullptr, nullptr, true, -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI &typeid(void) # else nullptr @@ -548,7 +548,7 @@ struct __policy { &__large_clone<_Fun>, &__large_destroy<_Fun>, false, -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI &typeid(typename _Fun::_Target) # else nullptr @@ -563,7 +563,7 @@ struct __policy { nullptr, nullptr, false, -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI &typeid(typename _Fun::_Target) # else nullptr @@ -725,7 +725,7 @@ class __policy_func<_Rp(_ArgTypes...)> { _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return !__policy_->__is_null; } -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT { return *__policy_->__type_info; } template @@ -737,10 +737,10 @@ class __policy_func<_Rp(_ArgTypes...)> { else return reinterpret_cast(&__buf_.__small); } -# endif // _LIBCPP_HAS_NO_RTTI +# endif // _LIBCPP_HAS_RTTI }; -# if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) +# if _LIBCPP_HAS_BLOCKS_RUNTIME extern "C" void* _Block_copy(const void*); extern "C" void _Block_release(const void*); @@ -752,7 +752,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base public: _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f) -# ifdef _LIBCPP_HAS_OBJC_ARC +# if _LIBCPP_HAS_OBJC_ARC : __f_(__f) # else : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) @@ -763,7 +763,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base // [TODO] add && to save on a retain _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type __f, const _Alloc& /* unused */) -# ifdef _LIBCPP_HAS_OBJC_ARC +# if _LIBCPP_HAS_OBJC_ARC : __f_(__f) # else : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) @@ -785,7 +785,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base } _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT { -# ifndef _LIBCPP_HAS_OBJC_ARC +# if !_LIBCPP_HAS_OBJC_ARC if (__f_) _Block_release(__f_); # endif @@ -804,7 +804,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...); } -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(type_info const& __ti) const _NOEXCEPT { if (__ti == typeid(__func::__block_type)) return &__f_; @@ -814,7 +814,7 @@ class __func<_Rp1 (^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> : public __base _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT { return typeid(__func::__block_type); } -# endif // _LIBCPP_HAS_NO_RTTI +# endif // _LIBCPP_HAS_RTTI }; # endif // _LIBCPP_HAS_EXTENSION_BLOCKS @@ -906,14 +906,14 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> // function invocation: _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const; -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI // function target access: _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT; template _LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT; template _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT; -# endif // _LIBCPP_HAS_NO_RTTI +# endif // _LIBCPP_HAS_RTTI }; # if _LIBCPP_STD_VER >= 17 @@ -990,7 +990,7 @@ _Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { return __f_(std::forward<_ArgTypes>(__arg)...); } -# ifndef _LIBCPP_HAS_NO_RTTI +# if _LIBCPP_HAS_RTTI template const std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT { @@ -1009,7 +1009,7 @@ const _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT { return __f_.template target<_Tp>(); } -# endif // _LIBCPP_HAS_NO_RTTI +# endif // _LIBCPP_HAS_RTTI template inline _LIBCPP_HIDE_FROM_ABI bool operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT { diff --git a/libcxx/include/__functional/hash.h b/libcxx/include/__functional/hash.h index 59dce7ac9cc03..8abec99f72905 100644 --- a/libcxx/include/__functional/hash.h +++ b/libcxx/include/__functional/hash.h @@ -356,12 +356,12 @@ struct _LIBCPP_TEMPLATE_VIS hash : public __unary_function(__v); } }; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T template <> struct _LIBCPP_TEMPLATE_VIS hash : public __unary_function { _LIBCPP_HIDE_FROM_ABI size_t operator()(char8_t __v) const _NOEXCEPT { return static_cast(__v); } }; -#endif // !_LIBCPP_HAS_NO_CHAR8_T +#endif // _LIBCPP_HAS_CHAR8_T template <> struct _LIBCPP_TEMPLATE_VIS hash : public __unary_function { @@ -416,7 +416,7 @@ struct _LIBCPP_TEMPLATE_VIS hash : public __scalar_hash {} template <> struct _LIBCPP_TEMPLATE_VIS hash : public __scalar_hash {}; -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 template <> struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> : public __scalar_hash<__int128_t> {}; diff --git a/libcxx/include/__fwd/string.h b/libcxx/include/__fwd/string.h index 2418e1f9b23d0..f13a3594022e8 100644 --- a/libcxx/include/__fwd/string.h +++ b/libcxx/include/__fwd/string.h @@ -24,7 +24,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits; template <> struct char_traits; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T template <> struct char_traits; #endif @@ -48,7 +48,7 @@ using string = basic_string; using wstring = basic_string; #endif -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T using u8string = basic_string; #endif @@ -67,7 +67,7 @@ using string _LIBCPP_AVAILABILITY_PMR = basic_string; using wstring _LIBCPP_AVAILABILITY_PMR = basic_string; # endif -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T using u8string _LIBCPP_AVAILABILITY_PMR = basic_string; # endif @@ -83,7 +83,7 @@ class _LIBCPP_PREFERRED_NAME(string) #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_PREFERRED_NAME(wstring) #endif -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T _LIBCPP_PREFERRED_NAME(u8string) #endif _LIBCPP_PREFERRED_NAME(u16string) @@ -93,7 +93,7 @@ class _LIBCPP_PREFERRED_NAME(string) # ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_PREFERRED_NAME(pmr::wstring) # endif -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T _LIBCPP_PREFERRED_NAME(pmr::u8string) # endif _LIBCPP_PREFERRED_NAME(pmr::u16string) diff --git a/libcxx/include/__fwd/string_view.h b/libcxx/include/__fwd/string_view.h index 72a64be5b00b5..e1acd87425611 100644 --- a/libcxx/include/__fwd/string_view.h +++ b/libcxx/include/__fwd/string_view.h @@ -23,7 +23,7 @@ template > class _LIBCPP_TEMPLATE_VIS basic_string_view; typedef basic_string_view string_view; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T typedef basic_string_view u8string_view; #endif typedef basic_string_view u16string_view; @@ -38,7 +38,7 @@ class _LIBCPP_PREFERRED_NAME(string_view) #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS _LIBCPP_PREFERRED_NAME(wstring_view) #endif -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T _LIBCPP_PREFERRED_NAME(u8string_view) #endif _LIBCPP_PREFERRED_NAME(u16string_view) diff --git a/libcxx/include/__hash_table b/libcxx/include/__hash_table index 821d4edd8d87c..560e873adc384 100644 --- a/libcxx/include/__hash_table +++ b/libcxx/include/__hash_table @@ -1210,9 +1210,9 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, max_load_factor() = __u.max_load_factor(); if (bucket_count() != 0) { __next_pointer __cache = __detach(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS const_iterator __i = __u.begin(); while (__cache != nullptr && __u.size() != 0) { __cache->__upcast()->__get_value() = std::move(__u.remove(__i++)->__get_value()); @@ -1220,12 +1220,12 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign(__hash_table& __u, __node_insert_multi(__cache->__upcast()); __cache = __next; } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __deallocate_node(__cache); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __deallocate_node(__cache); } const_iterator __i = __u.begin(); @@ -1256,21 +1256,21 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __ if (bucket_count() != 0) { __next_pointer __cache = __detach(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { __cache->__upcast()->__get_value() = *__first; __next_pointer __next = __cache->__next_; __node_insert_unique(__cache->__upcast()); __cache = __next; } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __deallocate_node(__cache); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __deallocate_node(__cache); } for (; __first != __last; ++__first) @@ -1288,21 +1288,21 @@ void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __f " or the nodes value type"); if (bucket_count() != 0) { __next_pointer __cache = __detach(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { __cache->__upcast()->__get_value() = *__first; __next_pointer __next = __cache->__next_; __node_insert_multi(__cache->__upcast()); __cache = __next; } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __deallocate_node(__cache); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __deallocate_node(__cache); } for (; __first != __last; ++__first) diff --git a/libcxx/include/__iterator/counted_iterator.h b/libcxx/include/__iterator/counted_iterator.h index d461427ccea3c..65e178bc0cf21 100644 --- a/libcxx/include/__iterator/counted_iterator.h +++ b/libcxx/include/__iterator/counted_iterator.h @@ -132,7 +132,7 @@ class counted_iterator _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator++(int) { _LIBCPP_ASSERT_UNCATEGORIZED(__count_ > 0, "Iterator already at or past end."); --__count_; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { return __current_++; } catch (...) { @@ -141,7 +141,7 @@ class counted_iterator } # else return __current_++; -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } _LIBCPP_HIDE_FROM_ABI constexpr counted_iterator operator++(int) diff --git a/libcxx/include/__locale b/libcxx/include/__locale index 4b382764b4464..5fb0c19903cd5 100644 --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -982,7 +982,7 @@ protected: virtual int do_max_length() const _NOEXCEPT; }; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T // template <> class codecvt // C++20 @@ -1145,7 +1145,7 @@ protected: virtual int do_max_length() const _NOEXCEPT; }; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T // template <> class codecvt // C++20 @@ -1255,7 +1255,7 @@ extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname; // deprecated in C++20 extern template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname; // deprecated in C++20 -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname; // C++20 extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname; // C++20 #endif diff --git a/libcxx/include/__memory/addressof.h b/libcxx/include/__memory/addressof.h index fa590212c49b9..ecb68e0fe61e4 100644 --- a/libcxx/include/__memory/addressof.h +++ b/libcxx/include/__memory/addressof.h @@ -23,7 +23,7 @@ inline _LIBCPP_CONSTEXPR_SINCE_CXX17 _LIBCPP_NO_CFI _LIBCPP_HIDE_FROM_ABI _Tp* a return __builtin_addressof(__x); } -#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) +#if _LIBCPP_HAS_OBJC_ARC && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) // Objective-C++ Automatic Reference Counting uses qualified pointers // that require special addressof() signatures. When // _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler @@ -33,7 +33,7 @@ inline _LIBCPP_HIDE_FROM_ABI __strong _Tp* addressof(__strong _Tp& __x) _NOEXCEP return &__x; } -# ifdef _LIBCPP_HAS_OBJC_ARC_WEAK +# if _LIBCPP_HAS_OBJC_ARC_WEAK template inline _LIBCPP_HIDE_FROM_ABI __weak _Tp* addressof(__weak _Tp& __x) _NOEXCEPT { return &__x; diff --git a/libcxx/include/__memory/aligned_alloc.h b/libcxx/include/__memory/aligned_alloc.h index cb424328bcafc..33fe8af77df7b 100644 --- a/libcxx/include/__memory/aligned_alloc.h +++ b/libcxx/include/__memory/aligned_alloc.h @@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION // Low-level helpers to call the aligned allocation and deallocation functions // on the target platform. This is used to implement libc++'s own memory @@ -30,7 +30,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_aligned_alloc(std::size_t __alignment, std::size_t __size) { # if defined(_LIBCPP_MSVCRT_LIKE) return ::_aligned_malloc(__size, __alignment); -# elif _LIBCPP_STD_VER >= 17 && !defined(_LIBCPP_HAS_NO_C11_ALIGNED_ALLOC) +# elif _LIBCPP_STD_VER >= 17 && _LIBCPP_HAS_C11_ALIGNED_ALLOC // aligned_alloc() requires that __size is a multiple of __alignment, // but for C++ [new.delete.general], only states "if the value of an // alignment argument passed to any of these functions is not a valid @@ -57,7 +57,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_aligned_free(void* __ptr) { # endif } -#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +#endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__memory/shared_ptr.h b/libcxx/include/__memory/shared_ptr.h index 20c1b69f45ae6..65870ba574c25 100644 --- a/libcxx/include/__memory/shared_ptr.h +++ b/libcxx/include/__memory/shared_ptr.h @@ -54,7 +54,7 @@ #include #include #include -#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) +#if _LIBCPP_HAS_ATOMIC_HEADER # include <__atomic/memory_order.h> #endif @@ -70,10 +70,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD // NOTE: Relaxed and acq/rel atomics (for increment and decrement respectively) // should be sufficient for thread safety. // See https://llvm.org/PR22803 -#if defined(__clang__) && __has_builtin(__atomic_add_fetch) && defined(__ATOMIC_RELAXED) && defined(__ATOMIC_ACQ_REL) -# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT -#elif defined(_LIBCPP_COMPILER_GCC) -# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT +#if (defined(__clang__) && __has_builtin(__atomic_add_fetch) && defined(__ATOMIC_RELAXED) && \ + defined(__ATOMIC_ACQ_REL)) || \ + defined(_LIBCPP_COMPILER_GCC) +# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT 1 +#else +# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT 0 #endif template @@ -98,7 +100,7 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const* template inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _NOEXCEPT { -#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS) +#if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && !defined(_LIBCPP_HAS_NO_THREADS) return __atomic_add_fetch(&__t, 1, __ATOMIC_RELAXED); #else return __t += 1; @@ -107,7 +109,7 @@ inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_increment(_Tp& __t) _N template inline _LIBCPP_HIDE_FROM_ABI _Tp __libcpp_atomic_refcount_decrement(_Tp& __t) _NOEXCEPT { -#if defined(_LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT) && !defined(_LIBCPP_HAS_NO_THREADS) +#if _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT && !defined(_LIBCPP_HAS_NO_THREADS) return __atomic_add_fetch(&__t, -1, __ATOMIC_ACQ_REL); #else return __t -= 1; @@ -124,7 +126,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_weak_ptr : public std::exception { }; [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_weak_ptr() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw bad_weak_ptr(); #else _LIBCPP_VERBOSE_ABORT("bad_weak_ptr was thrown in -fno-exceptions mode"); @@ -206,7 +208,7 @@ class __shared_ptr_pointer : public __shared_weak_count { _LIBCPP_HIDE_FROM_ABI __shared_ptr_pointer(_Tp __p, _Dp __d, _Alloc __a) : __ptr_(__p), __deleter_(std::move(__d)), __alloc_(std::move(__a)) {} -#ifndef _LIBCPP_HAS_NO_RTTI +#if _LIBCPP_HAS_RTTI _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* __get_deleter(const type_info&) const _NOEXCEPT override; #endif @@ -215,14 +217,14 @@ class __shared_ptr_pointer : public __shared_weak_count { _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __on_zero_shared_weak() _NOEXCEPT override; }; -#ifndef _LIBCPP_HAS_NO_RTTI +#if _LIBCPP_HAS_RTTI template const void* __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT { return __t == typeid(_Dp) ? std::addressof(__deleter_) : nullptr; } -#endif // _LIBCPP_HAS_NO_RTTI +#endif // _LIBCPP_HAS_RTTI template void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT { @@ -455,9 +457,9 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d) : __ptr_(__p) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS typedef typename __shared_ptr_default_allocator<_Yp>::type _AllocT; typedef __shared_ptr_pointer<_Yp*, _Dp, _AllocT> _CntrlBlk; #ifndef _LIBCPP_CXX03_LANG @@ -466,12 +468,12 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); #endif // not _LIBCPP_CXX03_LANG __enable_weak_this(__p, __p); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __d(__p); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } template ::value, int> = 0> _LIBCPP_HIDE_FROM_ABI shared_ptr(_Yp* __p, _Dp __d, _Alloc __a) : __ptr_(__p) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS typedef __shared_ptr_pointer<_Yp*, _Dp, _Alloc> _CntrlBlk; typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; typedef __allocator_destructor<_A2> _D2; @@ -495,12 +497,12 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { #endif // not _LIBCPP_CXX03_LANG __cntrl_ = std::addressof(*__hold2.release()); __enable_weak_this(__p, __p); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __d(__p); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -509,9 +511,9 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { _Dp __d, __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) : __ptr_(nullptr) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS typedef typename __shared_ptr_default_allocator<_Tp>::type _AllocT; typedef __shared_ptr_pointer _CntrlBlk; #ifndef _LIBCPP_CXX03_LANG @@ -519,12 +521,12 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { #else __cntrl_ = new _CntrlBlk(__p, __d, _AllocT()); #endif // not _LIBCPP_CXX03_LANG -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __d(__p); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -534,9 +536,9 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { _Alloc __a, __enable_if_t<__shared_ptr_nullptr_deleter_ctor_reqs<_Dp>::value, __nullptr_sfinae_tag> = __nullptr_sfinae_tag()) : __ptr_(nullptr) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS typedef __shared_ptr_pointer _CntrlBlk; typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2; typedef __allocator_destructor<_A2> _D2; @@ -549,12 +551,12 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { _CntrlBlk(__p, __d, __a); #endif // not _LIBCPP_CXX03_LANG __cntrl_ = std::addressof(*__hold2.release()); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __d(__p); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -767,12 +769,12 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr { } #endif -#ifndef _LIBCPP_HAS_NO_RTTI +#if _LIBCPP_HAS_RTTI template _LIBCPP_HIDE_FROM_ABI _Dp* __get_deleter() const _NOEXCEPT { return static_cast<_Dp*>(__cntrl_ ? const_cast(__cntrl_->__get_deleter(typeid(_Dp))) : nullptr); } -#endif // _LIBCPP_HAS_NO_RTTI +#endif // _LIBCPP_HAS_RTTI template _LIBCPP_HIDE_FROM_ABI static shared_ptr<_Tp> __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT { @@ -1297,14 +1299,14 @@ _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> reinterpret_pointer_cast(shared_ptr<_Up>&& } #endif -#ifndef _LIBCPP_HAS_NO_RTTI +#if _LIBCPP_HAS_RTTI template inline _LIBCPP_HIDE_FROM_ABI _Dp* get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT { return __p.template __get_deleter<_Dp>(); } -#endif // _LIBCPP_HAS_NO_RTTI +#endif // _LIBCPP_HAS_RTTI template class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr { diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h index dd72f3c10cf15..54af1fa1a1cc5 100644 --- a/libcxx/include/__memory/uninitialized_algorithms.h +++ b/libcxx/include/__memory/uninitialized_algorithms.h @@ -59,12 +59,12 @@ template __uninitialized_copy( _InputIterator __ifirst, _Sentinel1 __ilast, _ForwardIterator __ofirst, _EndPredicate __stop_copying) { _ForwardIterator __idx = __ofirst; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { #endif for (; __ifirst != __ilast && !__stop_copying(__idx); ++__ifirst, (void)++__idx) ::new (static_cast(std::addressof(*__idx))) _ValueType(*__ifirst); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__ofirst, __idx); throw; @@ -89,12 +89,12 @@ template __uninitialized_copy_n(_InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_copying) { _ForwardIterator __idx = __ofirst; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { #endif for (; __n > 0 && !__stop_copying(__idx); ++__ifirst, (void)++__idx, (void)--__n) ::new (static_cast(std::addressof(*__idx))) _ValueType(*__ifirst); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__ofirst, __idx); throw; @@ -119,12 +119,12 @@ template inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_fill(_ForwardIterator __first, _Sentinel __last, const _Tp& __x) { _ForwardIterator __idx = __first; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { #endif for (; __idx != __last; ++__idx) ::new (static_cast(std::addressof(*__idx))) _ValueType(__x); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__first, __idx); throw; @@ -147,12 +147,12 @@ template inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_fill_n(_ForwardIterator __first, _Size __n, const _Tp& __x) { _ForwardIterator __idx = __first; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { #endif for (; __n > 0; ++__idx, (void)--__n) ::new (static_cast(std::addressof(*__idx))) _ValueType(__x); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__first, __idx); throw; @@ -177,12 +177,12 @@ template inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct(_ForwardIterator __first, _Sentinel __last) { auto __idx = __first; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif for (; __idx != __last; ++__idx) ::new (static_cast(std::addressof(*__idx))) _ValueType; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__first, __idx); throw; @@ -203,12 +203,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterat template inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_default_construct_n(_ForwardIterator __first, _Size __n) { auto __idx = __first; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif for (; __n > 0; ++__idx, (void)--__n) ::new (static_cast(std::addressof(*__idx))) _ValueType; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__first, __idx); throw; @@ -230,12 +230,12 @@ template inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct(_ForwardIterator __first, _Sentinel __last) { auto __idx = __first; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif for (; __idx != __last; ++__idx) ::new (static_cast(std::addressof(*__idx))) _ValueType(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__first, __idx); throw; @@ -256,12 +256,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator template inline _LIBCPP_HIDE_FROM_ABI _ForwardIterator __uninitialized_value_construct_n(_ForwardIterator __first, _Size __n) { auto __idx = __first; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif for (; __n > 0; ++__idx, (void)--__n) ::new (static_cast(std::addressof(*__idx))) _ValueType(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__first, __idx); throw; @@ -292,13 +292,13 @@ inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __uninitiali _EndPredicate __stop_moving, _IterMove __iter_move) { auto __idx = __ofirst; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif for (; __ifirst != __ilast && !__stop_moving(__idx); ++__idx, (void)++__ifirst) { ::new (static_cast(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst)); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__ofirst, __idx); throw; @@ -330,12 +330,12 @@ template __uninitialized_move_n( _InputIterator __ifirst, _Size __n, _ForwardIterator __ofirst, _EndPredicate __stop_moving, _IterMove __iter_move) { auto __idx = __ofirst; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif for (; __n > 0 && !__stop_moving(__idx); ++__idx, (void)++__ifirst, --__n) ::new (static_cast(std::addressof(*__idx))) _ValueType(__iter_move(__ifirst)); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { std::__destroy(__ofirst, __idx); throw; @@ -627,7 +627,7 @@ __uninitialized_allocator_relocate(_Alloc& __alloc, _Tp* __first, _Tp* __last, _ std::__make_exception_guard(_AllocatorDestroyRangeReverse<_Alloc, _Tp*>(__alloc, __destruct_first, __result)); auto __iter = __first; while (__iter != __last) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS allocator_traits<_Alloc>::construct(__alloc, __result, std::move_if_noexcept(*__iter)); #else allocator_traits<_Alloc>::construct(__alloc, __result, std::move(*__iter)); diff --git a/libcxx/include/__memory/unique_temporary_buffer.h b/libcxx/include/__memory/unique_temporary_buffer.h index 001254e8fa4be..8a8c327be69fe 100644 --- a/libcxx/include/__memory/unique_temporary_buffer.h +++ b/libcxx/include/__memory/unique_temporary_buffer.h @@ -62,7 +62,7 @@ __allocate_unique_temporary_buffer(ptrdiff_t __count) { if (__count > __max_count) __count = __max_count; while (__count > 0) { -#if !defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) +#if _LIBCPP_HAS_ALIGNED_ALLOCATION if (__is_overaligned_for_new(_LIBCPP_ALIGNOF(_Tp))) { align_val_t __al = align_val_t(_LIBCPP_ALIGNOF(_Tp)); __ptr = static_cast<_Tp*>(::operator new(__count * sizeof(_Tp), __al, nothrow)); diff --git a/libcxx/include/__mutex/mutex.h b/libcxx/include/__mutex/mutex.h index 1ed01547126f4..9c0c9ad6b5997 100644 --- a/libcxx/include/__mutex/mutex.h +++ b/libcxx/include/__mutex/mutex.h @@ -30,7 +30,7 @@ class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mut mutex(const mutex&) = delete; mutex& operator=(const mutex&) = delete; -# if defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION) +# if _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION _LIBCPP_HIDE_FROM_ABI ~mutex() = default; # else ~mutex() _NOEXCEPT; diff --git a/libcxx/include/__ostream/basic_ostream.h b/libcxx/include/__ostream/basic_ostream.h index 1f7fe8338c589..1b1c026706cdf 100644 --- a/libcxx/include/__ostream/basic_ostream.h +++ b/libcxx/include/__ostream/basic_ostream.h @@ -156,15 +156,15 @@ basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& _ template basic_ostream<_CharT, _Traits>::sentry::~sentry() { if (__os_.rdbuf() && __os_.good() && (__os_.flags() & ios_base::unitbuf) && uncaught_exceptions() == 0) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (__os_.rdbuf()->pubsync() == -1) __os_.setstate(ios_base::badbit); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -185,15 +185,15 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() {} template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf* __sb) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { if (__sb) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typedef istreambuf_iterator<_CharT, _Traits> _Ip; typedef ostreambuf_iterator<_CharT, _Traits> _Op; _Ip __i(__sb); @@ -207,27 +207,27 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambufsetstate(ios_base::failbit); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_failbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else this->setstate(ios_base::badbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -235,19 +235,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(bool if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; @@ -262,19 +262,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(short .failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned short __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -282,19 +282,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig if (__f.put(*this, *this, this->fill(), static_cast(__n)).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { ios_base::fmtflags __flags = ios_base::flags() & ios_base::basefield; @@ -309,19 +309,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(int _ .failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned int __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -329,19 +329,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig if (__f.put(*this, *this, this->fill(), static_cast(__n)).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -349,19 +349,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -369,19 +369,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long long __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -389,19 +389,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsigned long long __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -409,19 +409,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -429,19 +429,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float if (__f.put(*this, *this, this->fill(), static_cast(__n)).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(double __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -449,19 +449,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(doubl if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long double __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -469,19 +469,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(long if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const void* __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef num_put > _Fp; @@ -489,20 +489,20 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(const if (__f.put(*this, *this, this->fill(), __n).failed()) this->setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str, size_t __len) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Ip; @@ -516,11 +516,11 @@ __put_character_sequence(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s .failed()) __os.setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __os; } @@ -531,9 +531,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_ template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { _CharT __c = __os.widen(__cn); @@ -548,11 +548,11 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_ .failed()) __os.setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __os; } @@ -580,9 +580,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) { template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Ip; @@ -609,11 +609,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn) { .failed()) __os.setstate(ios_base::badbit | ios_base::failbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __os; } @@ -638,9 +638,9 @@ operator<<(basic_ostream& __os, const unsigned char* __str) { template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __c) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __s(*this); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Op; @@ -649,37 +649,37 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::put(char_type __ if (__o.failed()) this->setstate(ios_base::badbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::write(const char_type* __s, streamsize __n) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS sentry __sen(*this); if (__sen && __n) { if (this->rdbuf()->sputn(__s, __n) != __n) this->setstate(ios_base::badbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } template basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf()) { sentry __s(*this); if (__s) { @@ -687,11 +687,11 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::flush() { this->setstate(ios_base::badbit); } } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return *this; } @@ -823,7 +823,7 @@ basic_ostream& operator<<(basic_ostream&, co # endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T template basic_ostream& operator<<(basic_ostream&, char8_t) = delete; diff --git a/libcxx/include/__ostream/print.h b/libcxx/include/__ostream/print.h index 6c82b11e1de96..82eb93a845792 100644 --- a/libcxx/include/__ostream/print.h +++ b/libcxx/include/__ostream/print.h @@ -52,9 +52,9 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _ const char* __str = __o.data(); size_t __len = __o.size(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typedef ostreambuf_iterator _Ip; if (std::__pad_and_output( _Ip(__os), @@ -66,11 +66,11 @@ __vprint_nonunicode(ostream& __os, string_view __fmt, format_args __args, bool _ .failed()) __os.setstate(ios_base::badbit | ios_base::failbit); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -115,9 +115,9 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo // This is the path for the native API, start with flushing. __os.flush(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS ostream::sentry __s(__os); if (__s) { # ifndef _LIBCPP_WIN32API @@ -129,11 +129,11 @@ _LIBCPP_HIDE_FROM_ABI void __vprint_unicode(ostream& __os, string_view __fmt, fo # endif } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS # endif // _LIBCPP_AVAILABILITY_HAS_PRINT } diff --git a/libcxx/include/__pstl/backends/libdispatch.h b/libcxx/include/__pstl/backends/libdispatch.h index 2d6ab49c8f7f3..a92d0978e5c64 100644 --- a/libcxx/include/__pstl/backends/libdispatch.h +++ b/libcxx/include/__pstl/backends/libdispatch.h @@ -142,11 +142,11 @@ struct __cpu_traits<__libdispatch_backend_tag> { unique_ptr<__merge_range_t[], decltype(__destroy)> __ranges( [&]() -> __merge_range_t* { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif return std::allocator<__merge_range_t>().allocate(__n_ranges); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (const std::bad_alloc&) { return nullptr; } diff --git a/libcxx/include/__random/is_valid.h b/libcxx/include/__random/is_valid.h index a3e0f143ae86a..f6679b3fdc427 100644 --- a/libcxx/include/__random/is_valid.h +++ b/libcxx/include/__random/is_valid.h @@ -66,12 +66,12 @@ struct __libcpp_random_is_valid_inttype : true_type {}; template <> struct __libcpp_random_is_valid_inttype : true_type {}; -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 template <> struct __libcpp_random_is_valid_inttype<__int128_t> : true_type {}; // extension template <> struct __libcpp_random_is_valid_inttype<__uint128_t> : true_type {}; // extension -#endif // _LIBCPP_HAS_NO_INT128 +#endif // _LIBCPP_HAS_INT128 // [rand.req.urng]/3: // A class G meets the uniform random bit generator requirements if G models diff --git a/libcxx/include/__random/linear_congruential_engine.h b/libcxx/include/__random/linear_congruential_engine.h index 9d77649e9cfc8..a0afda4945cdc 100644 --- a/libcxx/include/__random/linear_congruential_engine.h +++ b/libcxx/include/__random/linear_congruential_engine.h @@ -48,7 +48,7 @@ struct __lce_alg_picker { : _Schrage ? _LCE_Schrage : _LCE_Promote; -#ifdef _LIBCPP_HAS_NO_INT128 +#if !_LIBCPP_HAS_INT128 static_assert(_Mp != (unsigned long long)(-1) || _Full || _Part || _Schrage, "The current values for a, c, and m are not currently supported on platforms without __int128"); #endif @@ -63,7 +63,7 @@ struct __lce_ta; // 64 -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 template struct __lce_ta<_Ap, _Cp, _Mp, (unsigned long long)(-1), _LCE_Promote> { typedef unsigned long long result_type; diff --git a/libcxx/include/__random/log2.h b/libcxx/include/__random/log2.h index 74b4889c6402b..c96a5247ff6db 100644 --- a/libcxx/include/__random/log2.h +++ b/libcxx/include/__random/log2.h @@ -38,7 +38,7 @@ struct __log2_imp { static const size_t value = _Rp + 1; }; -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 template <__uint128_t _Xp, size_t _Rp> struct __log2_imp<__uint128_t, _Xp, _Rp> { @@ -47,16 +47,16 @@ struct __log2_imp<__uint128_t, _Xp, _Rp> { : __log2_imp::value; }; -#endif // _LIBCPP_HAS_NO_INT128 +#endif // _LIBCPP_HAS_INT128 template struct __log2 { static const size_t value = __log2_imp< -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 __conditional_t, #else unsigned long long, -#endif // _LIBCPP_HAS_NO_INT128 +#endif // _LIBCPP_HAS_INT128 _Xp, sizeof(_UIntType) * __CHAR_BIT__ - 1>::value; }; diff --git a/libcxx/include/__split_buffer b/libcxx/include/__split_buffer index 7916769bd83bf..dfe552fbb4589 100644 --- a/libcxx/include/__split_buffer +++ b/libcxx/include/__split_buffer @@ -440,9 +440,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::reserve(size template _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { if (capacity() > size()) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __split_buffer __t(size(), 0, __alloc()); __t.__construct_at_end(move_iterator(__begin_), move_iterator(__end_)); __t.__end_ = __t.__begin_ + (__end_ - __begin_); @@ -450,10 +450,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::shrink_to_fi std::swap(__begin_, __t.__begin_); std::swap(__end_, __t.__end_); std::swap(__end_cap(), __t.__end_cap()); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } diff --git a/libcxx/include/__string/char_traits.h b/libcxx/include/__string/char_traits.h index 9b7d567dd3c27..107f0a96a0227 100644 --- a/libcxx/include/__string/char_traits.h +++ b/libcxx/include/__string/char_traits.h @@ -257,7 +257,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits : __char_traits_base struct _LIBCPP_TEMPLATE_VIS char_traits @@ -277,7 +277,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits } }; -#endif // _LIBCPP_HAS_NO_CHAR8_T +#endif // _LIBCPP_HAS_CHAR8_T template <> struct _LIBCPP_TEMPLATE_VIS char_traits diff --git a/libcxx/include/__string/constexpr_c_functions.h b/libcxx/include/__string/constexpr_c_functions.h index 9b8871e2e71a3..e62a7b0cd1b3b 100644 --- a/libcxx/include/__string/constexpr_c_functions.h +++ b/libcxx/include/__string/constexpr_c_functions.h @@ -43,7 +43,7 @@ inline const bool __is_char_type = false; template <> inline const bool __is_char_type = true; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T template <> inline const bool __is_char_type = true; #endif diff --git a/libcxx/include/__system_error/system_error.h b/libcxx/include/__system_error/system_error.h index 3ffa1029ca5c2..2763aaba88f5f 100644 --- a/libcxx/include/__system_error/system_error.h +++ b/libcxx/include/__system_error/system_error.h @@ -41,7 +41,7 @@ class _LIBCPP_EXPORTED_FROM_ABI system_error : public runtime_error { [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_system_error(int __ev, const char* __what_arg); [[__noreturn__]] _LIBCPP_HIDE_FROM_ABI inline void __throw_system_error(error_code __ec, const char* __what_arg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw system_error(__ec, __what_arg); #else _LIBCPP_VERBOSE_ABORT( diff --git a/libcxx/include/__type_traits/is_integral.h b/libcxx/include/__type_traits/is_integral.h index 26969885af8df..61178720a5938 100644 --- a/libcxx/include/__type_traits/is_integral.h +++ b/libcxx/include/__type_traits/is_integral.h @@ -28,7 +28,7 @@ template <> struct __libcpp_is_integral { enum { va #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS template <> struct __libcpp_is_integral { enum { value = 1 }; }; #endif -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T template <> struct __libcpp_is_integral { enum { value = 1 }; }; #endif template <> struct __libcpp_is_integral { enum { value = 1 }; }; @@ -41,7 +41,7 @@ template <> struct __libcpp_is_integral { enum { va template <> struct __libcpp_is_integral { enum { value = 1 }; }; template <> struct __libcpp_is_integral { enum { value = 1 }; }; template <> struct __libcpp_is_integral { enum { value = 1 }; }; -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 template <> struct __libcpp_is_integral<__int128_t> { enum { value = 1 }; }; template <> struct __libcpp_is_integral<__uint128_t> { enum { value = 1 }; }; #endif diff --git a/libcxx/include/__type_traits/is_pointer.h b/libcxx/include/__type_traits/is_pointer.h index 38eb7996c6864..9701e57807cf6 100644 --- a/libcxx/include/__type_traits/is_pointer.h +++ b/libcxx/include/__type_traits/is_pointer.h @@ -40,7 +40,7 @@ template struct __libcpp_remove_objc_qualifiers { typedef _Tp type; }; -# if defined(_LIBCPP_HAS_OBJC_ARC) +# if _LIBCPP_HAS_OBJC_ARC // clang-format off template struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; }; template struct __libcpp_remove_objc_qualifiers<_Tp __weak> { typedef _Tp type; }; diff --git a/libcxx/include/__type_traits/is_scalar.h b/libcxx/include/__type_traits/is_scalar.h index 455200de47208..242023a6877c9 100644 --- a/libcxx/include/__type_traits/is_scalar.h +++ b/libcxx/include/__type_traits/is_scalar.h @@ -37,7 +37,7 @@ inline constexpr bool is_scalar_v = __is_scalar(_Tp); template struct __is_block : false_type {}; -# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS) +# if _LIBCPP_HAS_EXTENSION_BLOCKS template struct __is_block<_Rp (^)(_Args...)> : true_type {}; # endif diff --git a/libcxx/include/__type_traits/is_signed_integer.h b/libcxx/include/__type_traits/is_signed_integer.h index 467548d0aaafb..a3e19a66f2c74 100644 --- a/libcxx/include/__type_traits/is_signed_integer.h +++ b/libcxx/include/__type_traits/is_signed_integer.h @@ -25,7 +25,7 @@ template <> struct __libcpp_is_signed_integer : publi template <> struct __libcpp_is_signed_integer : public true_type {}; template <> struct __libcpp_is_signed_integer : public true_type {}; template <> struct __libcpp_is_signed_integer : public true_type {}; -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 template <> struct __libcpp_is_signed_integer<__int128_t> : public true_type {}; #endif // clang-format on diff --git a/libcxx/include/__type_traits/is_unsigned_integer.h b/libcxx/include/__type_traits/is_unsigned_integer.h index 265894b32d4fc..86e42a1e8156a 100644 --- a/libcxx/include/__type_traits/is_unsigned_integer.h +++ b/libcxx/include/__type_traits/is_unsigned_integer.h @@ -25,7 +25,7 @@ template <> struct __libcpp_is_unsigned_integer : p template <> struct __libcpp_is_unsigned_integer : public true_type {}; template <> struct __libcpp_is_unsigned_integer : public true_type {}; template <> struct __libcpp_is_unsigned_integer : public true_type {}; -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 template <> struct __libcpp_is_unsigned_integer<__uint128_t> : public true_type {}; #endif // clang-format on diff --git a/libcxx/include/__type_traits/make_32_64_or_128_bit.h b/libcxx/include/__type_traits/make_32_64_or_128_bit.h index f7f2e81735daf..70f84fcd18686 100644 --- a/libcxx/include/__type_traits/make_32_64_or_128_bit.h +++ b/libcxx/include/__type_traits/make_32_64_or_128_bit.h @@ -35,7 +35,7 @@ using __make_32_64_or_128_bit_t = __copy_unsigned_t<_Tp, __conditional_t #else diff --git a/libcxx/include/__type_traits/make_signed.h b/libcxx/include/__type_traits/make_signed.h index d09d6ed4a1e7c..8070690b3a7a9 100644 --- a/libcxx/include/__type_traits/make_signed.h +++ b/libcxx/include/__type_traits/make_signed.h @@ -35,11 +35,11 @@ typedef __type_list # endif > > > > > __signed_types; @@ -63,7 +63,7 @@ template <> struct __make_signed< signed long, true> {typedef long ty template <> struct __make_signed {typedef long type;}; template <> struct __make_signed< signed long long, true> {typedef long long type;}; template <> struct __make_signed {typedef long long type;}; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 template <> struct __make_signed<__int128_t, true> {typedef __int128_t type;}; template <> struct __make_signed<__uint128_t, true> {typedef __int128_t type;}; # endif diff --git a/libcxx/include/__type_traits/make_unsigned.h b/libcxx/include/__type_traits/make_unsigned.h index 8757f451eb807..562f7bab8a7fb 100644 --- a/libcxx/include/__type_traits/make_unsigned.h +++ b/libcxx/include/__type_traits/make_unsigned.h @@ -37,11 +37,11 @@ typedef __type_list # endif > > > > > __unsigned_types; @@ -65,7 +65,7 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l template <> struct __make_unsigned {typedef unsigned long type;}; template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;}; template <> struct __make_unsigned {typedef unsigned long long type;}; -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 template <> struct __make_unsigned<__int128_t, true> {typedef __uint128_t type;}; template <> struct __make_unsigned<__uint128_t, true> {typedef __uint128_t type;}; # endif diff --git a/libcxx/include/__type_traits/promote.h b/libcxx/include/__type_traits/promote.h index 2b2a6843b9150..0f545bc507398 100644 --- a/libcxx/include/__type_traits/promote.h +++ b/libcxx/include/__type_traits/promote.h @@ -39,7 +39,7 @@ class __promote { static double __test(unsigned long); static double __test(long long); static double __test(unsigned long long); -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 static double __test(__int128_t); static double __test(__uint128_t); # endif @@ -63,7 +63,7 @@ struct __numeric_type { static double __test(unsigned long); static double __test(long long); static double __test(unsigned long long); -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 static double __test(__int128_t); static double __test(__uint128_t); # endif diff --git a/libcxx/include/__utility/convert_to_integral.h b/libcxx/include/__utility/convert_to_integral.h index f1fcdd98010cc..8947c349d8302 100644 --- a/libcxx/include/__utility/convert_to_integral.h +++ b/libcxx/include/__utility/convert_to_integral.h @@ -42,7 +42,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR long long __convert_to_integral(_ return __val; } -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __int128_t __convert_to_integral(__int128_t __val) { return __val; } inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } diff --git a/libcxx/include/__utility/exception_guard.h b/libcxx/include/__utility/exception_guard.h index 9f732ca265c86..a03bd7e8f3522 100644 --- a/libcxx/include/__utility/exception_guard.h +++ b/libcxx/include/__utility/exception_guard.h @@ -44,7 +44,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // less common, especially one that tries to catch an exception through -fno-exceptions code. // // __exception_guard can help greatly simplify code that would normally be cluttered by -// `#if _LIBCPP_HAS_NO_EXCEPTIONS`. For example: +// `#if _LIBCPP_HAS_EXCEPTIONS`. For example: // // template // Iterator uninitialized_copy_n(Iterator iter, Size n, OutputIterator out) { @@ -124,7 +124,7 @@ struct __exception_guard_noexceptions { _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__exception_guard_noexceptions); -#ifdef _LIBCPP_HAS_NO_EXCEPTIONS +#if !_LIBCPP_HAS_EXCEPTIONS template using __exception_guard = __exception_guard_noexceptions<_Rollback>; #else diff --git a/libcxx/include/any b/libcxx/include/any index 6e4ff31ff9b62..e32aa7f8e8a42 100644 --- a/libcxx/include/any +++ b/libcxx/include/any @@ -128,7 +128,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #if _LIBCPP_STD_VER >= 17 [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_any_cast(); # else _LIBCPP_VERBOSE_ABORT("bad_any_cast was thrown in -fno-exceptions mode"); @@ -176,7 +176,7 @@ inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() { template inline _LIBCPP_HIDE_FROM_ABI bool __compare_typeid(type_info const* __id, const void* __fallback_id) { -# if !defined(_LIBCPP_HAS_NO_RTTI) +# if _LIBCPP_HAS_RTTI if (__id && *__id == typeid(_Tp)) return true; # endif @@ -266,7 +266,7 @@ public: // 6.3.4 any observers _LIBCPP_HIDE_FROM_ABI bool has_value() const _NOEXCEPT { return __h_ != nullptr; } -# if !defined(_LIBCPP_HAS_NO_RTTI) +# if _LIBCPP_HAS_RTTI _LIBCPP_HIDE_FROM_ABI const type_info& type() const _NOEXCEPT { if (__h_) { return *static_cast(this->__call(_Action::_TypeInfo)); @@ -372,7 +372,7 @@ private: } _LIBCPP_HIDE_FROM_ABI static void* __type_info() { -# if !defined(_LIBCPP_HAS_NO_RTTI) +# if _LIBCPP_HAS_RTTI return const_cast(static_cast(&typeid(_Tp))); # else return nullptr; @@ -444,7 +444,7 @@ private: } _LIBCPP_HIDE_FROM_ABI static void* __type_info() { -# if !defined(_LIBCPP_HAS_NO_RTTI) +# if _LIBCPP_HAS_RTTI return const_cast(static_cast(&typeid(_Tp))); # else return nullptr; @@ -579,7 +579,7 @@ _LIBCPP_HIDE_FROM_ABI add_pointer_t<_ValueType> any_cast(any* __any) _NOEXCEPT { void* __p = __any->__call( _Action::_Get, nullptr, -# if !defined(_LIBCPP_HAS_NO_RTTI) +# if _LIBCPP_HAS_RTTI &typeid(_ValueType), # else nullptr, diff --git a/libcxx/include/atomic b/libcxx/include/atomic index bf65750672bb0..ebd46238eec98 100644 --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -613,7 +613,7 @@ template # pragma GCC system_header #endif -#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER +#if !_LIBCPP_HAS_ATOMIC_HEADER # error is not implemented #endif diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar index bfc26f03aaf78..1d156eb7aaaf3 100644 --- a/libcxx/include/cuchar +++ b/libcxx/include/cuchar @@ -59,7 +59,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD using ::mbstate_t _LIBCPP_USING_IF_EXISTS; -# if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8) +# if _LIBCPP_HAS_C8RTOMB_MBRTOC8 using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS; using ::c8rtomb _LIBCPP_USING_IF_EXISTS; # endif diff --git a/libcxx/include/deque b/libcxx/include/deque index bab0526629f0f..fa67916ba11bc 100644 --- a/libcxx/include/deque +++ b/libcxx/include/deque @@ -918,7 +918,7 @@ private: (void)__end; (void)__annotation_type; (void)__place; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN // __beg - index of the first item to annotate // __end - index behind the last item to annotate (so last item + 1) // __annotation_type - __asan_unposion or __asan_poison @@ -1011,23 +1011,23 @@ private: std::__annotate_double_ended_contiguous_container<_Allocator>( __mem_beg, __mem_end, __old_beg, __old_end, __new_beg, __new_end); } -#endif // !_LIBCPP_HAS_NO_ASAN +#endif // _LIBCPP_HAS_ASAN } _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { (void)__current_size; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN if (__current_size == 0) __annotate_from_to(0, __map_.size() * __block_size, __asan_poison, __asan_back_moved); else { __annotate_from_to(0, __start_, __asan_poison, __asan_front_moved); __annotate_from_to(__start_ + __current_size, __map_.size() * __block_size, __asan_poison, __asan_back_moved); } -#endif +#endif // _LIBCPP_HAS_ASAN } _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN if (empty()) { for (size_t __i = 0; __i < __map_.size(); ++__i) { __annotate_whole_block(__i, __asan_unposion); @@ -1036,19 +1036,19 @@ private: __annotate_from_to(0, __start_, __asan_unposion, __asan_front_moved); __annotate_from_to(__start_ + size(), __map_.size() * __block_size, __asan_unposion, __asan_back_moved); } -#endif +#endif // _LIBCPP_HAS_ASAN } _LIBCPP_HIDE_FROM_ABI void __annotate_increase_front(size_type __n) const _NOEXCEPT { (void)__n; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __annotate_from_to(__start_ - __n, __start_, __asan_unposion, __asan_front_moved); #endif } _LIBCPP_HIDE_FROM_ABI void __annotate_increase_back(size_type __n) const _NOEXCEPT { (void)__n; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __annotate_from_to(__start_ + size(), __start_ + size() + __n, __asan_unposion, __asan_back_moved); #endif } @@ -1056,7 +1056,7 @@ private: _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_front(size_type __old_size, size_type __old_start) const _NOEXCEPT { (void)__old_size; (void)__old_start; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __annotate_from_to(__old_start, __old_start + (__old_size - size()), __asan_poison, __asan_front_moved); #endif } @@ -1064,7 +1064,7 @@ private: _LIBCPP_HIDE_FROM_ABI void __annotate_shrink_back(size_type __old_size, size_type __old_start) const _NOEXCEPT { (void)__old_size; (void)__old_start; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __annotate_from_to(__old_start + size(), __old_start + __old_size, __asan_poison, __asan_back_moved); #endif } @@ -1077,7 +1077,7 @@ private: __annotate_whole_block(size_t __block_index, __asan_annotation_type __annotation_type) const _NOEXCEPT { (void)__block_index; (void)__annotation_type; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __map_const_iterator __block_it = __map_.begin() + __block_index; const void* __block_start = std::__to_address(*__block_it); const void* __block_end = std::__to_address(*__block_it + __block_size); @@ -1090,7 +1090,7 @@ private: } #endif } -#if !defined(_LIBCPP_HAS_NO_ASAN) +#if _LIBCPP_HAS_ASAN public: _LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT { @@ -1152,7 +1152,7 @@ public: } private: -#endif // _LIBCPP_VERIFY_ASAN_DEQUE_ANNOTATIONS +#endif // _LIBCPP_HAS_ASAN _LIBCPP_HIDE_FROM_ABI bool __maybe_remove_front_spare(bool __keep_one = true) { if (__front_spare_blocks() >= 2 || (!__keep_one && __front_spare_blocks())) { __annotate_whole_block(0, __asan_unposion); @@ -2123,22 +2123,22 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) { size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty(); __split_buffer __buf( std::max(2 * __map_.capacity(), __nb + __map_.size()), 0, __map_.__alloc()); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (; __nb > 0; --__nb) { __buf.push_back(__alloc_traits::allocate(__a, __block_size)); // ASan: this is empty container, we have to poison whole block __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __annotate_delete(); for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) __alloc_traits::deallocate(__a, *__i, __block_size); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (; __back_capacity > 0; --__back_capacity) { __buf.push_back(__map_.back()); __map_.pop_back(); @@ -2248,22 +2248,22 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) { std::max(2 * __map_.capacity(), __nb + __map_.size()), __map_.size() - __front_capacity, __map_.__alloc()); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (; __nb > 0; --__nb) { __buf.push_back(__alloc_traits::allocate(__a, __block_size)); // ASan: this is an empty container, we have to poison the whole block __annotate_poison_block(std::__to_address(__buf.back()), std::__to_address(__buf.back() + __block_size)); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __annotate_delete(); for (__map_pointer __i = __buf.begin(); __i != __buf.end(); ++__i) __alloc_traits::deallocate(__a, *__i, __block_size); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (; __front_capacity > 0; --__front_capacity) { __buf.push_back(__map_.front()); __map_.pop_front(); diff --git a/libcxx/include/experimental/__simd/utility.h b/libcxx/include/experimental/__simd/utility.h index 0103b06b71953..01736925d155c 100644 --- a/libcxx/include/experimental/__simd/utility.h +++ b/libcxx/include/experimental/__simd/utility.h @@ -47,7 +47,7 @@ _LIBCPP_HIDE_FROM_ABI auto __choose_mask_type() { } else if constexpr (sizeof(_Tp) == 8) { return uint64_t{}; } -# ifndef _LIBCPP_HAS_NO_INT128 +# if _LIBCPP_HAS_INT128 else if constexpr (sizeof(_Tp) == 16) { return __uint128_t{}; } diff --git a/libcxx/include/forward_list b/libcxx/include/forward_list index c5ae8add511cf..dd86888bf7a6e 100644 --- a/libcxx/include/forward_list +++ b/libcxx/include/forward_list @@ -1122,13 +1122,13 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const if (__n > 0) { __node_pointer __first = this->__create_node(/* next = */ nullptr, __v); __node_pointer __last = __first; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (--__n; __n != 0; --__n, __last = __last->__next_) { __last->__next_ = this->__create_node(/* next = */ nullptr, __v); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (__first != nullptr) { __node_pointer __next = __first->__next_; @@ -1137,7 +1137,7 @@ forward_list<_Tp, _Alloc>::insert_after(const_iterator __p, size_type __n, const } throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __last->__next_ = __r->__next_; __r->__next_ = __first; __r = static_cast<__begin_node_pointer>(__last); @@ -1162,13 +1162,13 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp __node_pointer __first = this->__create_node(/* next = */ nullptr, *__f); __node_pointer __last = __first; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (++__f; __f != __l; ++__f, ((void)(__last = __last->__next_))) { __last->__next_ = this->__create_node(/* next = */ nullptr, *__f); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (__first != nullptr) { __node_pointer __next = __first->__next_; @@ -1177,7 +1177,7 @@ forward_list<_Tp, _Alloc>::__insert_after_with_sentinel(const_iterator __p, _Inp } throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __last->__next_ = __r->__next_; __r->__next_ = __first; diff --git a/libcxx/include/fstream b/libcxx/include/fstream index de7c614836bab..dce0efc71d8e5 100644 --- a/libcxx/include/fstream +++ b/libcxx/include/fstream @@ -211,8 +211,10 @@ typedef basic_fstream wfstream; _LIBCPP_PUSH_MACROS #include <__undef_macros> -#if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION) -# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS +#if !defined(_LIBCPP_MSVCRT) && !defined(_NEWLIB_VERSION) +# define _LIBCPP_HAS_OFF_T_FUNCTIONS 1 +#else +# define _LIBCPP_HAS_OFF_T_FUNCTIONS 0 #endif #if !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION) @@ -254,7 +256,7 @@ public: // 27.9.1.4 Members: _LIBCPP_HIDE_FROM_ABI bool is_open() const; basic_filebuf* open(const char* __s, ios_base::openmode __mode); -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR basic_filebuf* open(const wchar_t* __s, ios_base::openmode __mode); # endif _LIBCPP_HIDE_FROM_ABI basic_filebuf* open(const string& __s, ios_base::openmode __mode); @@ -281,7 +283,7 @@ public: # endif // _LIBCPP_STD_VER >= 26 _LIBCPP_HIDE_FROM_ABI inline static const char* __make_mdstring(ios_base::openmode __mode) _NOEXCEPT; -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR _LIBCPP_HIDE_FROM_ABI inline static const wchar_t* __make_mdwstring(ios_base::openmode __mode) _NOEXCEPT; # endif @@ -485,14 +487,14 @@ inline basic_filebuf<_CharT, _Traits>& basic_filebuf<_CharT, _Traits>::operator= template basic_filebuf<_CharT, _Traits>::~basic_filebuf() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS close(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (__owns_eb_) delete[] __extbuf_; if (__owns_ib_) @@ -630,7 +632,7 @@ const char* basic_filebuf<_CharT, _Traits>::__make_mdstring(ios_base::openmode _ __libcpp_unreachable(); } -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template const wchar_t* basic_filebuf<_CharT, _Traits>::__make_mdwstring(ios_base::openmode __mode) _NOEXCEPT { switch (__mode & ~ios_base::ate) { @@ -705,7 +707,7 @@ inline basic_filebuf<_CharT, _Traits>* basic_filebuf<_CharT, _Traits>::__open(in return __do_open(fdopen(__fd, __mdstr), __mode); } -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR // This is basically the same as the char* overload except that it uses _wfopen // and long mode strings. template @@ -929,7 +931,7 @@ basic_filebuf<_CharT, _Traits>::seekoff(off_type __off, ios_base::seekdir __way, default: return pos_type(off_type(-1)); } -# if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) +# if !_LIBCPP_HAS_OFF_T_FUNCTIONS if (fseek(__file_, __width > 0 ? __width * __off : 0, __whence)) return pos_type(off_type(-1)); pos_type __r = ftell(__file_); @@ -947,7 +949,7 @@ typename basic_filebuf<_CharT, _Traits>::pos_type basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode) { if (__file_ == nullptr || sync()) return pos_type(off_type(-1)); -# if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) +# if !_LIBCPP_HAS_OFF_T_FUNCTIONS if (fseek(__file_, __sp, SEEK_SET)) return pos_type(off_type(-1)); # else @@ -1000,7 +1002,7 @@ int basic_filebuf<_CharT, _Traits>::sync() { } } } -# if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS) +# if !_LIBCPP_HAS_OFF_T_FUNCTIONS if (fseek(__file_, -__c, SEEK_CUR)) return -1; # else @@ -1098,7 +1100,7 @@ public: _LIBCPP_HIDE_FROM_ABI basic_ifstream(); _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const char* __s, ios_base::openmode __mode = ios_base::in); -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); # endif _LIBCPP_HIDE_FROM_ABI explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in); @@ -1118,7 +1120,7 @@ public: # endif _LIBCPP_HIDE_FROM_ABI bool is_open() const; void open(const char* __s, ios_base::openmode __mode = ios_base::in); -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in); # endif void open(const string& __s, ios_base::openmode __mode = ios_base::in); @@ -1147,7 +1149,7 @@ inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base this->setstate(ios_base::failbit); } -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode) : basic_istream(std::addressof(__sb_)) { @@ -1206,7 +1208,7 @@ void basic_ifstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _ this->setstate(ios_base::failbit); } -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template void basic_ifstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { if (__sb_.open(__s, __mode | ios_base::in)) @@ -1254,7 +1256,7 @@ public: _LIBCPP_HIDE_FROM_ABI basic_ofstream(); _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const char* __s, ios_base::openmode __mode = ios_base::out); -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); # endif _LIBCPP_HIDE_FROM_ABI explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out); @@ -1276,7 +1278,7 @@ public: # endif _LIBCPP_HIDE_FROM_ABI bool is_open() const; void open(const char* __s, ios_base::openmode __mode = ios_base::out); -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::out); # endif void open(const string& __s, ios_base::openmode __mode = ios_base::out); @@ -1306,7 +1308,7 @@ inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base this->setstate(ios_base::failbit); } -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode) : basic_ostream(std::addressof(__sb_)) { @@ -1365,7 +1367,7 @@ void basic_ofstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode _ this->setstate(ios_base::failbit); } -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template void basic_ofstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { if (__sb_.open(__s, __mode | ios_base::out)) @@ -1414,7 +1416,7 @@ public: _LIBCPP_HIDE_FROM_ABI basic_fstream(); _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR _LIBCPP_HIDE_FROM_ABI explicit basic_fstream(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); # endif @@ -1440,7 +1442,7 @@ public: # endif _LIBCPP_HIDE_FROM_ABI bool is_open() const; _LIBCPP_HIDE_FROM_ABI void open(const char* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR void open(const wchar_t* __s, ios_base::openmode __mode = ios_base::in | ios_base::out); # endif _LIBCPP_HIDE_FROM_ABI void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out); @@ -1469,7 +1471,7 @@ inline basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base:: this->setstate(ios_base::failbit); } -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template inline basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode) : basic_iostream(std::addressof(__sb_)) { @@ -1528,7 +1530,7 @@ void basic_fstream<_CharT, _Traits>::open(const char* __s, ios_base::openmode __ this->setstate(ios_base::failbit); } -# ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR +# if _LIBCPP_HAS_OPEN_WITH_WCHAR template void basic_fstream<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode) { if (__sb_.open(__s, __mode)) diff --git a/libcxx/include/future b/libcxx/include/future index 7dc38a3354bb4..dfa373d6593c7 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -500,7 +500,7 @@ public: // Declared above std::future_error void __throw_future_error(future_errc __ev) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw future_error(make_error_code(__ev)); # else (void)__ev; @@ -779,15 +779,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f template void __deferred_assoc_state<_Rp, _Fp>::__execute() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->set_value(__func_()); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -809,16 +809,16 @@ inline __deferred_assoc_state::__deferred_assoc_state(_Fp&& __f) : __ template void __deferred_assoc_state::__execute() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __func_(); this->set_value(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -840,15 +840,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s template void __async_assoc_state<_Rp, _Fp>::__execute() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->set_value(__func_()); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -876,16 +876,16 @@ inline __async_assoc_state::__async_assoc_state(_Fp&& __f) : __func_( template void __async_assoc_state::__execute() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __func_(); this->set_value(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->set_exception(current_exception()); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1656,15 +1656,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __p_.set_value(__f_(std::forward<_ArgTypes>(__args)...)); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1673,15 +1673,15 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __ __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...)); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1758,16 +1758,16 @@ void packaged_task::operator()(_ArgTypes... __args) { __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __f_(std::forward<_ArgTypes>(__args)...); __p_.set_value(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __p_.set_exception(current_exception()); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1776,16 +1776,16 @@ void packaged_task::make_ready_at_thread_exit(_ArgTypes... _ __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) __throw_future_error(future_errc::promise_already_satisfied); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __f_(std::forward<_ArgTypes>(__args)...); __p_.set_value_at_thread_exit(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __p_.set_exception_at_thread_exit(current_exception()); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -1857,13 +1857,13 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF; typedef typename _BF::_Rp _Rp; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif if (__does_policy_contain(__policy, launch::async)) return std::__make_async_assoc_state<_Rp>( _BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...)); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { if (__policy == launch::async) throw; diff --git a/libcxx/include/iomanip b/libcxx/include/iomanip index 2c4023d4ee44a..538fc413bb8ee 100644 --- a/libcxx/include/iomanip +++ b/libcxx/include/iomanip @@ -236,9 +236,9 @@ public: template _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { typedef istreambuf_iterator<_CharT, _Traits> _Ip; @@ -248,11 +248,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) { __mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_); __is.setstate(__err); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __is; } @@ -285,9 +285,9 @@ public: template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Op; @@ -296,11 +296,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) { if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed()) __os.setstate(ios_base::badbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __os; } @@ -333,9 +333,9 @@ public: template _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { typedef istreambuf_iterator<_CharT, _Traits> _Ip; @@ -345,11 +345,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) { __tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_)); __is.setstate(__err); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __is.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __is; } @@ -382,9 +382,9 @@ public: template _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typename basic_ostream<_CharT, _Traits>::sentry __s(__os); if (__s) { typedef ostreambuf_iterator<_CharT, _Traits> _Op; @@ -394,11 +394,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) { .failed()) __os.setstate(ios_base::badbit); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __os.__set_badbit_and_consider_rethrow(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS return __os; } diff --git a/libcxx/include/ios b/libcxx/include/ios index d4f15a269a11a..546c5462f222d 100644 --- a/libcxx/include/ios +++ b/libcxx/include/ios @@ -232,7 +232,7 @@ storage-class-specifier const error_category& iostream_category() noexcept; // [ios.syn] # include -# if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) +# if _LIBCPP_HAS_ATOMIC_HEADER # include <__atomic/atomic.h> // for __xindex_ # endif @@ -441,7 +441,7 @@ public: }; [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_failure(char const* __msg) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw ios_base::failure(__msg); # else _LIBCPP_VERBOSE_ABORT("ios_base::failure was thrown in -fno-exceptions mode with message \"%s\"", __msg); diff --git a/libcxx/include/iosfwd b/libcxx/include/iosfwd index eeafcc37c598e..9079ce21512f9 100644 --- a/libcxx/include/iosfwd +++ b/libcxx/include/iosfwd @@ -134,7 +134,7 @@ typedef fpos streampos; #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS typedef fpos wstreampos; #endif -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T typedef fpos u8streampos; #endif typedef fpos u16streampos; diff --git a/libcxx/include/istream b/libcxx/include/istream index 8ee29ba3302f2..45ca95369c51d 100644 --- a/libcxx/include/istream +++ b/libcxx/include/istream @@ -357,13 +357,13 @@ __input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) { ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typedef istreambuf_iterator<_CharT, _Traits> _Ip; typedef num_get<_CharT, _Ip> _Fp; std::use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -438,9 +438,9 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __s(__is); if (__s) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS typedef istreambuf_iterator<_CharT, _Traits> _Ip; typedef num_get<_CharT, _Ip> _Fp; long __temp; @@ -454,7 +454,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp } else { __n = static_cast<_Tp>(__temp); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -462,7 +462,7 @@ __input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __is.setstate(__state); } return __is; @@ -484,7 +484,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif _CharT* __s = __p; @@ -505,7 +505,7 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n) __is.width(0); if (__s == __p) __state |= ios_base::failbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -572,7 +572,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_ ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif typename _Traits::int_type __i = __is.rdbuf()->sbumpc(); @@ -580,7 +580,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& operator>>(basic_istream<_ __state |= ios_base::eofbit | ios_base::failbit; else __c = _Traits::to_char_type(__i); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -614,9 +614,9 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambufrdbuf()->sgetc(); if (traits_type::eq_int_type(__i, _Traits::eof())) { @@ -630,7 +630,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf::operator>>(basic_streambuf::int_type basic_istream<_CharT, _Traits> int_type __r = traits_type::eof(); sentry __s(*this, true); if (__s) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif __r = this->rdbuf()->sbumpc(); @@ -665,7 +665,7 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> __state |= ios_base::failbit | ios_base::eofbit; else __gc_ = 1; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__setstate_nothrow(this->rdstate() | ios_base::badbit); if (this->exceptions() & ios_base::badbit) { @@ -685,7 +685,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ sentry __sen(*this, true); if (__sen) { if (__n > 0) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif while (__gc_ < __n - 1) { @@ -703,7 +703,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* _ } if (__gc_ == 0) __state |= ios_base::failbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -734,9 +734,9 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf& __s __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { @@ -751,12 +751,12 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf& __s __inc_gcount(); this->rdbuf()->sbumpc(); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; // according to the spec, exceptions here are caught but not rethrown } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (__gc_ == 0) __state |= ios_base::failbit; this->setstate(__state); @@ -771,9 +771,9 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS while (true) { typename traits_type::int_type __i = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__i, traits_type::eof())) { @@ -794,7 +794,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ this->rdbuf()->sbumpc(); __inc_gcount(); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -806,7 +806,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } if (__n > 0) *__s = char_type(); @@ -822,9 +822,9 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (__n == numeric_limits::max()) { while (true) { typename traits_type::int_type __i = this->rdbuf()->sbumpc(); @@ -848,7 +848,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz break; } } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -856,7 +856,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::ignore(streamsiz throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return *this; @@ -869,13 +869,13 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> int_type __r = traits_type::eof(); sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __r = this->rdbuf()->sgetc(); if (traits_type::eq_int_type(__r, traits_type::eof())) __state |= ios_base::eofbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -883,7 +883,7 @@ typename basic_istream<_CharT, _Traits>::int_type basic_istream<_CharT, _Traits> throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return __r; @@ -895,13 +895,13 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __gc_ = this->rdbuf()->sgetn(__s, __n); if (__gc_ != __n) __state |= ios_base::failbit | ios_base::eofbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -909,7 +909,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::read(char_type* throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -923,9 +923,9 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ __gc_ = 0; sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS streamsize __c = this->rdbuf()->in_avail(); switch (__c) { case -1: @@ -940,7 +940,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ __state |= ios_base::failbit | ios_base::eofbit; break; } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -948,7 +948,7 @@ streamsize basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize _ throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -963,12 +963,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ this->clear(__state); sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf() == nullptr || this->rdbuf()->sputbackc(__c) == traits_type::eof()) __state |= ios_base::badbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -976,7 +976,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::putback(char_typ throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -991,12 +991,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { this->clear(__state); sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf() == nullptr || this->rdbuf()->sungetc() == traits_type::eof()) __state |= ios_base::badbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1004,7 +1004,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::unget() { throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } else { __state |= ios_base::failbit; } @@ -1021,14 +1021,14 @@ int basic_istream<_CharT, _Traits>::sync() { int __r = 0; if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf()->pubsync() == -1) { __state |= ios_base::badbit; __r = -1; } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1036,7 +1036,7 @@ int basic_istream<_CharT, _Traits>::sync() { throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return __r; @@ -1048,11 +1048,11 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits> pos_type __r(-1); sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1060,7 +1060,7 @@ typename basic_istream<_CharT, _Traits>::pos_type basic_istream<_CharT, _Traits> throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return __r; @@ -1072,12 +1072,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _ this->clear(__state); sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) __state |= ios_base::failbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1085,7 +1085,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(pos_type _ throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return *this; @@ -1097,12 +1097,12 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _ this->clear(__state); sentry __sen(*this, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) __state |= ios_base::failbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; this->__setstate_nothrow(__state); @@ -1110,7 +1110,7 @@ basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::seekg(off_type _ throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS this->setstate(__state); } return *this; @@ -1121,9 +1121,9 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS const ctype<_CharT>& __ct = std::use_facet >(__is.getloc()); while (true) { typename _Traits::int_type __i = __is.rdbuf()->sgetc(); @@ -1135,7 +1135,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ break; __is.rdbuf()->sbumpc(); } -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1143,7 +1143,7 @@ _LIBCPP_HIDE_FROM_ABI basic_istream<_CharT, _Traits>& ws(basic_istream<_CharT, _ throw; } } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __is.setstate(__state); } return __is; @@ -1211,7 +1211,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif __str.clear(); @@ -1243,7 +1243,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _ __is.width(0); if (__c == 0) __state |= ios_base::failbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1263,7 +1263,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif __str.clear(); @@ -1286,7 +1286,7 @@ getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _All } if (__extr == 0) __state |= ios_base::failbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); @@ -1324,7 +1324,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { ios_base::iostate __state = ios_base::goodbit; typename basic_istream<_CharT, _Traits>::sentry __sen(__is); if (__sen) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif basic_string<_CharT, _Traits> __str; @@ -1348,7 +1348,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) { __x = bitset<_Size>(__str); if (_Size > 0 && __c == 0) __state |= ios_base::failbit; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __state |= ios_base::badbit; __is.__setstate_nothrow(__state); diff --git a/libcxx/include/list b/libcxx/include/list index 05234f7696c6f..ba21dbe3f74c0 100644 --- a/libcxx/include/list +++ b/libcxx/include/list @@ -1157,13 +1157,13 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ ++__ds; __r = iterator(__node->__as_link()); iterator __e = __r; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (true) { __base_pointer __prev = __e.__ptr_->__prev_; @@ -1175,7 +1175,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ } throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); base::__sz() += __ds; } @@ -1199,13 +1199,13 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se ++__ds; __r = iterator(__node->__as_link()); iterator __e = __r; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) { __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link(); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (true) { __base_pointer __prev = __e.__ptr_->__prev_; @@ -1217,7 +1217,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se } throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_); base::__sz() += __ds; } @@ -1370,13 +1370,13 @@ void list<_Tp, _Alloc>::resize(size_type __n) { ++__ds; iterator __r = iterator(__node->__as_link()); iterator __e = __r; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link(); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (true) { __base_pointer __prev = __e.__ptr_->__prev_; @@ -1388,7 +1388,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) { } throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __link_nodes_at_back(__r.__ptr_, __e.__ptr_); base::__sz() += __ds; } @@ -1406,13 +1406,13 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { __base_pointer __nl = __node->__as_link(); iterator __r = iterator(__nl); iterator __e = __r; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (--__n; __n != 0; --__n, (void)++__e, ++__ds) { __e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link(); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { while (true) { __base_pointer __prev = __e.__ptr_->__prev_; @@ -1424,7 +1424,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { } throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_); base::__sz() += __ds; } diff --git a/libcxx/include/locale b/libcxx/include/locale index 573910a85bef5..782475ea7e0eb 100644 --- a/libcxx/include/locale +++ b/libcxx/include/locale @@ -223,7 +223,11 @@ template class messages_byname; # if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__) # define _LIBCPP_HAS_CATOPEN 1 # include +# else +# define _LIBCPP_HAS_CATOPEN 0 # endif +# else +# define _LIBCPP_HAS_CATOPEN 0 # endif # ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -3074,7 +3078,7 @@ locale::id messages<_CharT>::id; template typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string& __nm, const locale&) const { -# ifdef _LIBCPP_HAS_CATOPEN +# if _LIBCPP_HAS_CATOPEN return (catalog)catopen(__nm.c_str(), NL_CAT_LOCALE); # else // !_LIBCPP_HAS_CATOPEN (void)__nm; @@ -3085,7 +3089,7 @@ typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string< template typename messages<_CharT>::string_type messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& __dflt) const { -# ifdef _LIBCPP_HAS_CATOPEN +# if _LIBCPP_HAS_CATOPEN string __ndflt; __narrow_to_utf8()( std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size()); @@ -3105,7 +3109,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type& template void messages<_CharT>::do_close(catalog __c) const { -# ifdef _LIBCPP_HAS_CATOPEN +# if _LIBCPP_HAS_CATOPEN catclose((nl_catd)__c); # else // !_LIBCPP_HAS_CATOPEN (void)__c; diff --git a/libcxx/include/new b/libcxx/include/new index 3252b0bb1abcd..2947ee179510a 100644 --- a/libcxx/include/new +++ b/libcxx/include/new @@ -103,16 +103,22 @@ void operator delete[](void* ptr, void*) noexcept; # pragma GCC system_header #endif -#if !defined(__cpp_sized_deallocation) || __cpp_sized_deallocation < 201309L -# define _LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION +#if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309L +# define _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION 1 +#else +# define _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION 0 #endif -#if !defined(_LIBCPP_BUILDING_LIBRARY) && _LIBCPP_STD_VER < 14 && defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION) -# define _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION +#if _LIBCPP_STD_VER >= 14 || _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION +# define _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION 1 +#else +# define _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION 0 #endif -#if defined(_LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION) || defined(_LIBCPP_HAS_NO_LANGUAGE_SIZED_DEALLOCATION) -# define _LIBCPP_HAS_NO_SIZED_DEALLOCATION +#if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION && _LIBCPP_HAS_LANGUAGE_SIZED_DEALLOCATION +# define _LIBCPP_HAS_SIZED_DEALLOCATION 1 +#else +# define _LIBCPP_HAS_SIZED_DEALLOCATION 0 #endif namespace std // purposefully not using versioning namespace @@ -169,14 +175,14 @@ public: [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_bad_alloc(); // not in C++ spec [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_array_new_length() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw bad_array_new_length(); #else _LIBCPP_VERBOSE_ABORT("bad_array_new_length was thrown in -fno-exceptions mode"); #endif } -#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) && !defined(_LIBCPP_ABI_VCRUNTIME) +#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION && !defined(_LIBCPP_ABI_VCRUNTIME) # ifndef _LIBCPP_CXX03_LANG enum class align_val_t : size_t {}; # else @@ -208,7 +214,7 @@ inline constexpr destroying_delete_t destroying_delete{}; _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; -# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT; # endif @@ -217,17 +223,17 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _ _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; -# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT; # endif -# ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; [[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; -# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; # endif @@ -237,7 +243,7 @@ operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC; operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT; _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT; -# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION +# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT; # endif # endif @@ -284,7 +290,7 @@ _LIBCPP_HIDE_FROM_ABI void __libcpp_operator_delete(_Args... __args) { } inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __align) { -#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#if _LIBCPP_HAS_ALIGNED_ALLOCATION if (__is_overaligned_for_new(__align)) { const align_val_t __align_val = static_cast(__align); return __libcpp_operator_new(__size, __align_val); @@ -297,7 +303,7 @@ inline _LIBCPP_HIDE_FROM_ABI void* __libcpp_allocate(size_t __size, size_t __ali template _LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __size, _Args... __args) { -#ifdef _LIBCPP_HAS_NO_SIZED_DEALLOCATION +#if !_LIBCPP_HAS_SIZED_DEALLOCATION (void)__size; return std::__libcpp_operator_delete(__ptr, __args...); #else @@ -306,7 +312,7 @@ _LIBCPP_HIDE_FROM_ABI void __do_deallocate_handle_size(void* __ptr, size_t __siz } inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size, size_t __align) { -#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) +#if !_LIBCPP_HAS_ALIGNED_ALLOCATION (void)__align; return __do_deallocate_handle_size(__ptr, __size); #else @@ -320,7 +326,7 @@ inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate(void* __ptr, size_t __size } inline _LIBCPP_HIDE_FROM_ABI void __libcpp_deallocate_unsized(void* __ptr, size_t __align) { -#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) +#if !_LIBCPP_HAS_ALIGNED_ALLOCATION (void)__align; return __libcpp_operator_delete(__ptr); #else diff --git a/libcxx/include/optional b/libcxx/include/optional index 4e44ef990f5d2..b9dcf9053633f 100644 --- a/libcxx/include/optional +++ b/libcxx/include/optional @@ -260,7 +260,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void __throw_bad_optional_access() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_optional_access(); # else _LIBCPP_VERBOSE_ABORT("bad_optional_access was thrown in -fno-exceptions mode"); diff --git a/libcxx/include/regex b/libcxx/include/regex index d6b8768a257e3..074b19865cb4f 100644 --- a/libcxx/include/regex +++ b/libcxx/include/regex @@ -984,7 +984,7 @@ public: template [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_regex_error() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw regex_error(_Ev); #else _LIBCPP_VERBOSE_ABORT("regex_error was thrown in -fno-exceptions mode"); diff --git a/libcxx/include/sstream b/libcxx/include/sstream index c29abab9c5fc3..df039194996d7 100644 --- a/libcxx/include/sstream +++ b/libcxx/include/sstream @@ -786,9 +786,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { if (this->pptr() == this->epptr()) { if (!(__mode_ & ios_base::out)) return traits_type::eof(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS ptrdiff_t __nout = this->pptr() - this->pbase(); ptrdiff_t __hm = __hm_ - this->pbase(); __str_.push_back(char_type()); @@ -797,11 +797,11 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) { this->setp(__p, __p + __str_.size()); this->__pbump(__nout); __hm_ = this->pbase() + __hm; -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { return traits_type::eof(); } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } __hm_ = std::max(this->pptr() + 1, __hm_); if (__mode_ & ios_base::in) { diff --git a/libcxx/include/stdatomic.h b/libcxx/include/stdatomic.h index 3206f7da8c8c4..2f25b057df087 100644 --- a/libcxx/include/stdatomic.h +++ b/libcxx/include/stdatomic.h @@ -156,7 +156,7 @@ using std::atomic_long _LIBCPP_USING_IF_EXISTS; using std::atomic_ulong _LIBCPP_USING_IF_EXISTS; using std::atomic_llong _LIBCPP_USING_IF_EXISTS; using std::atomic_ullong _LIBCPP_USING_IF_EXISTS; -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS; # endif using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/include/stdexcept b/libcxx/include/stdexcept index bdfc27aeac374..daa7b501a8699 100644 --- a/libcxx/include/stdexcept +++ b/libcxx/include/stdexcept @@ -212,7 +212,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD [[__noreturn__]] _LIBCPP_EXPORTED_FROM_ABI void __throw_runtime_error(const char*); [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_logic_error(const char* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw logic_error(__msg); #else _LIBCPP_VERBOSE_ABORT("logic_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); @@ -220,7 +220,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_domain_error(const char* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw domain_error(__msg); #else _LIBCPP_VERBOSE_ABORT("domain_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); @@ -228,7 +228,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_invalid_argument(const char* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw invalid_argument(__msg); #else _LIBCPP_VERBOSE_ABORT("invalid_argument was thrown in -fno-exceptions mode with message \"%s\"", __msg); @@ -236,7 +236,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_length_error(const char* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw length_error(__msg); #else _LIBCPP_VERBOSE_ABORT("length_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); @@ -244,7 +244,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range(const char* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw out_of_range(__msg); #else _LIBCPP_VERBOSE_ABORT("out_of_range was thrown in -fno-exceptions mode with message \"%s\"", __msg); @@ -252,7 +252,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_range_error(const char* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw range_error(__msg); #else _LIBCPP_VERBOSE_ABORT("range_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); @@ -260,7 +260,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_overflow_error(const char* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw overflow_error(__msg); #else _LIBCPP_VERBOSE_ABORT("overflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); @@ -268,7 +268,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD } [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_underflow_error(const char* __msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw underflow_error(__msg); #else _LIBCPP_VERBOSE_ABORT("underflow_error was thrown in -fno-exceptions mode with message \"%s\"", __msg); diff --git a/libcxx/include/string b/libcxx/include/string index 685dbcbd4418e..4b5017f5e7753 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -672,7 +672,7 @@ basic_string operator""s( const char32_t *str, size_t len ); _LIBCPP_PUSH_MACROS #include <__undef_macros> -#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) # define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS __attribute__((__no_sanitize__("address"))) // This macro disables AddressSanitizer (ASan) instrumentation for a specific function, // allowing memory accesses that would normally trigger ASan errors to proceed without crashing. @@ -785,7 +785,7 @@ public: // // This string implementation doesn't contain any references into itself. It only contains a bit that says whether // it is in small or large string mode, so the entire structure is trivially relocatable if its members are. -#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) // When compiling with AddressSanitizer (ASan), basic_string cannot be trivially // relocatable. Because the object's memory might be poisoned when its content // is kept inside objects memory (short string optimization), instead of in allocated @@ -799,7 +799,8 @@ public: basic_string, void>; #endif -#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) + +#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const { if (__libcpp_is_constant_evaluated()) return __ptr; @@ -2018,7 +2019,7 @@ private: __annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const { (void)__old_mid; (void)__new_mid; -#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) # if defined(__APPLE__) // TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099) if (!__is_long()) @@ -2030,14 +2031,14 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_new(size_type __current_size) const _NOEXCEPT { (void)__current_size; -#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) if (!__libcpp_is_constant_evaluated()) __annotate_contiguous_container(data() + capacity() + 1, data() + __current_size + 1); #endif } _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_delete() const _NOEXCEPT { -#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) if (!__libcpp_is_constant_evaluated()) __annotate_contiguous_container(data() + size() + 1, data() + capacity() + 1); #endif @@ -2045,7 +2046,7 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_increase(size_type __n) const _NOEXCEPT { (void)__n; -#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) if (!__libcpp_is_constant_evaluated()) __annotate_contiguous_container(data() + size() + 1, data() + size() + 1 + __n); #endif @@ -2053,7 +2054,7 @@ private: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __annotate_shrink(size_type __old_size) const _NOEXCEPT { (void)__old_size; -#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) if (!__libcpp_is_constant_evaluated()) __annotate_contiguous_container(data() + __old_size + 1, data() + size() + 1); #endif @@ -2416,19 +2417,19 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator _ __rep_ = __rep(); __annotate_new(0); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (; __first != __last; ++__first) push_back(*__first); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __annotate_delete(); if (__is_long()) __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -2463,18 +2464,18 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir __set_long_size(__sz); } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__p)); traits_type::assign(*__end, value_type()); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { if (__is_long()) __alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap()); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __annotate_new(__sz); } @@ -3376,9 +3377,9 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target // Shrink // - called from shrink_to_fit should not throw. // - called from reserve may throw but is not required to. -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1); // The Standard mandates shrink_to_fit() does not increase the capacity. @@ -3391,11 +3392,11 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target } __new_data = __allocation.ptr; __target_capacity = __allocation.count - 1; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { return; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } __begin_lifetime(__new_data, __target_capacity + 1); __now_long = true; @@ -4234,7 +4235,7 @@ struct __string_hash : public __unary_function struct hash, _Allocator> > : __string_hash {}; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T template struct hash, _Allocator> > : __string_hash {}; #endif @@ -4308,7 +4309,7 @@ operator""s(const wchar_t* __str, size_t __len) { } # endif -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string operator""s(const char8_t* __str, size_t __len) { return basic_string(__str, __len); } diff --git a/libcxx/include/string_view b/libcxx/include/string_view index 3b32117386388..5beac404fb5b5 100644 --- a/libcxx/include/string_view +++ b/libcxx/include/string_view @@ -901,7 +901,7 @@ struct __string_view_hash : public __unary_function struct hash > > : __string_view_hash {}; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T template <> struct hash > > : __string_view_hash {}; #endif @@ -931,7 +931,7 @@ operator""sv(const wchar_t* __str, size_t __len) noexcept { } # endif -# ifndef _LIBCPP_HAS_NO_CHAR8_T +# if _LIBCPP_HAS_CHAR8_T inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string_view operator""sv(const char8_t* __str, size_t __len) noexcept { return basic_string_view(__str, __len); diff --git a/libcxx/include/syncstream b/libcxx/include/syncstream index a2e1c7edadc5d..72a5f6ca5c86c 100644 --- a/libcxx/include/syncstream +++ b/libcxx/include/syncstream @@ -273,14 +273,14 @@ public: } _LIBCPP_HIDE_FROM_ABI ~basic_syncbuf() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS emit(); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS __dec_reference(); } @@ -337,7 +337,7 @@ protected: return traits_type::not_eof(__c); if (this->pptr() == this->epptr()) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif size_t __size = __str_.size(); @@ -348,7 +348,7 @@ protected: this->setp(__p, __p + __str_.size()); this->pbump(__size); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { return traits_type::eof(); } @@ -480,13 +480,13 @@ public: // TODO validate other unformatted output functions. typename basic_ostream::sentry __s(*this); if (__s) { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { # endif if (__sb_.emit() == false) this->setstate(ios::badbit); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { this->__set_badbit_and_consider_rethrow(); } diff --git a/libcxx/include/typeinfo b/libcxx/include/typeinfo index a44fa4d73ee58..252afe59a0aa6 100644 --- a/libcxx/include/typeinfo +++ b/libcxx/include/typeinfo @@ -374,7 +374,7 @@ private: _LIBCPP_BEGIN_NAMESPACE_STD [[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_cast() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw bad_cast(); #else _LIBCPP_VERBOSE_ABORT("bad_cast was thrown in -fno-exceptions mode"); diff --git a/libcxx/include/valarray b/libcxx/include/valarray index 44341eb2ba6c1..b3b48958f92bd 100644 --- a/libcxx/include/valarray +++ b/libcxx/include/valarray @@ -1984,17 +1984,17 @@ template inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) { if (__n) { __begin_ = __end_ = allocator().allocate(__n); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) ::new ((void*)__end_) value_type(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2007,17 +2007,17 @@ template valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) { if (__n) { __begin_ = __end_ = allocator().allocate(__n); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (size_t __n_left = __n; __n_left; ++__end_, ++__p, --__n_left) ::new ((void*)__end_) value_type(*__p); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2025,17 +2025,17 @@ template valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) { if (__v.size()) { __begin_ = __end_ = allocator().allocate(__v.size()); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (value_type* __p = __v.__begin_; __p != __v.__end_; ++__end_, ++__p) ::new ((void*)__end_) value_type(*__p); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__v.size()); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2051,18 +2051,18 @@ valarray<_Tp>::valarray(initializer_list __il) : __begin_(nullptr), const size_t __n = __il.size(); if (__n) { __begin_ = __end_ = allocator().allocate(__n); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS try { -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS size_t __n_left = __n; for (const value_type* __p = __il.begin(); __n_left; ++__end_, ++__p, --__n_left) ::new ((void*)__end_) value_type(*__p); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__n); throw; } -# endif // _LIBCPP_HAS_NO_EXCEPTIONS +# endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2073,18 +2073,18 @@ valarray<_Tp>::valarray(const slice_array& __sa) : __begin_(nullptr) const size_t __n = __sa.__size_; if (__n) { __begin_ = __end_ = allocator().allocate(__n); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS size_t __n_left = __n; for (const value_type* __p = __sa.__vp_; __n_left; ++__end_, __p += __sa.__stride_, --__n_left) ::new ((void*)__end_) value_type(*__p); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2093,19 +2093,19 @@ valarray<_Tp>::valarray(const gslice_array& __ga) : __begin_(nullptr const size_t __n = __ga.__1d_.size(); if (__n) { __begin_ = __end_ = allocator().allocate(__n); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ga.__vp_; for (_Ip __i = __ga.__1d_.__begin_, __e = __ga.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new ((void*)__end_) value_type(__s[*__i]); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2114,19 +2114,19 @@ valarray<_Tp>::valarray(const mask_array& __ma) : __begin_(nullptr), const size_t __n = __ma.__1d_.size(); if (__n) { __begin_ = __end_ = allocator().allocate(__n); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ma.__vp_; for (_Ip __i = __ma.__1d_.__begin_, __e = __ma.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new ((void*)__end_) value_type(__s[*__i]); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2135,19 +2135,19 @@ valarray<_Tp>::valarray(const indirect_array& __ia) : __begin_(nullp const size_t __n = __ia.__1d_.size(); if (__n) { __begin_ = __end_ = allocator().allocate(__n); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS typedef const size_t* _Ip; const value_type* __s = __ia.__vp_; for (_Ip __i = __ia.__1d_.__begin_, __e = __ia.__1d_.__end_; __i != __e; ++__i, ++__end_) ::new ((void*)__end_) value_type(__s[*__i]); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2636,17 +2636,17 @@ void valarray<_Tp>::resize(size_t __n, value_type __x) { __clear(size()); if (__n) { __begin_ = __end_ = allocator().allocate(__n); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (size_t __n_left = __n; __n_left; --__n_left, ++__end_) ::new ((void*)__end_) value_type(__x); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { __clear(__n); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } diff --git a/libcxx/include/variant b/libcxx/include/variant index fd3aebaea0e14..2e158a4eea314 100644 --- a/libcxx/include/variant +++ b/libcxx/include/variant @@ -307,7 +307,7 @@ struct __farray { [[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void __throw_bad_variant_access() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_variant_access(); # else _LIBCPP_VERBOSE_ABORT("bad_variant_access was thrown in -fno-exceptions mode"); @@ -1062,7 +1062,7 @@ public: std::swap(__lhs, __rhs); } __impl __tmp(std::move(*__rhs)); -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS if constexpr (__all...>::value) { this->__generic_construct(*__rhs, std::move(*__lhs)); } else { @@ -1300,7 +1300,7 @@ public: __impl_.__swap(__that.__impl_); } -# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER) +# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER // Helper class to implement [variant.visit]/10 // Constraints: The call to visit does not use an explicit template-argument-list // that begins with a type template-argument. diff --git a/libcxx/include/vector b/libcxx/include/vector index 7d3aac5989a48..76de0ab0a81a0 100644 --- a/libcxx/include/vector +++ b/libcxx/include/vector @@ -917,27 +917,27 @@ private: _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_new(size_type __current_size) const _NOEXCEPT { (void)__current_size; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __annotate_contiguous_container(data() + capacity(), data() + __current_size); #endif } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_delete() const _NOEXCEPT { -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __annotate_contiguous_container(data() + size(), data() + capacity()); #endif } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_increase(size_type __n) const _NOEXCEPT { (void)__n; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __annotate_contiguous_container(data() + size(), data() + size() + __n); #endif } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI void __annotate_shrink(size_type __old_size) const _NOEXCEPT { (void)__old_size; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __annotate_contiguous_container(data() + __old_size, data() + size()); #endif } @@ -945,14 +945,14 @@ private: struct _ConstructTransaction { _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI explicit _ConstructTransaction(vector& __v, size_type __n) : __v_(__v), __pos_(__v.__end_), __new_end_(__v.__end_ + __n) { -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN __v_.__annotate_increase(__n); #endif } _LIBCPP_CONSTEXPR_SINCE_CXX20 _LIBCPP_HIDE_FROM_ABI ~_ConstructTransaction() { __v_.__end_ = __pos_; -#ifndef _LIBCPP_HAS_NO_ASAN +#if _LIBCPP_HAS_ASAN if (__pos_ != __new_end_) { __v_.__annotate_shrink(__new_end_ - __v_.__begin_); } @@ -1482,9 +1482,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __ template _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT { if (capacity() > size()) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS allocator_type& __a = this->__alloc(); __split_buffer __v(size(), size(), __a); // The Standard mandates shrink_to_fit() does not increase the capacity. @@ -1492,10 +1492,10 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::shrink_to_fit() _NOE // due to swapping the elements. if (__v.capacity() < capacity()) __swap_out_circular_buffer(__v); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -1733,21 +1733,21 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu } __split_buffer __v(__a); if (__first != __last) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __v.__construct_at_end_with_sentinel(std::move(__first), std::move(__last)); difference_type __old_size = __old_last - this->__begin_; difference_type __old_p = __p - this->__begin_; reserve(__recommend(size() + __v.size())); __p = this->__begin_ + __old_p; __old_last = this->__begin_ + __old_size; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { erase(__make_iter(__old_last), end()); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } __p = std::rotate(__p, __old_last, this->__end_); insert(__make_iter(__p), std::make_move_iterator(__v.begin()), std::make_move_iterator(__v.end())); @@ -2190,18 +2190,18 @@ private: template _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void __init_with_sentinel(_InputIterator __first, _Sentinel __last) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS for (; __first != __last; ++__first) push_back(*__first); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -2648,14 +2648,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector::reserve(size_type _ template _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector::shrink_to_fit() _NOEXCEPT { if (__external_cap_to_internal(size()) > __cap()) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS vector(*this, allocator_type(__alloc())).swap(*this); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } } @@ -2744,21 +2744,21 @@ vector::__insert_with_sentinel(const_iterator __position, _Inp } vector __v(get_allocator()); if (__first != __last) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __v.__assign_with_sentinel(std::move(__first), std::move(__last)); difference_type __old_size = static_cast(__old_end - begin()); difference_type __old_p = __p - begin(); reserve(__recommend(size() + __v.size())); __p = begin() + __old_p; __old_end = begin() + __old_size; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { erase(__old_end, end()); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } __p = std::rotate(__p, __old_end, end()); insert(__p, __v.begin(), __v.end()); diff --git a/libcxx/include/version b/libcxx/include/version index 88387e311636c..5ab4f28a04d88 100644 --- a/libcxx/include/version +++ b/libcxx/include/version @@ -384,7 +384,7 @@ __cpp_lib_void_t 201411L # define __cpp_lib_bit_cast 201806L # define __cpp_lib_bitops 201907L # define __cpp_lib_bounded_array_traits 201902L -# if !defined(_LIBCPP_HAS_NO_CHAR8_T) +# if _LIBCPP_HAS_CHAR8_T # define __cpp_lib_char8_t 201907L # endif # define __cpp_lib_concepts 202002L diff --git a/libcxx/modules/std.compat/cuchar.inc b/libcxx/modules/std.compat/cuchar.inc index d1a511cadef18..119a8511252bf 100644 --- a/libcxx/modules/std.compat/cuchar.inc +++ b/libcxx/modules/std.compat/cuchar.inc @@ -17,7 +17,7 @@ export { // size_t is conditionally here, but always present in cstddef.cppm. To avoid // conflicing declarations omit the using here. -#if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8) +#if _LIBCPP_HAS_C8RTOMB_MBRTOC8 using ::mbrtoc8 _LIBCPP_USING_IF_EXISTS; using ::c8rtomb _LIBCPP_USING_IF_EXISTS; #endif diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in index 0575774f6f42f..64ed8d4088cc0 100644 --- a/libcxx/modules/std.cppm.in +++ b/libcxx/modules/std.cppm.in @@ -20,7 +20,7 @@ module; #include #include #include -#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) +#if _LIBCPP_HAS_ATOMIC_HEADER # include #endif #include diff --git a/libcxx/modules/std/atomic.inc b/libcxx/modules/std/atomic.inc index e8cf90d012588..6ed0f7e9c4f32 100644 --- a/libcxx/modules/std/atomic.inc +++ b/libcxx/modules/std/atomic.inc @@ -60,7 +60,7 @@ export namespace std { using std::atomic_char _LIBCPP_USING_IF_EXISTS; using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS; using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS; #endif using std::atomic_int _LIBCPP_USING_IF_EXISTS; diff --git a/libcxx/modules/std/cuchar.inc b/libcxx/modules/std/cuchar.inc index fd80110d11ee8..4a0b21c17b7e1 100644 --- a/libcxx/modules/std/cuchar.inc +++ b/libcxx/modules/std/cuchar.inc @@ -17,7 +17,7 @@ export namespace std { // size_t is conditionally here, but always present in cstddef.cppm. To avoid // conflicing declarations omit the using here. -#if !defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8) +#if _LIBCPP_HAS_C8RTOMB_MBRTOC8 using std::mbrtoc8 _LIBCPP_USING_IF_EXISTS; using std::c8rtomb _LIBCPP_USING_IF_EXISTS; #endif diff --git a/libcxx/modules/std/iosfwd.inc b/libcxx/modules/std/iosfwd.inc index 090d990d061e5..952057d691fc4 100644 --- a/libcxx/modules/std/iosfwd.inc +++ b/libcxx/modules/std/iosfwd.inc @@ -14,7 +14,7 @@ export namespace std { #endif using std::u16streampos; using std::u32streampos; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T using std::u8streampos; #endif diff --git a/libcxx/modules/std/memory.inc b/libcxx/modules/std/memory.inc index c15f37a21239c..4c4cccfd7cf2f 100644 --- a/libcxx/modules/std/memory.inc +++ b/libcxx/modules/std/memory.inc @@ -154,9 +154,9 @@ export namespace std { using std::reinterpret_pointer_cast; using std::static_pointer_cast; -#ifndef _LIBCPP_HAS_NO_RTTI +#if _LIBCPP_HAS_RTTI using std::get_deleter; -#endif // _LIBCPP_HAS_NO_RTTI +#endif // _LIBCPP_HAS_RTTI // [util.smartptr.shared.io], shared_ptr I/O diff --git a/libcxx/modules/std/string.inc b/libcxx/modules/std/string.inc index 9808a96215a18..322317c98c018 100644 --- a/libcxx/modules/std/string.inc +++ b/libcxx/modules/std/string.inc @@ -34,7 +34,7 @@ export namespace std { using std::string; using std::u16string; using std::u32string; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T using std::u8string; #endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS @@ -60,7 +60,7 @@ export namespace std { using std::pmr::string; using std::pmr::u16string; using std::pmr::u32string; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T using std::pmr::u8string; #endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/modules/std/string_view.inc b/libcxx/modules/std/string_view.inc index f4f9d80ddb83d..1237f4516e7d0 100644 --- a/libcxx/modules/std/string_view.inc +++ b/libcxx/modules/std/string_view.inc @@ -27,7 +27,7 @@ export namespace std { using std::string_view; using std::u16string_view; using std::u32string_view; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T using std::u8string_view; #endif #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS diff --git a/libcxx/src/condition_variable_destructor.cpp b/libcxx/src/condition_variable_destructor.cpp index 59811ed7ff356..f6ffe33685990 100644 --- a/libcxx/src/condition_variable_destructor.cpp +++ b/libcxx/src/condition_variable_destructor.cpp @@ -14,7 +14,7 @@ #include <__config> #include <__thread/support.h> -#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION) +#if _LIBCPP_ABI_VERSION == 1 || !_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION # define NEEDS_CONDVAR_DESTRUCTOR #endif diff --git a/libcxx/src/filesystem/error.h b/libcxx/src/filesystem/error.h index 09020fbede9b9..07ba7fc3eef25 100644 --- a/libcxx/src/filesystem/error.h +++ b/libcxx/src/filesystem/error.h @@ -186,16 +186,16 @@ struct ErrorHandler { T report(const error_code& ec, const char* msg, ...) const { va_list ap; va_start(ap, msg); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS report_impl(ec, msg, ap); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { va_end(ap); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS va_end(ap); return error_value(); } @@ -206,16 +206,16 @@ struct ErrorHandler { T report(errc const& err, const char* msg, ...) const { va_list ap; va_start(ap, msg); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS report_impl(make_error_code(err), msg, ap); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { va_end(ap); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS va_end(ap); return error_value(); } diff --git a/libcxx/src/filesystem/format_string.h b/libcxx/src/filesystem/format_string.h index 81c5a95ae31e5..ad6c57579a0a6 100644 --- a/libcxx/src/filesystem/format_string.h +++ b/libcxx/src/filesystem/format_string.h @@ -56,16 +56,16 @@ inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 1, 2) string format_string(const cha string ret; va_list ap; va_start(ap, msg); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS ret = detail::vformat_string(msg, ap); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { va_end(ap); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS va_end(ap); return ret; } diff --git a/libcxx/src/filesystem/int128_builtins.cpp b/libcxx/src/filesystem/int128_builtins.cpp index 72b7cb4a8d1c0..da6f39e7d78b6 100644 --- a/libcxx/src/filesystem/int128_builtins.cpp +++ b/libcxx/src/filesystem/int128_builtins.cpp @@ -16,7 +16,7 @@ #include <__config> #include -#if !defined(_LIBCPP_HAS_NO_INT128) +#if _LIBCPP_HAS_INT128 extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t __muloti4(__int128_t a, __int128_t b, int* overflow) { diff --git a/libcxx/src/future.cpp b/libcxx/src/future.cpp index e2c14c8321ddd..04e6fb8db6459 100644 --- a/libcxx/src/future.cpp +++ b/libcxx/src/future.cpp @@ -142,10 +142,10 @@ promise::promise() : __state_(new __assoc_sub_state) {} promise::~promise() { if (__state_) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr(future_error(future_errc::broken_promise))); -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS __state_->__release_shared(); } } diff --git a/libcxx/src/ios.cpp b/libcxx/src/ios.cpp index a727855c4655e..74d33b4b2f1bc 100644 --- a/libcxx/src/ios.cpp +++ b/libcxx/src/ios.cpp @@ -361,18 +361,18 @@ void ios_base::swap(ios_base& rhs) noexcept { void ios_base::__set_badbit_and_consider_rethrow() { __rdstate_ |= badbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS if (__exceptions_ & badbit) throw; -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } void ios_base::__set_failbit_and_consider_rethrow() { __rdstate_ |= failbit; -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS if (__exceptions_ & failbit) throw; -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } bool ios_base::sync_with_stdio(bool sync) { diff --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp index 484963dcede9d..99a2d50f207ed 100644 --- a/libcxx/src/locale.cpp +++ b/libcxx/src/locale.cpp @@ -174,7 +174,7 @@ locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") { install(&make >(1u)); install(&make >(1u)); _LIBCPP_SUPPRESS_DEPRECATED_POP -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T install(&make >(1u)); install(&make >(1u)); #endif @@ -219,9 +219,9 @@ locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") { } locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), name_(name) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS facets_ = locale::classic().__locale_->facets_; for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) @@ -242,7 +242,7 @@ locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), install(new codecvt_byname(name_)); install(new codecvt_byname(name_)); _LIBCPP_SUPPRESS_DEPRECATED_POP -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T install(new codecvt_byname(name_)); install(new codecvt_byname(name_)); #endif @@ -268,14 +268,14 @@ locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS install(new messages_byname(name_)); #endif -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) facets_[i]->__release_shared(); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } locale::__imp::__imp(const __imp& other) : facets_(max(N, other.facets_.size())), name_(other.name_) { @@ -291,9 +291,9 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) facets_[i]->__add_shared(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS if (c & locale::collate) { install(new collate_byname(name)); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS @@ -313,7 +313,7 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) install(new codecvt_byname(name)); install(new codecvt_byname(name)); _LIBCPP_SUPPRESS_DEPRECATED_POP -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T install(new codecvt_byname(name)); install(new codecvt_byname(name)); #endif @@ -348,14 +348,14 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c) install(new messages_byname(name)); #endif } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) facets_[i]->__release_shared(); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } template @@ -370,9 +370,9 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) facets_[i]->__add_shared(); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS if (c & locale::collate) { install_from >(one); #ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS @@ -389,7 +389,7 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) install_from >(one); install_from >(one); _LIBCPP_SUPPRESS_DEPRECATED_POP -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T install_from >(one); install_from >(one); #endif @@ -443,14 +443,14 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c) install_from >(one); #endif } -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { for (unsigned i = 0; i < facets_.size(); ++i) if (facets_[i]) facets_[i]->__release_shared(); throw; } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } locale::__imp::__imp(const __imp& other, facet* f, long id) @@ -2815,7 +2815,7 @@ int codecvt::do_length( int codecvt::do_max_length() const noexcept { return 4; } -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T // template <> class codecvt @@ -2949,7 +2949,7 @@ int codecvt::do_length( int codecvt::do_max_length() const noexcept { return 4; } -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T // template <> class codecvt @@ -5707,7 +5707,7 @@ template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_ codecvt_byname; template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname; -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname; template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname; #endif diff --git a/libcxx/src/memory_resource.cpp b/libcxx/src/memory_resource.cpp index d2ff3509c5a31..299f810948fd1 100644 --- a/libcxx/src/memory_resource.cpp +++ b/libcxx/src/memory_resource.cpp @@ -9,7 +9,7 @@ #include #include -#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER +#if _LIBCPP_HAS_ATOMIC_HEADER # include #elif !defined(_LIBCPP_HAS_NO_THREADS) # include @@ -28,7 +28,7 @@ memory_resource::~memory_resource() = default; // new_delete_resource() -#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#if !_LIBCPP_HAS_ALIGNED_ALLOCATION static bool is_aligned_to(void* ptr, size_t align) { void* p2 = ptr; size_t space = 1; @@ -39,7 +39,7 @@ static bool is_aligned_to(void* ptr, size_t align) { class _LIBCPP_EXPORTED_FROM_ABI __new_delete_memory_resource_imp : public memory_resource { void* do_allocate(size_t bytes, size_t align) override { -#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#if _LIBCPP_HAS_ALIGNED_ALLOCATION return std::__libcpp_allocate(bytes, align); #else if (bytes == 0) @@ -91,7 +91,7 @@ memory_resource* null_memory_resource() noexcept { return &res_init.resources.nu // default_memory_resource() static memory_resource* __default_memory_resource(bool set = false, memory_resource* new_res = nullptr) noexcept { -#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER +#if _LIBCPP_HAS_ATOMIC_HEADER static constinit atomic __res{&res_init.resources.new_delete_res}; if (set) { new_res = new_res ? new_res : new_delete_resource(); diff --git a/libcxx/src/mutex_destructor.cpp b/libcxx/src/mutex_destructor.cpp index a6ceaaaf23ffe..9f991721f083f 100644 --- a/libcxx/src/mutex_destructor.cpp +++ b/libcxx/src/mutex_destructor.cpp @@ -19,7 +19,7 @@ #include <__config> #include <__thread/support.h> -#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION) +#if _LIBCPP_ABI_VERSION == 1 || !_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION # define NEEDS_MUTEX_DESTRUCTOR #endif diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp index b0c731678cac3..e010fe4c4f191 100644 --- a/libcxx/src/new.cpp +++ b/libcxx/src/new.cpp @@ -51,7 +51,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std } _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { -# ifdef _LIBCPP_HAS_NO_EXCEPTIONS +# if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( !std::__is_function_overridden(static_cast(&operator new)), @@ -79,7 +79,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](s } _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { -# ifdef _LIBCPP_HAS_NO_EXCEPTIONS +# if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( !std::__is_function_overridden(static_cast(&operator new[])), @@ -114,7 +114,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept { _LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); } -# if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) +# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) { if (size == 0) @@ -145,7 +145,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { } _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { -# ifdef _LIBCPP_HAS_NO_EXCEPTIONS +# if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( !std::__is_function_overridden(static_cast(&operator new)), @@ -174,7 +174,7 @@ operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { } _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { -# ifdef _LIBCPP_HAS_NO_EXCEPTIONS +# if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( !std::__is_function_overridden(static_cast(&operator new[])), @@ -220,7 +220,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignmen ::operator delete[](ptr, alignment); } -# endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +# endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION // ------------------ END COPY ------------------ #endif // !__GLIBCXX__ && !_LIBCPP_ABI_VCRUNTIME diff --git a/libcxx/src/new_helpers.cpp b/libcxx/src/new_helpers.cpp index 6560d0188ee32..2119d82b3e00f 100644 --- a/libcxx/src/new_helpers.cpp +++ b/libcxx/src/new_helpers.cpp @@ -18,7 +18,7 @@ const nothrow_t nothrow{}; #ifndef LIBSTDCXX void __throw_bad_alloc() { -# ifndef _LIBCPP_HAS_NO_EXCEPTIONS +# if _LIBCPP_HAS_EXCEPTIONS throw bad_alloc(); # else _LIBCPP_VERBOSE_ABORT("bad_alloc was thrown in -fno-exceptions mode"); diff --git a/libcxx/src/ostream.cpp b/libcxx/src/ostream.cpp index e1a9a4bc1de71..f036aaf29dfb2 100644 --- a/libcxx/src/ostream.cpp +++ b/libcxx/src/ostream.cpp @@ -24,7 +24,7 @@ _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) { // Returning a nullptr means the stream is not considered a terminal and the // special terminal handling is not done. The terminal handling is mainly of // importance on Windows. -#ifndef _LIBCPP_HAS_NO_RTTI +#if _LIBCPP_HAS_RTTI auto* __rdbuf = __os.rdbuf(); # ifndef _LIBCPP_HAS_NO_FILESYSTEM if (auto* __buffer = dynamic_cast(__rdbuf)) @@ -33,7 +33,7 @@ _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) { if (auto* __buffer = dynamic_cast<__stdoutbuf*>(__rdbuf)) return __buffer->__file_; -#endif // _LIBCPP_HAS_NO_RTTI +#endif // _LIBCPP_HAS_RTTI return nullptr; } diff --git a/libcxx/src/ryu/d2s.cpp b/libcxx/src/ryu/d2s.cpp index 32d617cb55324..5b80ed8a709d8 100644 --- a/libcxx/src/ryu/d2s.cpp +++ b/libcxx/src/ryu/d2s.cpp @@ -478,7 +478,7 @@ struct __floating_decimal_64 { 36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u }; unsigned long _Trailing_zero_bits; -#ifdef _LIBCPP_HAS_BITSCAN64 +#if _LIBCPP_HAS_BITSCAN64 (void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero #else // ^^^ 64-bit ^^^ / vvv 32-bit vvv const uint32_t _Low_mantissa = static_cast(__v.__mantissa); diff --git a/libcxx/src/stdexcept.cpp b/libcxx/src/stdexcept.cpp index 134d28efb750f..0ee438bef02e1 100644 --- a/libcxx/src/stdexcept.cpp +++ b/libcxx/src/stdexcept.cpp @@ -20,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD void __throw_runtime_error(const char* msg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw runtime_error(msg); #else _LIBCPP_VERBOSE_ABORT("runtime_error was thrown in -fno-exceptions mode with message \"%s\"", msg); diff --git a/libcxx/src/support/runtime/exception_fallback.ipp b/libcxx/src/support/runtime/exception_fallback.ipp index bedb16e58566b..ba283aee22901 100644 --- a/libcxx/src/support/runtime/exception_fallback.ipp +++ b/libcxx/src/support/runtime/exception_fallback.ipp @@ -34,18 +34,18 @@ terminate_handler set_terminate(terminate_handler func) noexcept { terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); } [[noreturn]] void terminate() noexcept { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS (*get_terminate())(); // handler should not return __libcpp_verbose_abort("terminate_handler unexpectedly returned\n"); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { // handler should not throw exception __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n"); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } diff --git a/libcxx/src/support/runtime/exception_msvc.ipp b/libcxx/src/support/runtime/exception_msvc.ipp index 869b64d2f533e..2ae004bb02e5d 100644 --- a/libcxx/src/support/runtime/exception_msvc.ipp +++ b/libcxx/src/support/runtime/exception_msvc.ipp @@ -42,18 +42,18 @@ terminate_handler set_terminate(terminate_handler func) noexcept { return ::set_ terminate_handler get_terminate() noexcept { return ::_get_terminate(); } [[noreturn]] void terminate() noexcept { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS (*get_terminate())(); // handler should not return __libcpp_verbose_abort("terminate_handler unexpectedly returned\n"); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { // handler should not throw exception __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n"); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp index 3367bd56bd788..476729310d868 100644 --- a/libcxx/src/system_error.cpp +++ b/libcxx/src/system_error.cpp @@ -211,7 +211,7 @@ system_error::system_error(int ev, const error_category& ecat) system_error::~system_error() noexcept {} void __throw_system_error(int ev, const char* what_arg) { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS std::__throw_system_error(error_code(ev, system_category()), what_arg); #else // The above could also handle the no-exception case, but for size, avoid referencing system_category() unnecessarily. diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp index 55b5929847748..563580b687955 100644 --- a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp +++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_integer.compile.pass.cpp @@ -30,7 +30,7 @@ static_assert(std::__libcpp_integer); static_assert(std::__libcpp_integer); static_assert(std::__libcpp_integer); static_assert(std::__libcpp_integer); -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 static_assert(std::__libcpp_integer<__uint128_t>); #endif // Signed @@ -40,7 +40,7 @@ static_assert(std::__libcpp_integer); static_assert(std::__libcpp_integer); static_assert(std::__libcpp_integer); static_assert(std::__libcpp_integer); -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 static_assert(std::__libcpp_integer<__int128_t>); #endif // Non-integer diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp index 5bf7aa526f0a2..d1e21ee96b073 100644 --- a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp +++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_signed_integer.compile.pass.cpp @@ -30,7 +30,7 @@ static_assert(!std::__libcpp_signed_integer); static_assert(!std::__libcpp_signed_integer); static_assert(!std::__libcpp_signed_integer); static_assert(!std::__libcpp_signed_integer); -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 static_assert(!std::__libcpp_signed_integer<__uint128_t>); #endif // Signed @@ -40,7 +40,7 @@ static_assert(std::__libcpp_signed_integer); static_assert(std::__libcpp_signed_integer); static_assert(std::__libcpp_signed_integer); static_assert(std::__libcpp_signed_integer); -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 static_assert(std::__libcpp_signed_integer<__int128_t>); #endif // Non-integer diff --git a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp index 163ec53e17bc1..c671f03cbfce4 100644 --- a/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp +++ b/libcxx/test/libcxx/concepts/concepts.arithmetic/__libcpp_unsigned_integer.compile.pass.cpp @@ -30,7 +30,7 @@ static_assert(std::__libcpp_unsigned_integer); static_assert(std::__libcpp_unsigned_integer); static_assert(std::__libcpp_unsigned_integer); static_assert(std::__libcpp_unsigned_integer); -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 static_assert(std::__libcpp_unsigned_integer<__uint128_t>); #endif // Signed @@ -40,7 +40,7 @@ static_assert(!std::__libcpp_unsigned_integer); static_assert(!std::__libcpp_unsigned_integer); static_assert(!std::__libcpp_unsigned_integer); static_assert(!std::__libcpp_unsigned_integer); -#ifndef _LIBCPP_HAS_NO_INT128 +#if _LIBCPP_HAS_INT128 static_assert(!std::__libcpp_unsigned_integer<__int128_t>); #endif // Non-integer diff --git a/libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp index 578afaabbd26d..505618c0b88d7 100644 --- a/libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp +++ b/libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp @@ -21,12 +21,12 @@ void test() { ::operator new(0, std::nothrow); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} ::operator new[](0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} ::operator new[](0, std::nothrow); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} -#ifndef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#if _LIBCPP_HAS_ALIGNED_ALLOCATION ::operator new(0, std::align_val_t{1}); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} ::operator new(0, std::align_val_t{1}, std::nothrow); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} ::operator new[](0, std::align_val_t{1}); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} ::operator new[](0, std::align_val_t{1}, std::nothrow); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} -#endif // _LIBCPP_HAS_NO_ALIGNED_ALLOCATION +#endif // _LIBCPP_HAS_ALIGNED_ALLOCATION #if TEST_STD_VER >= 17 int* ptr = nullptr; diff --git a/libcxx/test/libcxx/memory/aligned_allocation_macro.compile.pass.cpp b/libcxx/test/libcxx/memory/aligned_allocation_macro.compile.pass.cpp index 34a3146e26c95..6249c52814781 100644 --- a/libcxx/test/libcxx/memory/aligned_allocation_macro.compile.pass.cpp +++ b/libcxx/test/libcxx/memory/aligned_allocation_macro.compile.pass.cpp @@ -12,7 +12,6 @@ #include "test_macros.h" - -#ifdef _LIBCPP_HAS_NO_ALIGNED_ALLOCATION -# error "libc++ should have aligned allocation in C++17 and up when targeting a platform that supports it" +#if !_LIBCPP_HAS_ALIGNED_ALLOCATION +# error "libc++ should have aligned allocation in C++17 and up when targeting a platform that supports it" #endif diff --git a/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp b/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp index 64d2c54e7dd84..8bd82bacc5d1f 100644 --- a/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp +++ b/libcxx/test/libcxx/type_traits/is_trivially_relocatable.compile.pass.cpp @@ -79,7 +79,7 @@ static_assert(!std::__libcpp_is_trivially_relocatable, 1> >::value, ""); // basic_string -#if defined(_LIBCPP_HAS_NO_ASAN) || !defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) +#if !_LIBCPP_HAS_ASAN || !defined(_LIBCPP_INSTRUMENTED_WITH_ASAN) struct MyChar { char c; }; diff --git a/libcxx/test/libcxx/utilities/expected/expected.expected/value.observers.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/value.observers.verify.cpp index 00ba267a4fde0..d2b62a9b6ab99 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.expected/value.observers.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.expected/value.observers.verify.cpp @@ -121,7 +121,7 @@ void test() { } } // These diagnostics happen when we try to construct bad_expected_access from the non copy-constructible error type. -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS // expected-error-re@*:* {{call to deleted constructor of{{.*}}}} // expected-error-re@*:* {{call to deleted constructor of{{.*}}}} // expected-error-re@*:* {{call to deleted constructor of{{.*}}}} diff --git a/libcxx/test/std/atomics/stdatomic.h.syn/types.compile.pass.cpp b/libcxx/test/std/atomics/stdatomic.h.syn/types.compile.pass.cpp index 85d9337987835..50bc157157c5c 100644 --- a/libcxx/test/std/atomics/stdatomic.h.syn/types.compile.pass.cpp +++ b/libcxx/test/std/atomics/stdatomic.h.syn/types.compile.pass.cpp @@ -168,7 +168,7 @@ void f() { static_assert(std::is_same_v, ::atomic_llong>); static_assert(std::is_same_v, ::atomic_ullong>); -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T static_assert(std::is_same_v, ::atomic_char8_t>); #endif static_assert(std::is_same_v, ::atomic_char16_t>); diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/alg.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/alg.pass.cpp index 159cb19f65468..772c3c563087e 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/alg.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/alg.pass.cpp @@ -82,7 +82,7 @@ int main(int, char**) assert(e4() < 0x7fffffffu); assert(e4() < 0x7fffffffu); -#ifndef _LIBCPP_HAS_NO_INT128 +#ifndef TEST_HAS_NO_INT128 // m might overflow. The overflow is not OK, result will be in bounds, // and Schrage's algorithm is incompatible here. Need to use 128 bit arithmetic. typedef std::linear_congruential_engine E5; diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp index a85c63d26ead6..423f4d021ac64 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/default.pass.cpp @@ -84,7 +84,7 @@ int main(int, char**) test_ext(); test(); // This isn't implemented on platforms without __int128 -#ifndef _LIBCPP_HAS_NO_INT128 +#ifndef TEST_HAS_NO_INT128 test_ext(); #endif diff --git a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp index 66b4e6ab4d6a8..f238c12cff1eb 100644 --- a/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/values.pass.cpp @@ -117,7 +117,7 @@ int main(int, char**) test_ext(); test(); // This isn't implemented on platforms without __int128 -#ifndef _LIBCPP_HAS_NO_INT128 +#ifndef TEST_HAS_NO_INT128 test_ext(); #endif diff --git a/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp b/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp index bc058d400f749..1d4a225668d80 100644 --- a/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp +++ b/libcxx/test/std/strings/c.strings/no_c8rtomb_mbrtoc8.verify.cpp @@ -19,7 +19,7 @@ #if !defined(TEST_HAS_NO_CHAR8_T) using U = decltype(::c8rtomb); using V = decltype(::mbrtoc8); -# if defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8) +# if !_LIBCPP_HAS_C8RTOMB_MBRTOC8 // expected-error@-3 {{no member named 'c8rtomb' in the global namespace}} // expected-error@-3 {{no member named 'mbrtoc8' in the global namespace}} # else diff --git a/libcxx/test/support/test.support/make_string_header.pass.cpp b/libcxx/test/support/test.support/make_string_header.pass.cpp index 8fcc05ec49d7c..45aaa2cfef207 100644 --- a/libcxx/test/support/test.support/make_string_header.pass.cpp +++ b/libcxx/test/support/test.support/make_string_header.pass.cpp @@ -31,7 +31,7 @@ int main(int, char**) { == L" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN" "OPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"); #endif -#ifndef _LIBCPP_HAS_NO_CHAR8_T +#if _LIBCPP_HAS_CHAR8_T assert(MAKE_STRING(char8_t, " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMN" "OPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~") diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h index ae171b3f223ab..5dcd775e8641e 100644 --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -214,10 +214,10 @@ #define TEST_IS_EXECUTED_IN_A_SLOW_ENVIRONMENT #endif -#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \ - (!(TEST_STD_VER > 14 || \ - (defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606L))) -#define TEST_HAS_NO_ALIGNED_ALLOCATION +#if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_ALIGNED_ALLOCATION +# define TEST_HAS_NO_ALIGNED_ALLOCATION +#elif TEST_STD_VER < 17 && (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606L) +# define TEST_HAS_NO_ALIGNED_ALLOCATION #endif #if TEST_STD_VER > 17 @@ -397,12 +397,12 @@ inline Tp const& DoNotOptimize(Tp const& value) { # define TEST_HAS_NO_UNICODE #endif -#if defined(_LIBCPP_HAS_OPEN_WITH_WCHAR) +#if defined(_LIBCPP_VERSION) && _LIBCPP_HAS_OPEN_WITH_WCHAR # define TEST_HAS_OPEN_WITH_WCHAR #endif -#if defined(_LIBCPP_HAS_NO_INT128) || defined(_MSVC_STL_VERSION) -# define TEST_HAS_NO_INT128 +#if (defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_INT128) || defined(_MSVC_STL_VERSION) +# define TEST_HAS_NO_INT128 #endif #if defined(_LIBCPP_HAS_NO_LOCALIZATION) @@ -421,7 +421,7 @@ inline Tp const& DoNotOptimize(Tp const& value) { # define TEST_HAS_NO_FILESYSTEM #endif -#if defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8) +#if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_C8RTOMB_MBRTOC8 # define TEST_HAS_NO_C8RTOMB_MBRTOC8 #endif @@ -495,7 +495,7 @@ inline Tp const& DoNotOptimize(Tp const& value) { #endif // Clang-18 has support for deducing this, but it does not set the FTM. -#ifdef _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER +#if defined(_LIBCPP_VERSION) && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER # define TEST_HAS_EXPLICIT_THIS_PARAMETER #endif diff --git a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt index 0e1d3506a9973..efe63e0f625f2 100644 --- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt +++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt @@ -94,6 +94,7 @@ set(SOURCES abi_tag_on_virtual.cpp header_exportable_declarations.cpp hide_from_abi.cpp + internal_ftm_use.cpp proper_version_checks.cpp qualify_declval.cpp robust_against_adl.cpp diff --git a/libcxx/test/tools/clang_tidy_checks/internal_ftm_use.cpp b/libcxx/test/tools/clang_tidy_checks/internal_ftm_use.cpp new file mode 100644 index 0000000000000..b5e849e2a0cb9 --- /dev/null +++ b/libcxx/test/tools/clang_tidy_checks/internal_ftm_use.cpp @@ -0,0 +1,109 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// This clang-tidy check ensures that we don't use any _LIBCPP_HAS_FOO macro +// inside `#ifdef`, `#ifndef` & friends, since the intent is to always use `#if` instead. + +#include "internal_ftm_use.hpp" + +#include +#include +#include + +#include + +namespace libcpp { +namespace { +std::array valid_macros{ + // Public API macros + "_LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS", + + // Testing macros + "_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER", + + // TODO: Why does this macro even exist? + "_LIBCPP_HAS_NO_TREE_BARRIER", + + // Configuration macros + "_LIBCPP_HAS_NO_TIME_ZONE_DATABASE", + "_LIBCPP_HAS_NO_FILESYSTEM", + "_LIBCPP_HAS_NO_LOCALIZATION", + "_LIBCPP_HAS_NO_THREADS", + "_LIBCPP_HAS_NO_MONOTONIC_CLOCK", + "_LIBCPP_HAS_MUSL_LIBC", + "_LIBCPP_HAS_NO_WIDE_CHARACTERS", + "_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS", + "_LIBCPP_HAS_NO_RANDOM_DEVICE", + "_LIBCPP_HAS_NO_UNICODE", + "_LIBCPP_HAS_NO_TERMINAL", + + // Atomic API macros + "_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP", + "_LIBCPP_HAS_GCC_ATOMIC_IMP", + "_LIBCPP_HAS_C_ATOMIC_IMP", + + // Thread API macros + "_LIBCPP_HAS_THREAD_API_PTHREAD", + "_LIBCPP_HAS_THREAD_API_WIN32", + "_LIBCPP_HAS_THREAD_API_EXTERNAL", + "_LIBCPP_HAS_THREAD_API_C11", + + // Experimental features + "_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB", + "_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM", + "_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN", + "_LIBCPP_HAS_NO_INCOMPLETE_PSTL", +}; + +class internal_ftm_use_callbacks : public clang::PPCallbacks { +public: + internal_ftm_use_callbacks(clang::tidy::ClangTidyCheck& check) : check_(check) {} + + void Defined(const clang::Token& token, + const clang::MacroDefinition& macro_definition, + clang::SourceRange location) override { + check_macro(token.getIdentifierInfo()->getName(), location.getBegin()); + } + + void Ifdef(clang::SourceLocation location, const clang::Token& token, const clang::MacroDefinition&) override { + check_macro(token.getIdentifierInfo()->getName(), location); + } + + void Elifdef(clang::SourceLocation location, const clang::Token& token, const clang::MacroDefinition&) override { + check_macro(token.getIdentifierInfo()->getName(), location); + } + + void Ifndef(clang::SourceLocation location, const clang::Token& token, const clang::MacroDefinition&) override { + check_macro(token.getIdentifierInfo()->getName(), location); + } + + void Elifndef(clang::SourceLocation location, const clang::Token& token, const clang::MacroDefinition&) override { + check_macro(token.getIdentifierInfo()->getName(), location); + } + +private: + void check_macro(std::string_view macro, clang::SourceLocation location) { + if (macro.starts_with("_LIBCPP_HAS_") && std::ranges::find(valid_macros, macro) == valid_macros.end()) { + check_.diag(location, std::string("\'") + std::string{macro} + "' is always defined to 1 or 0."); + } + } + + clang::tidy::ClangTidyCheck& check_; +}; +} // namespace + +internal_ftm_use::internal_ftm_use(llvm::StringRef name, clang::tidy::ClangTidyContext* context) + : clang::tidy::ClangTidyCheck(name, context) {} + +void internal_ftm_use::registerPPCallbacks(const clang::SourceManager& source_manager, + clang::Preprocessor* preprocessor, + clang::Preprocessor* module_expander) { + preprocessor->addPPCallbacks(std::make_unique(*this)); +} + +} // namespace libcpp diff --git a/libcxx/test/tools/clang_tidy_checks/internal_ftm_use.hpp b/libcxx/test/tools/clang_tidy_checks/internal_ftm_use.hpp new file mode 100644 index 0000000000000..90c5448f6b38e --- /dev/null +++ b/libcxx/test/tools/clang_tidy_checks/internal_ftm_use.hpp @@ -0,0 +1,19 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "clang-tidy/ClangTidyCheck.h" + +namespace libcpp { +class internal_ftm_use : public clang::tidy::ClangTidyCheck { +public: + internal_ftm_use(llvm::StringRef, clang::tidy::ClangTidyContext*); + void registerPPCallbacks(const clang::SourceManager& source_manager, + clang::Preprocessor* preprocessor, + clang::Preprocessor* module_expander) override; +}; +} // namespace libcpp diff --git a/libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp b/libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp index 16acf32ae55b3..54beed5e30be5 100644 --- a/libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp +++ b/libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp @@ -12,6 +12,7 @@ #include "abi_tag_on_virtual.hpp" #include "header_exportable_declarations.hpp" #include "hide_from_abi.hpp" +#include "internal_ftm_use.hpp" #include "proper_version_checks.hpp" #include "qualify_declval.hpp" #include "robust_against_adl.hpp" @@ -24,6 +25,7 @@ class LibcxxTestModule : public clang::tidy::ClangTidyModule { check_factories.registerCheck("libcpp-avoid-abi-tag-on-virtual"); check_factories.registerCheck("libcpp-header-exportable-declarations"); check_factories.registerCheck("libcpp-hide-from-abi"); + check_factories.registerCheck("libcpp-internal-ftms"); check_factories.registerCheck("libcpp-cpp-version-check"); check_factories.registerCheck("libcpp-robust-against-adl"); check_factories.registerCheck("libcpp-uglify-attributes"); diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py index db14c1781dc35..7ab1af93d1774 100755 --- a/libcxx/utils/generate_feature_test_macro_components.py +++ b/libcxx/utils/generate_feature_test_macro_components.py @@ -280,7 +280,7 @@ def add_version_header(tc): "string_view", ], "test_suite_guard": "defined(__cpp_char8_t)", - "libcxx_guard": "!defined(_LIBCPP_HAS_NO_CHAR8_T)", + "libcxx_guard": "_LIBCPP_HAS_CHAR8_T", }, { "name": "__cpp_lib_chrono", diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py index fd48b35a88b55..6bebf3302ffae 100644 --- a/libcxx/utils/libcxx/header_information.py +++ b/libcxx/utils/libcxx/header_information.py @@ -10,8 +10,8 @@ header_restrictions = { # headers with #error directives - "atomic": "!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)", - "stdatomic.h": "!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)", + "atomic": "_LIBCPP_HAS_ATOMIC_HEADER", + "stdatomic.h": "_LIBCPP_HAS_ATOMIC_HEADER", # headers with #error directives "ios": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)", diff --git a/libcxxabi/src/fallback_malloc.cpp b/libcxxabi/src/fallback_malloc.cpp index 76bd2e9bcd9f7..75788fe9be8d9 100644 --- a/libcxxabi/src/fallback_malloc.cpp +++ b/libcxxabi/src/fallback_malloc.cpp @@ -259,7 +259,7 @@ void* __aligned_malloc_with_fallback(size_t size) { #if defined(_WIN32) if (void* dest = std::__libcpp_aligned_alloc(alignof(__aligned_type), size)) return dest; -#elif defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) +#elif !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION if (void* dest = ::malloc(size)) return dest; #else @@ -286,7 +286,7 @@ void __aligned_free_with_fallback(void* ptr) { if (is_fallback_ptr(ptr)) fallback_free(ptr); else { -#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) +#if !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION ::free(ptr); #else std::__libcpp_aligned_free(ptr); diff --git a/libcxxabi/src/stdlib_new_delete.cpp b/libcxxabi/src/stdlib_new_delete.cpp index bd576e6aeed74..f386b28f0cfe6 100644 --- a/libcxxabi/src/stdlib_new_delete.cpp +++ b/libcxxabi/src/stdlib_new_delete.cpp @@ -24,12 +24,12 @@ # error The _LIBCPP_WEAK macro should be already defined by libc++ #endif -#if defined(_LIBCXXABI_NO_EXCEPTIONS) != defined(_LIBCPP_HAS_NO_EXCEPTIONS) +#if defined(_LIBCXXABI_NO_EXCEPTIONS) != !_LIBCPP_HAS_EXCEPTIONS # error libc++ and libc++abi seem to disagree on whether exceptions are enabled #endif inline void __throw_bad_alloc_shim() { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS throw std::bad_alloc(); #else __abort_message("bad_alloc was thrown in -fno-exceptions mode"); @@ -71,7 +71,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new(std } _LIBCPP_WEAK void* operator new(size_t size, const std::nothrow_t&) noexcept { -#ifdef _LIBCPP_HAS_NO_EXCEPTIONS +#if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( !std::__is_function_overridden(static_cast(&operator new)), @@ -99,7 +99,7 @@ _LIBCPP_MAKE_OVERRIDABLE_FUNCTION_DETECTABLE _LIBCPP_WEAK void* operator new[](s } _LIBCPP_WEAK void* operator new[](size_t size, const std::nothrow_t&) noexcept { -#ifdef _LIBCPP_HAS_NO_EXCEPTIONS +#if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( !std::__is_function_overridden(static_cast(&operator new[])), @@ -134,7 +134,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept { _LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); } -#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) +#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) { if (size == 0) @@ -165,7 +165,7 @@ operator new(std::size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { } _LIBCPP_WEAK void* operator new(size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { -# ifdef _LIBCPP_HAS_NO_EXCEPTIONS +# if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( !std::__is_function_overridden(static_cast(&operator new)), @@ -194,7 +194,7 @@ operator new[](size_t size, std::align_val_t alignment) _THROW_BAD_ALLOC { } _LIBCPP_WEAK void* operator new[](size_t size, std::align_val_t alignment, const std::nothrow_t&) noexcept { -# ifdef _LIBCPP_HAS_NO_EXCEPTIONS +# if !_LIBCPP_HAS_EXCEPTIONS # if _LIBCPP_CAN_DETECT_OVERRIDDEN_FUNCTION _LIBCPP_ASSERT_SHIM( !std::__is_function_overridden(static_cast(&operator new[])), @@ -240,5 +240,5 @@ _LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignmen ::operator delete[](ptr, alignment); } -#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION +#endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION // ------------------ END COPY ------------------