diff options
author | Nikolas Klauser <nikolasklauser@berlin.de> | 2024-10-12 09:49:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-12 09:49:52 +0200 |
commit | ba87515fea90b5d55836a8e3be63a7e683ce299d (patch) | |
tree | 25b36e09d01ff31f453e6a8141629a52a7f673bb /libcxx/src | |
parent | dbd197118db597970a5a9c5688c5e0bb01948ebb (diff) | |
download | llvm-ba87515fea90b5d55836a8e3be63a7e683ce299d.zip llvm-ba87515fea90b5d55836a8e3be63a7e683ce299d.tar.gz llvm-ba87515fea90b5d55836a8e3be63a7e683ce299d.tar.bz2 |
[libc++][RFC] Always define internal feature test macros (#89178)
Currently, the library-internal feature test macros are only defined if
the feature is not available, and always have the prefix
`_LIBCPP_HAS_NO_`. This patch changes that, so that they are always
defined and have the prefix `_LIBCPP_HAS_` instead. This changes the
canonical use of these macros to `#if _LIBCPP_HAS_FEATURE`, which means
that using an undefined macro (e.g. due to a missing include) is
diagnosed now. While this is rather unlikely currently, a similar change
in `<__configuration/availability.h>` caught a few bugs. This also
improves readability, since it removes the double-negation of `#ifndef
_LIBCPP_HAS_NO_FEATURE`.
The current patch only touches the macros defined in `<__config>`. If
people are happy with this approach, I'll make a follow-up PR to also
change the macros defined in `<__config_site>`.
Diffstat (limited to 'libcxx/src')
-rw-r--r-- | libcxx/src/condition_variable_destructor.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/filesystem/error.h | 16 | ||||
-rw-r--r-- | libcxx/src/filesystem/format_string.h | 8 | ||||
-rw-r--r-- | libcxx/src/filesystem/int128_builtins.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/future.cpp | 4 | ||||
-rw-r--r-- | libcxx/src/ios.cpp | 8 | ||||
-rw-r--r-- | libcxx/src/locale.cpp | 38 | ||||
-rw-r--r-- | libcxx/src/memory_resource.cpp | 8 | ||||
-rw-r--r-- | libcxx/src/mutex_destructor.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/new.cpp | 12 | ||||
-rw-r--r-- | libcxx/src/new_helpers.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/ostream.cpp | 4 | ||||
-rw-r--r-- | libcxx/src/ryu/d2s.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/stdexcept.cpp | 2 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_fallback.ipp | 8 | ||||
-rw-r--r-- | libcxx/src/support/runtime/exception_msvc.ipp | 8 | ||||
-rw-r--r-- | libcxx/src/system_error.cpp | 2 |
17 files changed, 64 insertions, 64 deletions
diff --git a/libcxx/src/condition_variable_destructor.cpp b/libcxx/src/condition_variable_destructor.cpp index 59811ed..f6ffe33 100644 --- a/libcxx/src/condition_variable_destructor.cpp +++ b/libcxx/src/condition_variable_destructor.cpp @@ -14,7 +14,7 @@ #include <__config> #include <__thread/support.h> -#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION) +#if _LIBCPP_ABI_VERSION == 1 || !_LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION # define NEEDS_CONDVAR_DESTRUCTOR #endif diff --git a/libcxx/src/filesystem/error.h b/libcxx/src/filesystem/error.h index 09020fb..07ba7fc 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 81c5a95..ad6c575 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 72b7cb4..da6f39e 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 e2c14c8..04e6fb8 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 a727855..74d33b4 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 484963d..99a2d50 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 d2ff350..299f810 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/mutex_destructor.cpp b/libcxx/src/mutex_destructor.cpp index a6ceaaa..9f99172 100644 --- a/libcxx/src/mutex_destructor.cpp +++ b/libcxx/src/mutex_destructor.cpp @@ -19,7 +19,7 @@ #include <__config> #include <__thread/support.h> -#if _LIBCPP_ABI_VERSION == 1 || !defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION) +#if _LIBCPP_ABI_VERSION == 1 || !_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION # define NEEDS_MUTEX_DESTRUCTOR #endif diff --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp index b0c7316..e010fe4 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 6560d01..2119d82 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 e1a9a4b..f036aaf 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/ryu/d2s.cpp b/libcxx/src/ryu/d2s.cpp index 32d617c..5b80ed8 100644 --- a/libcxx/src/ryu/d2s.cpp +++ b/libcxx/src/ryu/d2s.cpp @@ -478,7 +478,7 @@ struct __floating_decimal_64 { 36893488u, 7378697u, 1475739u, 295147u, 59029u, 11805u, 2361u, 472u, 94u, 18u, 3u }; unsigned long _Trailing_zero_bits; -#ifdef _LIBCPP_HAS_BITSCAN64 +#if _LIBCPP_HAS_BITSCAN64 (void) _BitScanForward64(&_Trailing_zero_bits, __v.__mantissa); // __v.__mantissa is guaranteed nonzero #else // ^^^ 64-bit ^^^ / vvv 32-bit vvv const uint32_t _Low_mantissa = static_cast<uint32_t>(__v.__mantissa); diff --git a/libcxx/src/stdexcept.cpp b/libcxx/src/stdexcept.cpp index 134d28e..0ee438b 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 bedb16e..ba283ae 100644 --- a/libcxx/src/support/runtime/exception_fallback.ipp +++ b/libcxx/src/support/runtime/exception_fallback.ipp @@ -34,18 +34,18 @@ terminate_handler set_terminate(terminate_handler func) noexcept { terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); } [[noreturn]] void terminate() noexcept { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS (*get_terminate())(); // handler should not return __libcpp_verbose_abort("terminate_handler unexpectedly returned\n"); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { // handler should not throw exception __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n"); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } diff --git a/libcxx/src/support/runtime/exception_msvc.ipp b/libcxx/src/support/runtime/exception_msvc.ipp index 869b64d..2ae004b 100644 --- a/libcxx/src/support/runtime/exception_msvc.ipp +++ b/libcxx/src/support/runtime/exception_msvc.ipp @@ -42,18 +42,18 @@ terminate_handler set_terminate(terminate_handler func) noexcept { return ::set_ terminate_handler get_terminate() noexcept { return ::_get_terminate(); } [[noreturn]] void terminate() noexcept { -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS try { -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS (*get_terminate())(); // handler should not return __libcpp_verbose_abort("terminate_handler unexpectedly returned\n"); -#ifndef _LIBCPP_HAS_NO_EXCEPTIONS +#if _LIBCPP_HAS_EXCEPTIONS } catch (...) { // handler should not throw exception __libcpp_verbose_abort("terminate_handler unexpectedly threw an exception\n"); } -#endif // _LIBCPP_HAS_NO_EXCEPTIONS +#endif // _LIBCPP_HAS_EXCEPTIONS } bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; } diff --git a/libcxx/src/system_error.cpp b/libcxx/src/system_error.cpp index 3367bd5..4767293 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. |