[libcxx-commits] [libcxx] [libcxxabi] [libc++][RFC] Always define internal feature test macros (PR #89178)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 11 00:31:43 PDT 2024
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/89178
>From d2c09d2b887f316cd7f64c1ef025ffb7a20b8be6 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 18 Apr 2024 08:50:42 +0200
Subject: [PATCH] [libc++][RFC] Always define internal feature test macros
---
libcxx/include/__atomic/aliases.h | 2 +-
libcxx/include/__atomic/atomic_lock_free.h | 4 +-
libcxx/include/__bit/byteswap.h | 4 +-
libcxx/include/__bit/countl.h | 4 +-
libcxx/include/__charconv/tables.h | 2 +-
libcxx/include/__charconv/to_chars_base_10.h | 2 +-
libcxx/include/__charconv/to_chars_integral.h | 2 +-
libcxx/include/__charconv/traits.h | 2 +-
libcxx/include/__chrono/exception.h | 4 +-
libcxx/include/__chrono/file_clock.h | 2 +-
.../__condition_variable/condition_variable.h | 8 +-
libcxx/include/__config | 110 +++++++----
libcxx/include/__configuration/availability.h | 8 +-
libcxx/include/__configuration/language.h | 12 +-
libcxx/include/__debug_utils/sanitizers.h | 10 +-
libcxx/include/__exception/exception_ptr.h | 2 +-
libcxx/include/__exception/nested_exception.h | 4 +-
libcxx/include/__expected/expected.h | 2 +-
.../include/__filesystem/filesystem_error.h | 2 +-
libcxx/include/__filesystem/path.h | 12 +-
libcxx/include/__filesystem/u8path.h | 6 +-
libcxx/include/__format/format_arg.h | 30 +--
libcxx/include/__format/format_arg_store.h | 4 +-
libcxx/include/__format/format_context.h | 4 +-
libcxx/include/__format/format_error.h | 2 +-
libcxx/include/__format/format_functions.h | 4 +-
libcxx/include/__format/formatter_integer.h | 8 +-
libcxx/include/__functional/function.h | 50 ++---
libcxx/include/__functional/hash.h | 6 +-
libcxx/include/__fwd/string.h | 10 +-
libcxx/include/__fwd/string_view.h | 4 +-
libcxx/include/__hash_table | 24 +--
libcxx/include/__iterator/counted_iterator.h | 4 +-
libcxx/include/__locale | 6 +-
libcxx/include/__memory/addressof.h | 2 +-
libcxx/include/__memory/aligned_alloc.h | 6 +-
libcxx/include/__memory/shared_ptr.h | 64 ++++---
libcxx/include/__memory/temporary_buffer.h | 2 +-
.../__memory/uninitialized_algorithms.h | 42 ++---
libcxx/include/__mutex/mutex.h | 2 +-
libcxx/include/__ostream/basic_ostream.h | 178 +++++++++---------
libcxx/include/__ostream/print.h | 16 +-
libcxx/include/__pstl/backends/libdispatch.h | 4 +-
libcxx/include/__random/is_valid.h | 4 +-
.../__random/linear_congruential_engine.h | 4 +-
libcxx/include/__random/log2.h | 8 +-
libcxx/include/__split_buffer | 8 +-
libcxx/include/__std_clang_module | 4 +-
libcxx/include/__string/char_traits.h | 4 +-
.../include/__string/constexpr_c_functions.h | 2 +-
libcxx/include/__system_error/system_error.h | 2 +-
libcxx/include/__type_traits/is_integral.h | 4 +-
libcxx/include/__type_traits/is_pointer.h | 2 +-
libcxx/include/__type_traits/is_scalar.h | 2 +-
.../include/__type_traits/is_signed_integer.h | 2 +-
.../__type_traits/is_unsigned_integer.h | 2 +-
.../__type_traits/make_32_64_or_128_bit.h | 2 +-
libcxx/include/__type_traits/make_signed.h | 6 +-
libcxx/include/__type_traits/make_unsigned.h | 6 +-
libcxx/include/__type_traits/promote.h | 2 +-
.../include/__utility/convert_to_integral.h | 2 +-
libcxx/include/__utility/exception_guard.h | 4 +-
libcxx/include/any | 12 +-
libcxx/include/atomic | 2 +-
libcxx/include/cuchar | 2 +-
libcxx/include/deque | 42 ++---
libcxx/include/experimental/__simd/utility.h | 2 +-
libcxx/include/forward_list | 16 +-
libcxx/include/fstream | 52 ++---
libcxx/include/future | 70 +++----
libcxx/include/iomanip | 32 ++--
libcxx/include/ios | 4 +-
libcxx/include/iosfwd | 2 +-
libcxx/include/istream | 154 +++++++--------
libcxx/include/list | 32 ++--
libcxx/include/locale | 8 +-
libcxx/include/new | 40 ++--
libcxx/include/optional | 2 +-
libcxx/include/regex | 2 +-
libcxx/include/sstream | 8 +-
libcxx/include/stdexcept | 16 +-
libcxx/include/string | 45 ++---
libcxx/include/string_view | 4 +-
libcxx/include/syncstream | 16 +-
libcxx/include/typeinfo | 2 +-
libcxx/include/valarray | 72 +++----
libcxx/include/variant | 6 +-
libcxx/include/vector | 52 ++---
libcxx/include/version | 2 +-
libcxx/modules/std.compat/cuchar.inc | 2 +-
libcxx/modules/std.cppm.in | 2 +-
libcxx/modules/std/cuchar.inc | 2 +-
libcxx/modules/std/iosfwd.inc | 2 +-
libcxx/modules/std/memory.inc | 4 +-
libcxx/modules/std/string.inc | 4 +-
libcxx/modules/std/string_view.inc | 2 +-
libcxx/src/filesystem/error.h | 16 +-
libcxx/src/filesystem/format_string.h | 8 +-
libcxx/src/filesystem/int128_builtins.cpp | 2 +-
libcxx/src/future.cpp | 4 +-
libcxx/src/ios.cpp | 8 +-
libcxx/src/locale.cpp | 38 ++--
libcxx/src/memory_resource.cpp | 8 +-
libcxx/src/new.cpp | 12 +-
libcxx/src/new_helpers.cpp | 2 +-
libcxx/src/ostream.cpp | 4 +-
libcxx/src/stdexcept.cpp | 2 +-
.../support/runtime/exception_fallback.ipp | 8 +-
libcxx/src/support/runtime/exception_msvc.ipp | 8 +-
libcxx/src/system_error.cpp | 2 +-
.../__libcpp_integer.compile.pass.cpp | 4 +-
.../__libcpp_signed_integer.compile.pass.cpp | 4 +-
...__libcpp_unsigned_integer.compile.pass.cpp | 4 +-
.../diagnostics/new.nodiscard.verify.cpp | 4 +-
.../aligned_allocation_macro.compile.pass.cpp | 5 +-
.../value.observers.verify.cpp | 2 +-
.../stdatomic.h.syn/types.compile.pass.cpp | 2 +-
.../rand/rand.eng/rand.eng.lcong/alg.pass.cpp | 2 +-
.../rand.eng/rand.eng.lcong/default.pass.cpp | 2 +-
.../rand.eng/rand.eng.lcong/values.pass.cpp | 2 +-
.../c.strings/no_c8rtomb_mbrtoc8.verify.cpp | 2 +-
.../test.support/make_string_header.pass.cpp | 2 +-
libcxx/test/support/test_macros.h | 13 +-
.../tools/clang_tidy_checks/CMakeLists.txt | 1 +
.../clang_tidy_checks/internal_ftm_use.cpp | 104 ++++++++++
.../clang_tidy_checks/internal_ftm_use.hpp | 19 ++
.../tools/clang_tidy_checks/libcpp_module.cpp | 2 +
.../generate_feature_test_macro_components.py | 2 +-
libcxx/utils/libcxx/header_information.py | 4 +-
libcxxabi/src/stdlib_new_delete.cpp | 12 +-
130 files changed, 975 insertions(+), 800 deletions(-)
create mode 100644 libcxx/test/tools/clang_tidy_checks/internal_ftm_use.cpp
create mode 100644 libcxx/test/tools/clang_tidy_checks/internal_ftm_use.hpp
diff --git a/libcxx/include/__atomic/aliases.h b/libcxx/include/__atomic/aliases.h
index e27e09af6b77d9..afc64eaaa69e7b 100644
--- a/libcxx/include/__atomic/aliases.h
+++ b/libcxx/include/__atomic/aliases.h
@@ -37,7 +37,7 @@ using atomic_long = atomic<long>;
using atomic_ulong = atomic<unsigned long>;
using atomic_llong = atomic<long long>;
using atomic_ullong = atomic<unsigned long long>;
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
using atomic_char8_t = atomic<char8_t>;
#endif
using atomic_char16_t = atomic<char16_t>;
diff --git a/libcxx/include/__atomic/atomic_lock_free.h b/libcxx/include/__atomic/atomic_lock_free.h
index 0715439db45039..3ae9b8856e8102 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 6225ecf2f92dfb..d761e6a6fdb46e 100644
--- a/libcxx/include/__bit/byteswap.h
+++ b/libcxx/include/__bit/byteswap.h
@@ -32,7 +32,7 @@ template <integral _Tp>
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 <integral _Tp>
return static_cast<_Tp>(byteswap(static_cast<uint64_t>(__val))) << 64 |
static_cast<_Tp>(byteswap(static_cast<uint64_t>(__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 998a0b44c19dcb..8727df208cb3fa 100644
--- a/libcxx/include/__bit/countl.h
+++ b/libcxx/include/__bit/countl.h
@@ -39,7 +39,7 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_cl
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<unsigned long long>(__x >> 64));
# endif
}
-#endif // _LIBCPP_HAS_NO_INT128
+#endif // _LIBCPP_HAS_INT128
template <class _Tp>
_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 6b93536b8c1bac..9568bf841cd029 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 c49f4f6797aa43..06e4e692337df5 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 ccb5856df17993..fd92be4b4ce91e 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 c91c6da3247978..2cb37c8cfb0238 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<sizeof(_Tp) == sizeof(uin
}
};
-# ifndef _LIBCPP_HAS_NO_INT128
+# if _LIBCPP_HAS_INT128
template <typename _Tp>
struct _LIBCPP_HIDDEN __traits_base<_Tp, __enable_if_t<sizeof(_Tp) == sizeof(__uint128_t)> > {
using type = __uint128_t;
diff --git a/libcxx/include/__chrono/exception.h b/libcxx/include/__chrono/exception.h
index cc408d78a36da6..64484fb551b77d 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 <class _Duration>
[[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 <class _Duration>
[[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 4dd3f88ce5ba4b..b4b7e9dc14e70c 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 de35aaca1070eb..61412541b4b51a 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<mutex>& __lk, chrono::time_point<chrono::system_clock, chrono::nanoseconds>) _NOEXCEPT;
-# if defined(_LIBCPP_HAS_COND_CLOCKWAIT)
+# if _LIBCPP_HAS_COND_CLOCKWAIT
_LIBCPP_HIDE_FROM_ABI void
__do_timed_wait(unique_lock<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds>) _NOEXCEPT;
# endif
@@ -180,7 +180,7 @@ cv_status condition_variable::wait_for(unique_lock<mutex>& __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<steady_clock, nanoseconds>;
__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<mutex>& __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<mutex>& __lk, chrono::time_point<chrono::steady_clock, chrono::nanoseconds> __tp) _NOEXCEPT {
using namespace chrono;
diff --git a/libcxx/include/__config b/libcxx/include/__config
index b0a5dda147a6ae..e3eb09ceb85b3b 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -246,7 +246,9 @@ _LIBCPP_HARDENING_MODE_DEBUG
# if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || defined(__arm__))
# define _LIBCPP_HAS_BITSCAN64
# endif
-# define _LIBCPP_HAS_OPEN_WITH_WCHAR
+# define _LIBCPP_HAS_OPEN_WITH_WCHAR 1
+# else
+# define _LIBCPP_HAS_OPEN_WITH_WCHAR 0
# endif // defined(_WIN32)
# if defined(_AIX) && !defined(__64BIT__)
@@ -315,13 +317,14 @@ _LIBCPP_HARDENING_MODE_DEBUG
# define _NOEXCEPT noexcept
# define _NOEXCEPT_(...) noexcept(__VA_ARGS__)
# define _LIBCPP_CONSTEXPR constexpr
+# define _LIBCPP_HAS_NOEXCEPT 1
# else
# define _LIBCPP_ALIGNOF(_Tp) _Alignof(_Tp)
# define _ALIGNAS_TYPE(x) __attribute__((__aligned__(_LIBCPP_ALIGNOF(x))))
# define _ALIGNAS(x) __attribute__((__aligned__(x)))
-# define _LIBCPP_HAS_NO_NOEXCEPT
+# define _LIBCPP_HAS_NOEXCEPT 0
# define nullptr __nullptr
# define _NOEXCEPT throw()
# define _NOEXCEPT_(...)
@@ -338,7 +341,9 @@ 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)
@@ -346,15 +351,21 @@ typedef __char32_t char32_t;
# 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__))
@@ -477,7 +488,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
@@ -608,7 +619,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
@@ -640,17 +653,21 @@ 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
@@ -658,11 +675,15 @@ typedef __char32_t char32_t;
# 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
+# 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__)
@@ -674,7 +695,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.
@@ -733,7 +756,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
@@ -827,13 +850,14 @@ typedef __char32_t char32_t;
# endif // _LIBCPP_HAS_NO_THREADS
# if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
-# if defined(__ANDROID__) && __ANDROID_API__ >= 30
-# define _LIBCPP_HAS_COND_CLOCKWAIT
-# elif defined(_LIBCPP_GLIBC_PREREQ)
-# if _LIBCPP_GLIBC_PREREQ(2, 30)
-# define _LIBCPP_HAS_COND_CLOCKWAIT
-# endif
+# if (defined(__ANDROID__) && __ANDROID_API__ >= 30) || \
+ (defined(_LIBCPP_GLIBC_PREREQ) && _LIBCPP_GLIBC_PREREQ(2, 30))
+# define _LIBCPP_HAS_COND_CLOCKWAIT 1
+# 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)
@@ -870,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.
@@ -882,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__) || \
@@ -898,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
@@ -911,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)
@@ -1004,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
@@ -1012,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
@@ -1204,7 +1236,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 ab483a07c9c137..9956e7d846615f 100644
--- a/libcxx/include/__configuration/availability.h
+++ b/libcxx/include/__configuration/availability.h
@@ -375,10 +375,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
@@ -389,8 +389,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 fa62a7b6f5c2a1..9c224dfa76e407 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 d8547e32493303..73d192711eabb6 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 9e5351f534a1c1..2cb250dfd42da7 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 <class _Ep>
_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 8e817e1c069788..cc20b038c871ba 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 <class _Tp, class _Up, bool>
struct __throw_with_nested;
@@ -68,7 +68,7 @@ struct __throw_with_nested<_Tp, _Up, false> {
template <class _Tp>
[[__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 8661d5d6e9b939..81a1c11a1adc41 100644
--- a/libcxx/include/__expected/expected.h
+++ b/libcxx/include/__expected/expected.h
@@ -71,7 +71,7 @@ struct __expected_construct_unexpected_from_invoke_tag {};
template <class _Err, class _Arg>
_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 f43568c2004d21..73592bba31da0a 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 <class... _Args>
[[__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 eef1fc0db3ea72..5cfd7248cd475f 100644
--- a/libcxx/include/__filesystem/path.h
+++ b/libcxx/include/__filesystem/path.h
@@ -60,7 +60,7 @@ struct __can_convert_char<wchar_t> {
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<char8_t> {
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<char16_t> {
}
};
-# ifndef _LIBCPP_HAS_NO_CHAR8_T
+# if _LIBCPP_HAS_CHAR8_T
template <>
struct _PathExport<char8_t> {
typedef __narrow_to_utf8<sizeof(wchar_t) * __CHAR_BIT__> _Narrower;
@@ -376,7 +376,7 @@ struct _PathExport<char8_t> {
_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 dae5823128f028..e13980298d9e99 100644
--- a/libcxx/include/__filesystem/u8path.h
+++ b/libcxx/include/__filesystem/u8path.h
@@ -34,7 +34,7 @@ _LIBCPP_AVAILABILITY_FILESYSTEM_LIBRARY_PUSH
template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::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<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
# endif
is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
@@ -56,7 +56,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f,
template <class _InputIt, __enable_if_t<__is_pathable<_InputIt>::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<typename __is_pathable<_InputIt>::__char_type, char8_t>::value ||
# endif
is_same<typename __is_pathable<_InputIt>::__char_type, char>::value,
@@ -77,7 +77,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DEPRECATED_WITH_CHAR8_T path u8path(_InputIt __f,
template <class _Source, __enable_if_t<__is_pathable<_Source>::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<typename __is_pathable<_Source>::__char_type, char8_t>::value ||
# endif
is_same<typename __is_pathable<_Source>::__char_type, char>::value,
diff --git a/libcxx/include/__format/format_arg.h b/libcxx/include/__format/format_arg.h
index d1ce055874413e..3f39d2aec81f75 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 <class _Rp, class _Visitor, class _Context>
_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 <class _Visitor>
_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 <class _Rp, class _Visitor>
_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 <class _Visitor, class _Context>
-# 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 00de1c30b8733b..15a7be96278a1c 100644
--- a/libcxx/include/__format/format_arg_store.h
+++ b/libcxx/include/__format/format_arg_store.h
@@ -63,7 +63,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
@@ -78,7 +78,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 a9be17b855837d..019a71011a7140 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<typename __format::__retarget_bu
__format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
__basic_format_arg_value<basic_format_context>(__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 1df7dbff2b7df2..b92e6d1de00e26 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 1518ab5768d243..b3cda8bf844918 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 b7f46014c57231..3f51b10d75aaca 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<long, _CharT> : public __formatter_integer<_CharT> {};
template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS formatter<long long, _CharT> : 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<unsigned long, _CharT> : public __formatter_integer<_CharT> {};
template <__fmt_char_type _CharT>
struct _LIBCPP_TEMPLATE_VIS formatter<unsigned long long, _CharT> : 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<long> = true;
template <>
inline constexpr bool enable_nonlocking_formatter_optimization<long long> = 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<unsigned long> = true;
template <>
inline constexpr bool enable_nonlocking_formatter_optimization<unsigned long long> = 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 ff31011caa329d..e40445947dbb00 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 <class _Rp, class... _Args>
_LIBCPP_HIDE_FROM_ABI bool __not_null(_Rp (^__p)(_Args...)) {
return __p;
@@ -243,10 +243,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.
@@ -272,10 +272,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 <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
@@ -313,7 +313,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 <class _Fp, class _Alloc, class _Rp, class... _ArgTypes>
const void* __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT {
@@ -327,7 +327,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.
@@ -464,7 +464,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);
@@ -477,7 +477,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
@@ -520,7 +520,7 @@ struct __policy {
nullptr,
nullptr,
true,
-# ifndef _LIBCPP_HAS_NO_RTTI
+# if _LIBCPP_HAS_RTTI
&typeid(void)
# else
nullptr
@@ -547,7 +547,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
@@ -562,7 +562,7 @@ struct __policy {
nullptr,
nullptr,
false,
-# ifndef _LIBCPP_HAS_NO_RTTI
+# if _LIBCPP_HAS_RTTI
&typeid(typename _Fun::_Target)
# else
nullptr
@@ -724,7 +724,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 <typename _Tp>
@@ -736,10 +736,10 @@ class __policy_func<_Rp(_ArgTypes...)> {
else
return reinterpret_cast<const _Tp*>(&__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*);
@@ -751,7 +751,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))
@@ -762,7 +762,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))
@@ -784,7 +784,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
@@ -803,7 +803,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_;
@@ -813,7 +813,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
@@ -905,14 +905,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 <typename _Tp>
_LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT;
template <typename _Tp>
_LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT;
-# endif // _LIBCPP_HAS_NO_RTTI
+# endif // _LIBCPP_HAS_RTTI
};
# if _LIBCPP_STD_VER >= 17
@@ -989,7 +989,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 <class _Rp, class... _ArgTypes>
const std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT {
@@ -1008,7 +1008,7 @@ const _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT {
return __f_.template target<_Tp>();
}
-# endif // _LIBCPP_HAS_NO_RTTI
+# endif // _LIBCPP_HAS_RTTI
template <class _Rp, class... _ArgTypes>
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 a9e450edd39f53..c347e8e0df95ab 100644
--- a/libcxx/include/__functional/hash.h
+++ b/libcxx/include/__functional/hash.h
@@ -355,12 +355,12 @@ struct _LIBCPP_TEMPLATE_VIS hash<unsigned char> : public __unary_function<unsign
_LIBCPP_HIDE_FROM_ABI size_t operator()(unsigned char __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
};
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char8_t> : public __unary_function<char8_t, size_t> {
_LIBCPP_HIDE_FROM_ABI size_t operator()(char8_t __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
};
-#endif // !_LIBCPP_HAS_NO_CHAR8_T
+#endif // _LIBCPP_HAS_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char16_t> : public __unary_function<char16_t, size_t> {
@@ -415,7 +415,7 @@ struct _LIBCPP_TEMPLATE_VIS hash<long long> : public __scalar_hash<long long> {}
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long> : public __scalar_hash<unsigned long long> {};
-#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 2418e1f9b23d0d..f13a3594022e8b 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<char>;
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
template <>
struct char_traits<char8_t>;
#endif
@@ -48,7 +48,7 @@ using string = basic_string<char>;
using wstring = basic_string<wchar_t>;
#endif
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
using u8string = basic_string<char8_t>;
#endif
@@ -67,7 +67,7 @@ using string _LIBCPP_AVAILABILITY_PMR = basic_string<char>;
using wstring _LIBCPP_AVAILABILITY_PMR = basic_string<wchar_t>;
# endif
-# ifndef _LIBCPP_HAS_NO_CHAR8_T
+# if _LIBCPP_HAS_CHAR8_T
using u8string _LIBCPP_AVAILABILITY_PMR = basic_string<char8_t>;
# 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 72a64be5b00b54..e1acd874256110 100644
--- a/libcxx/include/__fwd/string_view.h
+++ b/libcxx/include/__fwd/string_view.h
@@ -23,7 +23,7 @@ template <class _CharT, class _Traits = char_traits<_CharT> >
class _LIBCPP_TEMPLATE_VIS basic_string_view;
typedef basic_string_view<char> string_view;
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
typedef basic_string_view<char8_t> u8string_view;
#endif
typedef basic_string_view<char16_t> 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 d5fbc92a3dfc4e..fee47d281035f9 100644
--- a/libcxx/include/__hash_table
+++ b/libcxx/include/__hash_table
@@ -1186,9 +1186,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());
@@ -1196,12 +1196,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();
@@ -1232,21 +1232,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)
@@ -1264,21 +1264,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 a02c61bf34e2f9..b3c10e70bfca3e 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 4b382764b44645..5fb0c19903cd5b 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<char16_t, char8_t, mbstate_t> // 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<char32_t, char8_t, mbstate_t> // C++20
@@ -1255,7 +1255,7 @@ extern template class _LIBCPP_DEPRECATED_IN_CXX20
_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>; // deprecated in C++20
extern template class _LIBCPP_DEPRECATED_IN_CXX20
_LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>; // 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<char16_t, char8_t, mbstate_t>; // C++20
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char8_t, mbstate_t>; // C++20
#endif
diff --git a/libcxx/include/__memory/addressof.h b/libcxx/include/__memory/addressof.h
index fa590212c49b96..cc570da847daad 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
diff --git a/libcxx/include/__memory/aligned_alloc.h b/libcxx/include/__memory/aligned_alloc.h
index cb424328bcafc1..33fe8af77df7b5 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 5dcd475e2c9f9d..34dc024606d200 100644
--- a/libcxx/include/__memory/shared_ptr.h
+++ b/libcxx/include/__memory/shared_ptr.h
@@ -54,7 +54,7 @@
#include <cstddef>
#include <new>
#include <typeinfo>
-#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 <class _ValueType>
@@ -98,7 +100,7 @@ inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_acquire_load(_ValueType const*
template <class _Tp>
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 <class _Tp>
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)
: __data_(__compressed_pair<_Tp, _Dp>(__p, std::move(__d)), 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 <class _Tp, class _Dp, class _Alloc>
const void* __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__get_deleter(const type_info& __t) const _NOEXCEPT {
return __t == typeid(_Dp) ? std::addressof(__data_.first().second()) : nullptr;
}
-#endif // _LIBCPP_HAS_NO_RTTI
+#endif // _LIBCPP_HAS_RTTI
template <class _Tp, class _Dp, class _Alloc>
void __shared_ptr_pointer<_Tp, _Dp, _Alloc>::__on_zero_shared() _NOEXCEPT {
@@ -461,9 +463,9 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr {
template <class _Yp, class _Dp, __enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::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
@@ -472,12 +474,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 <class _Yp,
@@ -485,9 +487,9 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr {
class _Alloc,
__enable_if_t<__shared_ptr_deleter_ctor_reqs<_Dp, _Yp, _Tp>::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;
@@ -501,12 +503,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 <class _Dp>
@@ -515,9 +517,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<nullptr_t, _Dp, _AllocT> _CntrlBlk;
#ifndef _LIBCPP_CXX03_LANG
@@ -525,12 +527,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 <class _Dp, class _Alloc>
@@ -540,9 +542,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<nullptr_t, _Dp, _Alloc> _CntrlBlk;
typedef typename __allocator_traits_rebind<_Alloc, _CntrlBlk>::type _A2;
typedef __allocator_destructor<_A2> _D2;
@@ -555,12 +557,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 <class _Yp>
@@ -773,12 +775,12 @@ class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS shared_ptr {
}
#endif
-#ifndef _LIBCPP_HAS_NO_RTTI
+#if _LIBCPP_HAS_RTTI
template <class _Dp>
_LIBCPP_HIDE_FROM_ABI _Dp* __get_deleter() const _NOEXCEPT {
return static_cast<_Dp*>(__cntrl_ ? const_cast<void*>(__cntrl_->__get_deleter(typeid(_Dp))) : nullptr);
}
-#endif // _LIBCPP_HAS_NO_RTTI
+#endif // _LIBCPP_HAS_RTTI
template <class _Yp, class _CntrlBlk>
_LIBCPP_HIDE_FROM_ABI static shared_ptr<_Tp> __create_with_control_block(_Yp* __p, _CntrlBlk* __cntrl) _NOEXCEPT {
@@ -1303,14 +1305,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 <class _Dp, class _Tp>
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 _Tp>
class _LIBCPP_SHARED_PTR_TRIVIAL_ABI _LIBCPP_TEMPLATE_VIS weak_ptr {
diff --git a/libcxx/include/__memory/temporary_buffer.h b/libcxx/include/__memory/temporary_buffer.h
index 88799ca95c1f35..ae1117f748313e 100644
--- a/libcxx/include/__memory/temporary_buffer.h
+++ b/libcxx/include/__memory/temporary_buffer.h
@@ -30,7 +30,7 @@ get_temporary_buffer(ptrdiff_t __n) _NOEXCEPT {
if (__n > __m)
__n = __m;
while (__n > 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));
__r.first = static_cast<_Tp*>(::operator new(__n * sizeof(_Tp), __al, nothrow));
diff --git a/libcxx/include/__memory/uninitialized_algorithms.h b/libcxx/include/__memory/uninitialized_algorithms.h
index 8ff87e28b3bb51..0c50a39ce07803 100644
--- a/libcxx/include/__memory/uninitialized_algorithms.h
+++ b/libcxx/include/__memory/uninitialized_algorithms.h
@@ -60,12 +60,12 @@ template <class _ValueType, class _InputIterator, class _Sentinel1, class _Forwa
inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __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 (std::__voidify(*__idx)) _ValueType(*__ifirst);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__ofirst, __idx);
throw;
@@ -90,12 +90,12 @@ template <class _ValueType, class _InputIterator, class _Size, class _ForwardIte
inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator>
__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 (std::__voidify(*__idx)) _ValueType(*__ifirst);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__ofirst, __idx);
throw;
@@ -120,12 +120,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel, class _Tp>
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 (std::__voidify(*__idx)) _ValueType(__x);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
@@ -148,12 +148,12 @@ template <class _ValueType, class _ForwardIterator, class _Size, class _Tp>
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 (std::__voidify(*__idx)) _ValueType(__x);
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
@@ -178,12 +178,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel>
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 (std::__voidify(*__idx)) _ValueType;
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
@@ -204,12 +204,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_default_construct(_ForwardIterat
template <class _ValueType, class _ForwardIterator, class _Size>
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 (std::__voidify(*__idx)) _ValueType;
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
@@ -231,12 +231,12 @@ template <class _ValueType, class _ForwardIterator, class _Sentinel>
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 (std::__voidify(*__idx)) _ValueType();
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
@@ -257,12 +257,12 @@ inline _LIBCPP_HIDE_FROM_ABI void uninitialized_value_construct(_ForwardIterator
template <class _ValueType, class _ForwardIterator, class _Size>
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 (std::__voidify(*__idx)) _ValueType();
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__first, __idx);
throw;
@@ -293,13 +293,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 (std::__voidify(*__idx)) _ValueType(__iter_move(__ifirst));
}
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__ofirst, __idx);
throw;
@@ -331,12 +331,12 @@ template <class _ValueType,
inline _LIBCPP_HIDE_FROM_ABI pair<_InputIterator, _ForwardIterator> __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 (std::__voidify(*__idx)) _ValueType(__iter_move(__ifirst));
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
std::__destroy(__ofirst, __idx);
throw;
@@ -628,7 +628,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/__mutex/mutex.h b/libcxx/include/__mutex/mutex.h
index 1ed01547126f48..9c0c9ad6b5997e 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 e0698ccb4842a5..61083050f48b68 100644
--- a/libcxx/include/__ostream/basic_ostream.h
+++ b/libcxx/include/__ostream/basic_ostream.h
@@ -153,15 +153,15 @@ basic_ostream<_CharT, _Traits>::sentry::sentry(basic_ostream<_CharT, _Traits>& _
template <class _CharT, class _Traits>
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
}
}
@@ -182,15 +182,15 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() {}
template <class _CharT, class _Traits>
basic_ostream<_CharT, _Traits>&
basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_type>* __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);
@@ -204,27 +204,27 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_streambuf<char_type, traits_typ
}
if (__c == 0)
this->setstate(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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -232,19 +232,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 <class _CharT, class _Traits>
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;
@@ -259,19 +259,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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -279,19 +279,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig
if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__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 <class _CharT, class _Traits>
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;
@@ -306,19 +306,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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -326,19 +326,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(unsig
if (__f.put(*this, *this, this->fill(), static_cast<unsigned long>(__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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -346,19 +346,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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -366,19 +366,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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -386,19 +386,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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -406,19 +406,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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -426,19 +426,19 @@ basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(float
if (__f.put(*this, *this, this->fill(), static_cast<double>(__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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -446,19 +446,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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -466,19 +466,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 <class _CharT, class _Traits>
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<char_type, ostreambuf_iterator<char_type, traits_type> > _Fp;
@@ -486,20 +486,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 <class _CharT, class _Traits>
_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;
@@ -513,11 +513,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;
}
@@ -528,9 +528,9 @@ _LIBCPP_HIDE_FROM_ABI basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_
template <class _CharT, class _Traits>
_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);
@@ -545,11 +545,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;
}
@@ -577,9 +577,9 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str) {
template <class _CharT, class _Traits>
_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;
@@ -606,11 +606,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;
}
@@ -635,9 +635,9 @@ operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str) {
template <class _CharT, class _Traits>
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;
@@ -646,37 +646,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 <class _CharT, class _Traits>
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 <class _CharT, class _Traits>
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) {
@@ -684,11 +684,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;
}
@@ -820,7 +820,7 @@ basic_ostream<wchar_t, _Traits>& operator<<(basic_ostream<wchar_t, _Traits>&, co
# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-# ifndef _LIBCPP_HAS_NO_CHAR8_T
+# if _LIBCPP_HAS_CHAR8_T
template <class _Traits>
basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>&, char8_t) = delete;
diff --git a/libcxx/include/__ostream/print.h b/libcxx/include/__ostream/print.h
index 8265ac00777e25..3bbc0841073498 100644
--- a/libcxx/include/__ostream/print.h
+++ b/libcxx/include/__ostream/print.h
@@ -49,9 +49,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<char> _Ip;
if (std::__pad_and_output(
_Ip(__os),
@@ -63,11 +63,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
}
}
@@ -112,9 +112,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
@@ -126,11 +126,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 a0c3ad980ed1b0..854c1b9cd25695 100644
--- a/libcxx/include/__pstl/backends/libdispatch.h
+++ b/libcxx/include/__pstl/backends/libdispatch.h
@@ -140,11 +140,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 a3e0f143ae86a7..f6679b3fdc427b 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<unsigned long> : true_type {};
template <>
struct __libcpp_random_is_valid_inttype<unsigned long long> : 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 9d77649e9cfc8e..a0afda4945cdcf 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 <unsigned long long _Ap, unsigned long long _Cp, unsigned long long _Mp>
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 74b4889c6402b5..c96a5247ff6dbe 100644
--- a/libcxx/include/__random/log2.h
+++ b/libcxx/include/__random/log2.h
@@ -38,7 +38,7 @@ struct __log2_imp<unsigned long long, 0, _Rp> {
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<unsigned long long, _Xp, 63>::value;
};
-#endif // _LIBCPP_HAS_NO_INT128
+#endif // _LIBCPP_HAS_INT128
template <class _UIntType, _UIntType _Xp>
struct __log2 {
static const size_t value = __log2_imp<
-#ifndef _LIBCPP_HAS_NO_INT128
+#if _LIBCPP_HAS_INT128
__conditional_t<sizeof(_UIntType) <= sizeof(unsigned long long), unsigned long long, __uint128_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 bab724d1b8963b..50a7929fae6754 100644
--- a/libcxx/include/__split_buffer
+++ b/libcxx/include/__split_buffer
@@ -443,9 +443,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void __split_buffer<_Tp, _Allocator>::reserve(size
template <class _Tp, class _Allocator>
_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<value_type, __alloc_rr&> __t(size(), 0, __alloc());
__t.__construct_at_end(move_iterator<pointer>(__begin_), move_iterator<pointer>(__end_));
__t.__end_ = __t.__begin_ + (__end_ - __begin_);
@@ -453,10 +453,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/__std_clang_module b/libcxx/include/__std_clang_module
index 18d6ce6b46c1f6..4039c5e211a23f 100644
--- a/libcxx/include/__std_clang_module
+++ b/libcxx/include/__std_clang_module
@@ -30,7 +30,7 @@
#include <algorithm>
#include <any>
#include <array>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+#if _LIBCPP_HAS_ATOMIC_HEADER
# include <atomic>
#endif
#if !defined(_LIBCPP_HAS_NO_THREADS)
@@ -166,7 +166,7 @@
# include <sstream>
#endif
#include <stack>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+#if _LIBCPP_HAS_ATOMIC_HEADER
# include <stdatomic.h>
#endif
#include <stdbool.h>
diff --git a/libcxx/include/__string/char_traits.h b/libcxx/include/__string/char_traits.h
index 2660ac2ede2d5c..c2a993105b4cd6 100644
--- a/libcxx/include/__string/char_traits.h
+++ b/libcxx/include/__string/char_traits.h
@@ -256,7 +256,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<wchar_t> : __char_traits_base<wchar_t, w
};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
@@ -276,7 +276,7 @@ struct _LIBCPP_TEMPLATE_VIS char_traits<char8_t>
}
};
-#endif // _LIBCPP_HAS_NO_CHAR8_T
+#endif // _LIBCPP_HAS_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS char_traits<char16_t>
diff --git a/libcxx/include/__string/constexpr_c_functions.h b/libcxx/include/__string/constexpr_c_functions.h
index 9b8871e2e71a38..e62a7b0cd1b3bb 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<char> = true;
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
template <>
inline const bool __is_char_type<char8_t> = true;
#endif
diff --git a/libcxx/include/__system_error/system_error.h b/libcxx/include/__system_error/system_error.h
index 3ffa1029ca5c2e..2763aaba88f5fa 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 26969885af8dfd..61178720a5938c 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<unsigned char> { enum { va
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <> struct __libcpp_is_integral<wchar_t> { enum { value = 1 }; };
#endif
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
template <> struct __libcpp_is_integral<char8_t> { enum { value = 1 }; };
#endif
template <> struct __libcpp_is_integral<char16_t> { enum { value = 1 }; };
@@ -41,7 +41,7 @@ template <> struct __libcpp_is_integral<long> { enum { va
template <> struct __libcpp_is_integral<unsigned long> { enum { value = 1 }; };
template <> struct __libcpp_is_integral<long long> { enum { value = 1 }; };
template <> struct __libcpp_is_integral<unsigned long long> { 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 38eb7996c68642..9701e57807cf6f 100644
--- a/libcxx/include/__type_traits/is_pointer.h
+++ b/libcxx/include/__type_traits/is_pointer.h
@@ -40,7 +40,7 @@ template <class _Tp>
struct __libcpp_remove_objc_qualifiers {
typedef _Tp type;
};
-# if defined(_LIBCPP_HAS_OBJC_ARC)
+# if _LIBCPP_HAS_OBJC_ARC
// clang-format off
template <class _Tp> struct __libcpp_remove_objc_qualifiers<_Tp __strong> { typedef _Tp type; };
template <class _Tp> 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 455200de472089..242023a6877c94 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 <class _Tp>
struct __is_block : false_type {};
-# if defined(_LIBCPP_HAS_EXTENSION_BLOCKS)
+# if _LIBCPP_HAS_EXTENSION_BLOCKS
template <class _Rp, class... _Args>
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 467548d0aaafbd..a3e19a66f2c74a 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<signed short> : publi
template <> struct __libcpp_is_signed_integer<signed int> : public true_type {};
template <> struct __libcpp_is_signed_integer<signed long> : public true_type {};
template <> struct __libcpp_is_signed_integer<signed long long> : 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 265894b32d4fc1..86e42a1e8156aa 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<unsigned short> : p
template <> struct __libcpp_is_unsigned_integer<unsigned int> : public true_type {};
template <> struct __libcpp_is_unsigned_integer<unsigned long> : public true_type {};
template <> struct __libcpp_is_unsigned_integer<unsigned long long> : 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 f7f2e81735dafd..70f84fcd18686c 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<sizeof(_Tp) <= sizeof(int32_t), int32_t,
__conditional_t<sizeof(_Tp) <= sizeof(int64_t), int64_t,
-#ifndef _LIBCPP_HAS_NO_INT128
+#if _LIBCPP_HAS_INT128
__conditional_t<sizeof(_Tp) <= sizeof(__int128_t), __int128_t,
/* else */ void>
#else
diff --git a/libcxx/include/__type_traits/make_signed.h b/libcxx/include/__type_traits/make_signed.h
index d09d6ed4a1e7cc..8070690b3a7a90 100644
--- a/libcxx/include/__type_traits/make_signed.h
+++ b/libcxx/include/__type_traits/make_signed.h
@@ -35,11 +35,11 @@ typedef __type_list<signed char,
__type_list<signed int,
__type_list<signed long,
__type_list<signed long long,
-# ifndef _LIBCPP_HAS_NO_INT128
+# if _LIBCPP_HAS_INT128
__type_list<__int128_t,
# endif
__nat
-# ifndef _LIBCPP_HAS_NO_INT128
+# if _LIBCPP_HAS_INT128
>
# endif
> > > > > __signed_types;
@@ -63,7 +63,7 @@ template <> struct __make_signed< signed long, true> {typedef long ty
template <> struct __make_signed<unsigned long, true> {typedef long type;};
template <> struct __make_signed< signed long long, true> {typedef long long type;};
template <> struct __make_signed<unsigned long long, true> {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 8757f451eb807b..562f7bab8a7fbf 100644
--- a/libcxx/include/__type_traits/make_unsigned.h
+++ b/libcxx/include/__type_traits/make_unsigned.h
@@ -37,11 +37,11 @@ typedef __type_list<unsigned char,
__type_list<unsigned int,
__type_list<unsigned long,
__type_list<unsigned long long,
-# ifndef _LIBCPP_HAS_NO_INT128
+# if _LIBCPP_HAS_INT128
__type_list<__uint128_t,
# endif
__nat
-# ifndef _LIBCPP_HAS_NO_INT128
+# if _LIBCPP_HAS_INT128
>
# endif
> > > > > __unsigned_types;
@@ -65,7 +65,7 @@ template <> struct __make_unsigned< signed long, true> {typedef unsigned l
template <> struct __make_unsigned<unsigned long, true> {typedef unsigned long type;};
template <> struct __make_unsigned< signed long long, true> {typedef unsigned long long type;};
template <> struct __make_unsigned<unsigned long long, true> {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 2b2a6843b91502..a2c856478f856e 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
diff --git a/libcxx/include/__utility/convert_to_integral.h b/libcxx/include/__utility/convert_to_integral.h
index f1fcdd98010cca..8947c349d83020 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 9f732ca265c86e..a03bd7e8f35227 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 <class Iterator, class Size, class OutputIterator>
// 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 <class _Rollback>
using __exception_guard = __exception_guard_noexceptions<_Rollback>;
#else
diff --git a/libcxx/include/any b/libcxx/include/any
index 6e4ff31ff9b620..e32aa7f8e8a420 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 <class _Tp>
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<type_info const*>(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<void*>(static_cast<void const*>(&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<void*>(static_cast<void const*>(&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 772ac998615a93..6a40cad8a414c1 100644
--- a/libcxx/include/atomic
+++ b/libcxx/include/atomic
@@ -617,7 +617,7 @@ template <class T>
# pragma GCC system_header
#endif
-#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER
+#if !_LIBCPP_HAS_ATOMIC_HEADER
# error <atomic> is not implemented
#endif
diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar
index bfc26f03aaf782..1d156eb7aaaf35 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 759de5d3a030a6..7cef5543c2cca7 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -905,7 +905,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
@@ -998,23 +998,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);
@@ -1023,19 +1023,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
}
@@ -1043,7 +1043,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
}
@@ -1051,7 +1051,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
}
@@ -1064,7 +1064,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);
@@ -1077,7 +1077,7 @@ private:
}
#endif
}
-#if !defined(_LIBCPP_HAS_NO_ASAN)
+#if _LIBCPP_HAS_ASAN
public:
_LIBCPP_HIDE_FROM_ABI bool __verify_asan_annotations() const _NOEXCEPT {
@@ -1139,7 +1139,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);
@@ -2105,22 +2105,22 @@ void deque<_Tp, _Allocator>::__add_front_capacity(size_type __n) {
size_type __ds = (__nb + __back_capacity) * __block_size - __map_.empty();
__split_buffer<pointer, __pointer_allocator&> __buf(
std::max<size_type>(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();
@@ -2230,22 +2230,22 @@ void deque<_Tp, _Allocator>::__add_back_capacity(size_type __n) {
std::max<size_type>(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 708fa3d8f72cef..bbe77ae09b024c 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 3187b11e4dde77..0fbdecf2509550 100644
--- a/libcxx/include/forward_list
+++ b/libcxx/include/forward_list
@@ -1121,13 +1121,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_;
@@ -1136,7 +1136,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);
@@ -1161,13 +1161,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_;
@@ -1176,7 +1176,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 a77b7ce06f2aaa..e7a99b54d0f471 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -211,8 +211,10 @@ typedef basic_fstream<wchar_t> 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)
@@ -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 <class _CharT, class _Traits>
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 <class _CharT, class _Traits>
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 <class _CharT, class _Traits>
@@ -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 <class _CharT, class _Traits>
inline basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_istream<char_type, traits_type>(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 <class _CharT, class _Traits>
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 <class _CharT, class _Traits>
inline basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_ostream<char_type, traits_type>(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 <class _CharT, class _Traits>
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 <class _CharT, class _Traits>
inline basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_iostream<char_type, traits_type>(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 <class _CharT, class _Traits>
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 9a0eb7971a313d..ec5ec756cf39c2 100644
--- a/libcxx/include/future
+++ b/libcxx/include/future
@@ -495,7 +495,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;
@@ -774,15 +774,15 @@ inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __f
template <class _Rp, class _Fp>
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 <class _Fp>
@@ -804,16 +804,16 @@ inline __deferred_assoc_state<void, _Fp>::__deferred_assoc_state(_Fp&& __f) : __
template <class _Fp>
void __deferred_assoc_state<void, _Fp>::__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 <class _Rp, class _Fp>
@@ -835,15 +835,15 @@ inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(s
template <class _Rp, class _Fp>
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 <class _Rp, class _Fp>
@@ -871,16 +871,16 @@ inline __async_assoc_state<void, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(
template <class _Fp>
void __async_assoc_state<void, _Fp>::__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 <class _Fp>
@@ -1647,15 +1647,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 <class _Rp, class... _ArgTypes>
@@ -1664,15 +1664,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 <class _Rp, class... _ArgTypes>
@@ -1747,16 +1747,16 @@ void packaged_task<void(_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
__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 <class... _ArgTypes>
@@ -1765,16 +1765,16 @@ void packaged_task<void(_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
__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 <class... _ArgTypes>
@@ -1844,13 +1844,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 fb4f15b9a58533..eda52cf3a898d6 100644
--- a/libcxx/include/iomanip
+++ b/libcxx/include/iomanip
@@ -231,9 +231,9 @@ public:
template <class _CharT, class _Traits, class _MoneyT>
_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;
@@ -243,11 +243,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;
}
@@ -280,9 +280,9 @@ public:
template <class _CharT, class _Traits, class _MoneyT>
_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;
@@ -291,11 +291,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;
}
@@ -328,9 +328,9 @@ public:
template <class _CharT, class _Traits>
_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;
@@ -340,11 +340,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;
}
@@ -377,9 +377,9 @@ public:
template <class _CharT, class _Traits>
_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;
@@ -389,11 +389,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 61a05fadd29a17..b30efc48263e88 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 <iosfwd>
-# 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 eeafcc37c598ef..9079ce21512f90 100644
--- a/libcxx/include/iosfwd
+++ b/libcxx/include/iosfwd
@@ -134,7 +134,7 @@ typedef fpos<mbstate_t> streampos;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
typedef fpos<mbstate_t> wstreampos;
#endif
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
typedef fpos<mbstate_t> u8streampos;
#endif
typedef fpos<mbstate_t> u16streampos;
diff --git a/libcxx/include/istream b/libcxx/include/istream
index 7c65a24bc313d9..3141cdb441b6d4 100644
--- a/libcxx/include/istream
+++ b/libcxx/include/istream
@@ -354,13 +354,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);
@@ -435,9 +435,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;
@@ -451,7 +451,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);
@@ -459,7 +459,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;
@@ -481,7 +481,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;
@@ -502,7 +502,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);
@@ -569,7 +569,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();
@@ -577,7 +577,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);
@@ -611,9 +611,9 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
sentry __s(*this, true);
if (__s) {
if (__sb) {
-#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::eof())) {
@@ -627,7 +627,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
}
if (__gc_ == 0)
__state |= ios_base::failbit;
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
__state |= ios_base::badbit;
if (__gc_ == 0)
@@ -638,7 +638,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_typ
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+#endif // _LIBCPP_HAS_EXCEPTIONS
} else {
__state |= ios_base::failbit;
}
@@ -654,7 +654,7 @@ typename basic_istream<_CharT, _Traits>::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();
@@ -662,7 +662,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) {
@@ -682,7 +682,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) {
@@ -700,7 +700,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);
@@ -731,9 +731,9 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __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())) {
@@ -748,12 +748,12 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __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);
@@ -768,9 +768,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())) {
@@ -791,7 +791,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);
@@ -803,7 +803,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();
@@ -819,9 +819,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<streamsize>::max()) {
while (true) {
typename traits_type::int_type __i = this->rdbuf()->sbumpc();
@@ -845,7 +845,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);
@@ -853,7 +853,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;
@@ -866,13 +866,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);
@@ -880,7 +880,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;
@@ -892,13 +892,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);
@@ -906,7 +906,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;
}
@@ -920,9 +920,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:
@@ -937,7 +937,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);
@@ -945,7 +945,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;
}
@@ -960,12 +960,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);
@@ -973,7 +973,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;
}
@@ -988,12 +988,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);
@@ -1001,7 +1001,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;
}
@@ -1018,14 +1018,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);
@@ -1033,7 +1033,7 @@ int basic_istream<_CharT, _Traits>::sync() {
throw;
}
}
-#endif // _LIBCPP_HAS_NO_EXCEPTIONS
+#endif // _LIBCPP_HAS_EXCEPTIONS
this->setstate(__state);
}
return __r;
@@ -1045,11 +1045,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);
@@ -1057,7 +1057,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;
@@ -1069,12 +1069,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);
@@ -1082,7 +1082,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;
@@ -1094,12 +1094,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);
@@ -1107,7 +1107,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;
@@ -1118,9 +1118,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<ctype<_CharT> >(__is.getloc());
while (true) {
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
@@ -1132,7 +1132,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);
@@ -1140,7 +1140,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;
@@ -1208,7 +1208,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();
@@ -1240,7 +1240,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);
@@ -1260,7 +1260,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();
@@ -1283,7 +1283,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);
@@ -1321,7 +1321,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;
@@ -1345,7 +1345,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 2aa774451ec2a8..e771d8f01d7ab1 100644
--- a/libcxx/include/list
+++ b/libcxx/include/list
@@ -1155,13 +1155,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) {
__link_pointer __prev = __e.__ptr_->__prev_;
@@ -1173,7 +1173,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;
}
@@ -1197,13 +1197,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) {
__link_pointer __prev = __e.__ptr_->__prev_;
@@ -1215,7 +1215,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;
}
@@ -1368,13 +1368,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) {
__link_pointer __prev = __e.__ptr_->__prev_;
@@ -1386,7 +1386,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;
}
@@ -1404,13 +1404,13 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
__link_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) {
__link_pointer __prev = __e.__ptr_->__prev_;
@@ -1422,7 +1422,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 573910a85bef54..a045366dba261b 100644
--- a/libcxx/include/locale
+++ b/libcxx/include/locale
@@ -223,6 +223,8 @@ template <class charT> class messages_byname;
# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
# define _LIBCPP_HAS_CATOPEN 1
# include <nl_types.h>
+# else
+# _LIBCPP_HAS_CATOPEN 0
# endif
# endif
@@ -3074,7 +3076,7 @@ locale::id messages<_CharT>::id;
template <class _CharT>
typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<char>& __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 +3087,7 @@ typename messages<_CharT>::catalog messages<_CharT>::do_open(const basic_string<
template <class _CharT>
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<sizeof(char_type) * __CHAR_BIT__>()(
std::back_inserter(__ndflt), __dflt.c_str(), __dflt.c_str() + __dflt.size());
@@ -3105,7 +3107,7 @@ messages<_CharT>::do_get(catalog __c, int __set, int __msgid, const string_type&
template <class _CharT>
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 207e4b46e0ca6e..96fadf3b4cf52d 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 @@ _LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __
_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_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t
_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
_LIBCPP_NODISCARD _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
_LIBCPP_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 @@ _LIBCPP_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
# 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_val_t>(__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 <class... _Args>
_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 b0933b59b25d26..c607702297da82 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -257,7 +257,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 d59abb8daf8ec1..57ba39c21b6763 100644
--- a/libcxx/include/regex
+++ b/libcxx/include/regex
@@ -984,7 +984,7 @@ public:
template <regex_constants::error_type _Ev>
[[__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 78a7f2d5901d26..ed3832fef3c3d3 100644
--- a/libcxx/include/sstream
+++ b/libcxx/include/sstream
@@ -781,9 +781,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());
@@ -792,11 +792,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/stdexcept b/libcxx/include/stdexcept
index bdfc27aeac3742..daa7b501a86999 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 46c5a5ac6de605..ad24917164e835 100644
--- a/libcxx/include/string
+++ b/libcxx/include/string
@@ -672,7 +672,7 @@ basic_string<char32_t> 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.
@@ -777,7 +777,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
@@ -791,7 +791,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;
@@ -2014,7 +2015,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())
@@ -2026,14 +2027,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
@@ -2041,7 +2042,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
@@ -2049,7 +2050,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
@@ -2412,19 +2413,19 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator _
__r_.first() = __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 <class _CharT, class _Traits, class _Allocator>
@@ -2459,18 +2460,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);
}
@@ -3372,9 +3373,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.
@@ -3387,11 +3388,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;
@@ -4230,7 +4231,7 @@ struct __string_hash : public __unary_function<basic_string<_CharT, char_traits<
template <class _Allocator>
struct hash<basic_string<char, char_traits<char>, _Allocator> > : __string_hash<char, _Allocator> {};
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
template <class _Allocator>
struct hash<basic_string<char8_t, char_traits<char8_t>, _Allocator> > : __string_hash<char8_t, _Allocator> {};
#endif
@@ -4304,7 +4305,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<char8_t> operator""s(const char8_t* __str, size_t __len) {
return basic_string<char8_t>(__str, __len);
}
diff --git a/libcxx/include/string_view b/libcxx/include/string_view
index cf97e3a9be314d..92fe14a49c3fa2 100644
--- a/libcxx/include/string_view
+++ b/libcxx/include/string_view
@@ -901,7 +901,7 @@ struct __string_view_hash : public __unary_function<basic_string_view<_CharT, ch
template <>
struct hash<basic_string_view<char, char_traits<char> > > : __string_view_hash<char> {};
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
template <>
struct hash<basic_string_view<char8_t, char_traits<char8_t> > > : __string_view_hash<char8_t> {};
#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<char8_t>
operator""sv(const char8_t* __str, size_t __len) noexcept {
return basic_string_view<char8_t>(__str, __len);
diff --git a/libcxx/include/syncstream b/libcxx/include/syncstream
index fea4c66b8e118f..1a136194183fee 100644
--- a/libcxx/include/syncstream
+++ b/libcxx/include/syncstream
@@ -270,14 +270,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();
}
@@ -334,7 +334,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();
@@ -345,7 +345,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();
}
@@ -477,13 +477,13 @@ public:
// TODO validate other unformatted output functions.
typename basic_ostream<char_type, traits_type>::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 a44fa4d73ee580..252afe59a0aa6d 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 44341eb2ba6c14..b3b48958f92bd7 100644
--- a/libcxx/include/valarray
+++ b/libcxx/include/valarray
@@ -1984,17 +1984,17 @@ template <class _Tp>
inline valarray<_Tp>::valarray(size_t __n) : __begin_(nullptr), __end_(nullptr) {
if (__n) {
__begin_ = __end_ = allocator<value_type>().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 <class _Tp>
valarray<_Tp>::valarray(const value_type* __p, size_t __n) : __begin_(nullptr), __end_(nullptr) {
if (__n) {
__begin_ = __end_ = allocator<value_type>().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 <class _Tp>
valarray<_Tp>::valarray(const valarray& __v) : __begin_(nullptr), __end_(nullptr) {
if (__v.size()) {
__begin_ = __end_ = allocator<value_type>().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<value_type> __il) : __begin_(nullptr),
const size_t __n = __il.size();
if (__n) {
__begin_ = __end_ = allocator<value_type>().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<value_type>& __sa) : __begin_(nullptr)
const size_t __n = __sa.__size_;
if (__n) {
__begin_ = __end_ = allocator<value_type>().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<value_type>& __ga) : __begin_(nullptr
const size_t __n = __ga.__1d_.size();
if (__n) {
__begin_ = __end_ = allocator<value_type>().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<value_type>& __ma) : __begin_(nullptr),
const size_t __n = __ma.__1d_.size();
if (__n) {
__begin_ = __end_ = allocator<value_type>().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<value_type>& __ia) : __begin_(nullp
const size_t __n = __ia.__1d_.size();
if (__n) {
__begin_ = __end_ = allocator<value_type>().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<value_type>().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 1cac603c27c243..27ac4bd56821f4 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -300,7 +300,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");
@@ -1073,7 +1073,7 @@ public:
std::swap(__lhs, __rhs);
}
__impl __tmp(std::move(*__rhs));
-# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+# if _LIBCPP_HAS_EXCEPTIONS
if constexpr (__all<is_nothrow_move_constructible_v<_Types>...>::value) {
this->__generic_construct(*__rhs, std::move(*__lhs));
} else {
@@ -1311,7 +1311,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 fc0a48669fe534..9aebbe4428d02e 100644
--- a/libcxx/include/vector
+++ b/libcxx/include/vector
@@ -904,27 +904,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
}
@@ -932,14 +932,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_);
}
@@ -1472,9 +1472,9 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<_Tp, _Allocator>::reserve(size_type __
template <class _Tp, class _Allocator>
_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<value_type, allocator_type&> __v(size(), size(), __a);
// The Standard mandates shrink_to_fit() does not increase the capacity.
@@ -1482,10 +1482,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
}
}
@@ -1723,21 +1723,21 @@ vector<_Tp, _Allocator>::__insert_with_sentinel(const_iterator __position, _Inpu
}
__split_buffer<value_type, allocator_type&> __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()));
@@ -2183,18 +2183,18 @@ private:
template <class _InputIterator, class _Sentinel>
_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 <class _Iterator, class _Sentinel>
@@ -2639,14 +2639,14 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::reserve(size_type _
template <class _Allocator>
_LIBCPP_CONSTEXPR_SINCE_CXX20 void vector<bool, _Allocator>::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
}
}
@@ -2735,21 +2735,21 @@ vector<bool, _Allocator>::__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<difference_type>(__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 dc1d3fd268ce83..7313178e185e73 100644
--- a/libcxx/include/version
+++ b/libcxx/include/version
@@ -383,7 +383,7 @@ __cpp_lib_void_t 201411L <type_traits>
# 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 d1a511cadef184..119a8511252bfc 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 ad8a639b7f71a1..ad357d0db65bc0 100644
--- a/libcxx/modules/std.cppm.in
+++ b/libcxx/modules/std.cppm.in
@@ -20,7 +20,7 @@ module;
#include <algorithm>
#include <any>
#include <array>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
+#if _LIBCPP_HAS_ATOMIC_HEADER
# include <atomic>
#endif
#if !defined(_LIBCPP_HAS_NO_THREADS)
diff --git a/libcxx/modules/std/cuchar.inc b/libcxx/modules/std/cuchar.inc
index fd80110d11ee84..4a0b21c17b7e12 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 090d990d061e5e..952057d691fc40 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 c15f37a21239ce..4c4cccfd7cf2fe 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 9808a96215a182..322317c98c0180 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 f4f9d80ddb83da..1237f4516e7d00 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/filesystem/error.h b/libcxx/src/filesystem/error.h
index 09020fbede9b94..07ba7fc3eef251 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<T>();
}
@@ -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<T>();
}
diff --git a/libcxx/src/filesystem/format_string.h b/libcxx/src/filesystem/format_string.h
index 81c5a95ae31e5f..ad6c57579a0a62 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 72b7cb4a8d1c09..da6f39e7d78b60 100644
--- a/libcxx/src/filesystem/int128_builtins.cpp
+++ b/libcxx/src/filesystem/int128_builtins.cpp
@@ -16,7 +16,7 @@
#include <__config>
#include <climits>
-#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 e2c14c8321dddb..04e6fb8db64596 100644
--- a/libcxx/src/future.cpp
+++ b/libcxx/src/future.cpp
@@ -142,10 +142,10 @@ promise<void>::promise() : __state_(new __assoc_sub_state) {}
promise<void>::~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 a727855c4655e8..74d33b4b2f1bce 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 0f87c7099fe37e..29eb5e68126f08 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<codecvt<char16_t, char, mbstate_t> >(1u));
install(&make<codecvt<char32_t, char, mbstate_t> >(1u));
_LIBCPP_SUPPRESS_DEPRECATED_POP
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u));
install(&make<codecvt<char32_t, char8_t, mbstate_t> >(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<char16_t, char, mbstate_t>(name_));
install(new codecvt_byname<char32_t, char, mbstate_t>(name_));
_LIBCPP_SUPPRESS_DEPRECATED_POP
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_));
install(new codecvt_byname<char32_t, char8_t, mbstate_t>(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<wchar_t>(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<size_t>(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<char>(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<char16_t, char, mbstate_t>(name));
install(new codecvt_byname<char32_t, char, mbstate_t>(name));
_LIBCPP_SUPPRESS_DEPRECATED_POP
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name));
install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name));
#endif
@@ -348,14 +348,14 @@ locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
install(new messages_byname<wchar_t>(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 <class F>
@@ -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<std::collate<char> >(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<std::codecvt<char16_t, char, mbstate_t> >(one);
install_from<std::codecvt<char32_t, char, mbstate_t> >(one);
_LIBCPP_SUPPRESS_DEPRECATED_POP
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one);
install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one);
#endif
@@ -443,14 +443,14 @@ locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
install_from<std::messages<wchar_t> >(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<char16_t, char, mbstate_t>::do_length(
int codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept { return 4; }
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
// template <> class codecvt<char16_t, char8_t, mbstate_t>
@@ -2949,7 +2949,7 @@ int codecvt<char32_t, char, mbstate_t>::do_length(
int codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept { return 4; }
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
// template <> class codecvt<char32_t, char8_t, mbstate_t>
@@ -5707,7 +5707,7 @@ template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_
codecvt_byname<char16_t, char, mbstate_t>;
template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
codecvt_byname<char32_t, char, mbstate_t>;
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char8_t, mbstate_t>;
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char8_t, mbstate_t>;
#endif
diff --git a/libcxx/src/memory_resource.cpp b/libcxx/src/memory_resource.cpp
index d2ff3509c5a31e..299f810948fd14 100644
--- a/libcxx/src/memory_resource.cpp
+++ b/libcxx/src/memory_resource.cpp
@@ -9,7 +9,7 @@
#include <memory>
#include <memory_resource>
-#ifndef _LIBCPP_HAS_NO_ATOMIC_HEADER
+#if _LIBCPP_HAS_ATOMIC_HEADER
# include <atomic>
#elif !defined(_LIBCPP_HAS_NO_THREADS)
# include <mutex>
@@ -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<memory_resource*> __res{&res_init.resources.new_delete_res};
if (set) {
new_res = new_res ? new_res : new_delete_resource();
diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp
index b0c731678cac30..e010fe4c4f1912 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<void* (*)(std::size_t)>(&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<void* (*)(std::size_t)>(&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<void* (*)(std::size_t, std::align_val_t)>(&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<void* (*)(std::size_t, std::align_val_t)>(&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 6560d0188ee32b..2119d82b3e00f9 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 e1a9a4bc1de718..f036aaf29dfb25 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<filebuf*>(__rdbuf))
@@ -33,7 +33,7 @@ _LIBCPP_EXPORTED_FROM_ABI FILE* __get_ostream_file(ostream& __os) {
if (auto* __buffer = dynamic_cast<__stdoutbuf<char>*>(__rdbuf))
return __buffer->__file_;
-#endif // _LIBCPP_HAS_NO_RTTI
+#endif // _LIBCPP_HAS_RTTI
return nullptr;
}
diff --git a/libcxx/src/stdexcept.cpp b/libcxx/src/stdexcept.cpp
index 134d28efb750f3..0ee438bef02e10 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 ca542c9497214f..edd9cfcc2e0337 100644
--- a/libcxx/src/support/runtime/exception_fallback.ipp
+++ b/libcxx/src/support/runtime/exception_fallback.ipp
@@ -34,20 +34,20 @@ 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
fprintf(stderr, "terminate_handler unexpectedly returned\n");
::abort();
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
// handler should not throw exception
fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
::abort();
}
-#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 163aec057d9b5c..4488200a415991 100644
--- a/libcxx/src/support/runtime/exception_msvc.ipp
+++ b/libcxx/src/support/runtime/exception_msvc.ipp
@@ -43,20 +43,20 @@ 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
fprintf(stderr, "terminate_handler unexpectedly returned\n");
::abort();
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
// handler should not throw exception
fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
::abort();
}
-#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 3367bd56bd7880..476729310d868b 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 55b5929847748f..563580b6879552 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<unsigned int>);
static_assert(std::__libcpp_integer<unsigned long int>);
static_assert(std::__libcpp_integer<unsigned long long int>);
static_assert(std::__libcpp_integer<unsigned short int>);
-#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<int>);
static_assert(std::__libcpp_integer<long int>);
static_assert(std::__libcpp_integer<long long int>);
static_assert(std::__libcpp_integer<short int>);
-#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 5bf7aa526f0a26..d1e21ee96b0736 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<unsigned int>);
static_assert(!std::__libcpp_signed_integer<unsigned long int>);
static_assert(!std::__libcpp_signed_integer<unsigned long long int>);
static_assert(!std::__libcpp_signed_integer<unsigned short int>);
-#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<int>);
static_assert(std::__libcpp_signed_integer<long int>);
static_assert(std::__libcpp_signed_integer<long long int>);
static_assert(std::__libcpp_signed_integer<short int>);
-#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 163ec53e17bc1e..c671f03cbfce46 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<unsigned int>);
static_assert(std::__libcpp_unsigned_integer<unsigned long int>);
static_assert(std::__libcpp_unsigned_integer<unsigned long long int>);
static_assert(std::__libcpp_unsigned_integer<unsigned short int>);
-#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<int>);
static_assert(!std::__libcpp_unsigned_integer<long int>);
static_assert(!std::__libcpp_unsigned_integer<long long int>);
static_assert(!std::__libcpp_unsigned_integer<short int>);
-#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 578afaabbd26de..505618c0b88d70 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 34a3146e26c958..6249c52814781a 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/utilities/expected/expected.expected/value.observers.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/value.observers.verify.cpp
index 00ba267a4fde09..d2b62a9b6ab994 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 29881891ffd11e..dca300320f8a7e 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
@@ -166,7 +166,7 @@ void f() {
static_assert(std::is_same_v<std::atomic<long long>, ::atomic_llong>);
static_assert(std::is_same_v<std::atomic<unsigned long long>, ::atomic_ullong>);
-#ifndef _LIBCPP_HAS_NO_CHAR8_T
+#if _LIBCPP_HAS_CHAR8_T
static_assert(std::is_same_v<std::atomic<char8_t>, ::atomic_char8_t>);
#endif
static_assert(std::is_same_v<std::atomic<char16_t>, ::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 159cb19f65468b..772c3c563087ec 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<T, 0x100000001ull, 0ull, (1ull << 61) - 1ull> 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 c59afd7a3eb273..6ecd22ea3450fb 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
@@ -83,7 +83,7 @@ int main(int, char**)
test_ext<unsigned long>();
test<unsigned long long>();
// This isn't implemented on platforms without __int128
-#ifndef _LIBCPP_HAS_NO_INT128
+#ifndef TEST_HAS_NO_INT128
test_ext<unsigned long long>();
#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 98b07e70f247af..13468536c5f49b 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
@@ -116,7 +116,7 @@ int main(int, char**)
test_ext<unsigned long>();
test<unsigned long long>();
// This isn't implemented on platforms without __int128
-#ifndef _LIBCPP_HAS_NO_INT128
+#ifndef TEST_HAS_NO_INT128
test_ext<unsigned long long>();
#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 bc058d400f7496..1d4a225668d80a 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 at -3 {{no member named 'c8rtomb' in the global namespace}}
// expected-error at -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 8fcc05ec49d7c1..45aaa2cfef207f 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 3aa818af1d2695..5e1667d462ef4f 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -214,10 +214,9 @@
#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_HAS_ALIGNED_ALLOCATION) && _LIBCPP_HAS_ALIGNED_ALLOCATION) || \
+ (!(TEST_STD_VER > 14 || (defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606L)))
+# define TEST_HAS_NO_ALIGNED_ALLOCATION
#endif
#if TEST_STD_VER > 17
@@ -399,8 +398,8 @@ inline Tp const& DoNotOptimize(Tp const& value) {
# 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_HAS_INT128) && !_LIBCPP_HAS_INT128) || defined(_MSVC_STL_VERSION)
+# define TEST_HAS_NO_INT128
#endif
#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
@@ -419,7 +418,7 @@ inline Tp const& DoNotOptimize(Tp const& value) {
# define TEST_HAS_NO_FILESYSTEM
#endif
-#if defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8)
+#if defined(_LIBCPP_HAS_C8RTOMB_MBRTOC8) && !_LIBCPP_HAS_C8RTOMB_MBRTOC8
# define TEST_HAS_NO_C8RTOMB_MBRTOC8
#endif
diff --git a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
index 5de2d44994ad05..452f9b3887e78e 100644
--- a/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
+++ b/libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
@@ -92,6 +92,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 00000000000000..21e5226df55d95
--- /dev/null
+++ b/libcxx/test/tools/clang_tidy_checks/internal_ftm_use.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "internal_ftm_use.hpp"
+
+#include <clang/Lex/Lexer.h>
+#include <clang/Lex/PPCallbacks.h>
+#include <clang/Lex/Preprocessor.h>
+
+#include <string>
+
+namespace libcpp {
+namespace {
+std::array valid_macros{
+ // Public API macros
+ "_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER",
+ "_LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS",
+
+ // 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<internal_ftm_use_callbacks>(*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 00000000000000..90c5448f6b38e0
--- /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 16acf32ae55b38..54beed5e30be58 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::abi_tag_on_virtual>("libcpp-avoid-abi-tag-on-virtual");
check_factories.registerCheck<libcpp::header_exportable_declarations>("libcpp-header-exportable-declarations");
check_factories.registerCheck<libcpp::hide_from_abi>("libcpp-hide-from-abi");
+ check_factories.registerCheck<libcpp::internal_ftm_use>("libcpp-internal-ftms");
check_factories.registerCheck<libcpp::proper_version_checks>("libcpp-cpp-version-check");
check_factories.registerCheck<libcpp::robust_against_adl_check>("libcpp-robust-against-adl");
check_factories.registerCheck<libcpp::uglify_attributes>("libcpp-uglify-attributes");
diff --git a/libcxx/utils/generate_feature_test_macro_components.py b/libcxx/utils/generate_feature_test_macro_components.py
index 3bdd3adad15b4e..47dce682fb0b67 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 166c9a77c08e70..153f20a1f13718 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/stdlib_new_delete.cpp b/libcxxabi/src/stdlib_new_delete.cpp
index b802559d479e2c..bdd7978c776358 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<void* (*)(std::size_t)>(&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<void* (*)(std::size_t)>(&operator new[])),
@@ -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<void* (*)(std::size_t, std::align_val_t)>(&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<void* (*)(std::size_t, std::align_val_t)>(&operator new[])),
More information about the libcxx-commits
mailing list