70 changes: 35 additions & 35 deletions libcxx/include/future
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ public:

// Declared above std::future_error
void __throw_future_error(future_errc __ev) {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
throw future_error(make_error_code(__ev));
# else
(void)__ev;
Expand Down Expand Up @@ -779,15 +779,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>
Expand All @@ -809,16 +809,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>
Expand All @@ -840,15 +840,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>
Expand Down Expand Up @@ -876,16 +876,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>
Expand Down Expand Up @@ -1656,15 +1656,15 @@ void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) {
__throw_future_error(future_errc::no_state);
if (__p_.__state_->__has_value())
__throw_future_error(future_errc::promise_already_satisfied);
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
try {
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
__p_.set_value(__f_(std::forward<_ArgTypes>(__args)...));
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
__p_.set_exception(current_exception());
}
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
}

template <class _Rp, class... _ArgTypes>
Expand All @@ -1673,15 +1673,15 @@ void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __
__throw_future_error(future_errc::no_state);
if (__p_.__state_->__has_value())
__throw_future_error(future_errc::promise_already_satisfied);
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
try {
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
__p_.set_value_at_thread_exit(__f_(std::forward<_ArgTypes>(__args)...));
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
__p_.set_exception_at_thread_exit(current_exception());
}
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
}

template <class _Rp, class... _ArgTypes>
Expand Down Expand Up @@ -1758,16 +1758,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>
Expand All @@ -1776,16 +1776,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>
Expand Down Expand Up @@ -1857,13 +1857,13 @@ async(launch __policy, _Fp&& __f, _Args&&... __args) {
typedef __async_func<__decay_t<_Fp>, __decay_t<_Args>...> _BF;
typedef typename _BF::_Rp _Rp;

# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
try {
# endif
if (__does_policy_contain(__policy, launch::async))
return std::__make_async_assoc_state<_Rp>(
_BF(_LIBCPP_AUTO_CAST(std::forward<_Fp>(__f)), _LIBCPP_AUTO_CAST(std::forward<_Args>(__args))...));
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
if (__policy == launch::async)
throw;
Expand Down
32 changes: 16 additions & 16 deletions libcxx/include/iomanip
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,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;
Expand All @@ -248,11 +248,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t7<_MoneyT>& __x) {
__mf.get(_Ip(__is), _Ip(), __x.__intl_, __is, __err, __x.__mon_);
__is.setstate(__err);
}
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
__is.__set_badbit_and_consider_rethrow();
}
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
return __is;
}

Expand Down Expand Up @@ -285,9 +285,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;
Expand All @@ -296,11 +296,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x) {
if (__mf.put(_Op(__os), __x.__intl_, __os, __os.fill(), __x.__mon_).failed())
__os.setstate(ios_base::badbit);
}
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
return __os;
}

Expand Down Expand Up @@ -333,9 +333,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;
Expand All @@ -345,11 +345,11 @@ operator>>(basic_istream<_CharT, _Traits>& __is, const __iom_t9<_CharT>& __x) {
__tf.get(_Ip(__is), _Ip(), __is, __err, __x.__tm_, __x.__fmt_, __x.__fmt_ + _Traits::length(__x.__fmt_));
__is.setstate(__err);
}
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
__is.__set_badbit_and_consider_rethrow();
}
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
return __is;
}

Expand Down Expand Up @@ -382,9 +382,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;
Expand All @@ -394,11 +394,11 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x) {
.failed())
__os.setstate(ios_base::badbit);
}
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
__os.__set_badbit_and_consider_rethrow();
}
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
return __os;
}

Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/ios
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/iosfwd
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
154 changes: 77 additions & 77 deletions libcxx/include/istream

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions libcxx/include/list
Original file line number Diff line number Diff line change
Expand Up @@ -1157,13 +1157,13 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
++__ds;
__r = iterator(__node->__as_link());
iterator __e = __r;
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
__e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link();
}
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
while (true) {
__base_pointer __prev = __e.__ptr_->__prev_;
Expand All @@ -1175,7 +1175,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _
}
throw;
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
__link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
Expand All @@ -1199,13 +1199,13 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se
++__ds;
__r = iterator(__node->__as_link());
iterator __e = __r;
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
for (++__f; __f != __l; ++__f, (void)++__e, ++__ds) {
__e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, *__f)->__as_link();
}
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
while (true) {
__base_pointer __prev = __e.__ptr_->__prev_;
Expand All @@ -1217,7 +1217,7 @@ list<_Tp, _Alloc>::__insert_with_sentinel(const_iterator __p, _Iterator __f, _Se
}
throw;
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
__link_nodes(__p.__ptr_, __r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
Expand Down Expand Up @@ -1370,13 +1370,13 @@ void list<_Tp, _Alloc>::resize(size_type __n) {
++__ds;
iterator __r = iterator(__node->__as_link());
iterator __e = __r;
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
__e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr)->__as_link();
}
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
while (true) {
__base_pointer __prev = __e.__ptr_->__prev_;
Expand All @@ -1388,7 +1388,7 @@ void list<_Tp, _Alloc>::resize(size_type __n) {
}
throw;
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
__link_nodes_at_back(__r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
Expand All @@ -1406,13 +1406,13 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
__base_pointer __nl = __node->__as_link();
iterator __r = iterator(__nl);
iterator __e = __r;
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
for (--__n; __n != 0; --__n, (void)++__e, ++__ds) {
__e.__ptr_->__next_ = this->__create_node(/* prev = */ __e.__ptr_, /* next = */ nullptr, __x)->__as_link();
}
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
while (true) {
__base_pointer __prev = __e.__ptr_->__prev_;
Expand All @@ -1424,7 +1424,7 @@ void list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) {
}
throw;
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
__link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_);
base::__sz() += __ds;
}
Expand Down
10 changes: 7 additions & 3 deletions libcxx/include/locale
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ template <class charT> class messages_byname;
# if !defined(__BIONIC__) && !defined(_NEWLIB_VERSION) && !defined(__EMSCRIPTEN__)
# define _LIBCPP_HAS_CATOPEN 1
# include <nl_types.h>
# else
# define _LIBCPP_HAS_CATOPEN 0
# endif
# else
# define _LIBCPP_HAS_CATOPEN 0
# endif

# ifdef _LIBCPP_LOCALE__L_EXTENSIONS
Expand Down Expand Up @@ -3074,7 +3078,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;
Expand All @@ -3085,7 +3089,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());
Expand All @@ -3105,7 +3109,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;
Expand Down
40 changes: 23 additions & 17 deletions libcxx/include/new
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -208,7 +214,7 @@ inline constexpr destroying_delete_t destroying_delete{};
_LIBCPP_NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _NOEXCEPT;
# endif

Expand All @@ -217,17 +223,17 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz) _
_LIBCPP_NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz) _NOEXCEPT;
# endif

# ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
# if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void*
operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
# endif

Expand All @@ -237,7 +243,7 @@ operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
# ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
# if _LIBCPP_HAS_LIBRARY_SIZED_DEALLOCATION
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::size_t __sz, std::align_val_t) _NOEXCEPT;
# endif
# endif
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/optional
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD

[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void
__throw_bad_optional_access() {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
throw bad_optional_access();
# else
_LIBCPP_VERBOSE_ABORT("bad_optional_access was thrown in -fno-exceptions mode");
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/regex
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions libcxx/include/sstream
Original file line number Diff line number Diff line change
Expand Up @@ -786,9 +786,9 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {
if (this->pptr() == this->epptr()) {
if (!(__mode_ & ios_base::out))
return traits_type::eof();
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
try {
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
ptrdiff_t __nout = this->pptr() - this->pbase();
ptrdiff_t __hm = __hm_ - this->pbase();
__str_.push_back(char_type());
Expand All @@ -797,11 +797,11 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::overflow(int_type __c) {
this->setp(__p, __p + __str_.size());
this->__pbump(__nout);
__hm_ = this->pbase() + __hm;
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
return traits_type::eof();
}
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
}
__hm_ = std::max(this->pptr() + 1, __hm_);
if (__mode_ & ios_base::in) {
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/stdatomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ using std::atomic_long _LIBCPP_USING_IF_EXISTS;
using std::atomic_ulong _LIBCPP_USING_IF_EXISTS;
using std::atomic_llong _LIBCPP_USING_IF_EXISTS;
using std::atomic_ullong _LIBCPP_USING_IF_EXISTS;
# ifndef _LIBCPP_HAS_NO_CHAR8_T
# if _LIBCPP_HAS_CHAR8_T
using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS;
# endif
using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS;
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/stdexcept
Original file line number Diff line number Diff line change
Expand Up @@ -212,63 +212,63 @@ _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);
#endif
}

[[__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);
#endif
}

[[__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);
#endif
}

[[__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);
#endif
}

[[__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);
#endif
}

[[__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);
#endif
}

[[__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);
#endif
}

[[__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);
Expand Down
45 changes: 23 additions & 22 deletions libcxx/include/string
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -785,7 +785,7 @@ public:
//
// This string implementation doesn't contain any references into itself. It only contains a bit that says whether
// it is in small or large string mode, so the entire structure is trivially relocatable if its members are.
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
// When compiling with AddressSanitizer (ASan), basic_string cannot be trivially
// relocatable. Because the object's memory might be poisoned when its content
// is kept inside objects memory (short string optimization), instead of in allocated
Expand All @@ -799,7 +799,8 @@ public:
basic_string,
void>;
#endif
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)

#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pointer __asan_volatile_wrapper(pointer const& __ptr) const {
if (__libcpp_is_constant_evaluated())
return __ptr;
Expand Down Expand Up @@ -2018,7 +2019,7 @@ private:
__annotate_contiguous_container(const void* __old_mid, const void* __new_mid) const {
(void)__old_mid;
(void)__new_mid;
#if !defined(_LIBCPP_HAS_NO_ASAN) && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
#if _LIBCPP_HAS_ASAN && defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
# if defined(__APPLE__)
// TODO: remove after addressing issue #96099 (https://github.com/llvm/llvm-project/issues/96099)
if (!__is_long())
Expand All @@ -2030,30 +2031,30 @@ 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
}

_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
}

_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
Expand Down Expand Up @@ -2416,19 +2417,19 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_sentinel(_InputIterator _
__rep_ = __rep();
__annotate_new(0);

#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
for (; __first != __last; ++__first)
push_back(*__first);
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
__annotate_delete();
if (__is_long())
__alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
throw;
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
}

template <class _CharT, class _Traits, class _Allocator>
Expand Down Expand Up @@ -2463,18 +2464,18 @@ basic_string<_CharT, _Traits, _Allocator>::__init_with_size(_InputIterator __fir
__set_long_size(__sz);
}

#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
auto __end = __copy_non_overlapping_range(__first, __last, std::__to_address(__p));
traits_type::assign(*__end, value_type());
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
if (__is_long())
__alloc_traits::deallocate(__alloc_, __get_long_pointer(), __get_long_cap());
throw;
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
__annotate_new(__sz);
}

Expand Down Expand Up @@ -3376,9 +3377,9 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
// Shrink
// - called from shrink_to_fit should not throw.
// - called from reserve may throw but is not required to.
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
auto __allocation = std::__allocate_at_least(__alloc_, __target_capacity + 1);

// The Standard mandates shrink_to_fit() does not increase the capacity.
Expand All @@ -3391,11 +3392,11 @@ basic_string<_CharT, _Traits, _Allocator>::__shrink_or_extend(size_type __target
}
__new_data = __allocation.ptr;
__target_capacity = __allocation.count - 1;
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
#if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
return;
}
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
#endif // _LIBCPP_HAS_EXCEPTIONS
}
__begin_lifetime(__new_data, __target_capacity + 1);
__now_long = true;
Expand Down Expand Up @@ -4234,7 +4235,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
Expand Down Expand Up @@ -4308,7 +4309,7 @@ operator""s(const wchar_t* __str, size_t __len) {
}
# endif

# ifndef _LIBCPP_HAS_NO_CHAR8_T
# if _LIBCPP_HAS_CHAR8_T
inline _LIBCPP_HIDE_FROM_ABI constexpr basic_string<char8_t> operator""s(const char8_t* __str, size_t __len) {
return basic_string<char8_t>(__str, __len);
}
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/string_view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
16 changes: 8 additions & 8 deletions libcxx/include/syncstream
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,14 @@ public:
}

_LIBCPP_HIDE_FROM_ABI ~basic_syncbuf() {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
try {
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
emit();
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
}
# endif // _LIBCPP_HAS_NO_EXCEPTIONS
# endif // _LIBCPP_HAS_EXCEPTIONS
__dec_reference();
}

Expand Down Expand Up @@ -337,7 +337,7 @@ protected:
return traits_type::not_eof(__c);

if (this->pptr() == this->epptr()) {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
try {
# endif
size_t __size = __str_.size();
Expand All @@ -348,7 +348,7 @@ protected:
this->setp(__p, __p + __str_.size());
this->pbump(__size);

# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
} catch (...) {
return traits_type::eof();
}
Expand Down Expand Up @@ -480,13 +480,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();
}
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/typeinfo
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
72 changes: 36 additions & 36 deletions libcxx/include/valarray
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -2007,35 +2007,35 @@ 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
}
}

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
}
}

Expand All @@ -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
}
}

Expand All @@ -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
}
}

Expand All @@ -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
}
}

Expand All @@ -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
}
}

Expand All @@ -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
}
}

Expand Down Expand Up @@ -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
}
}

Expand Down
6 changes: 3 additions & 3 deletions libcxx/include/variant
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ struct __farray {

[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void
__throw_bad_variant_access() {
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
throw bad_variant_access();
# else
_LIBCPP_VERBOSE_ABORT("bad_variant_access was thrown in -fno-exceptions mode");
Expand Down Expand Up @@ -1062,7 +1062,7 @@ public:
std::swap(__lhs, __rhs);
}
__impl __tmp(std::move(*__rhs));
# ifndef _LIBCPP_HAS_NO_EXCEPTIONS
# if _LIBCPP_HAS_EXCEPTIONS
if constexpr (__all<is_nothrow_move_constructible_v<_Types>...>::value) {
this->__generic_construct(*__rhs, std::move(*__lhs));
} else {
Expand Down Expand Up @@ -1300,7 +1300,7 @@ public:
__impl_.__swap(__that.__impl_);
}

# if _LIBCPP_STD_VER >= 26 && defined(_LIBCPP_HAS_EXPLICIT_THIS_PARAMETER)
# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
// Helper class to implement [variant.visit]/10
// Constraints: The call to visit does not use an explicit template-argument-list
// that begins with a type template-argument.
Expand Down
52 changes: 26 additions & 26 deletions libcxx/include/vector
Original file line number Diff line number Diff line change
Expand Up @@ -917,42 +917,42 @@ 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
}

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_);
}
Expand Down Expand Up @@ -1482,20 +1482,20 @@ _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.
// With equal capacity keep the existing buffer. This avoids extra work
// 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
}
}

Expand Down Expand Up @@ -1733,21 +1733,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()));
Expand Down Expand Up @@ -2190,18 +2190,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>
Expand Down Expand Up @@ -2648,14 +2648,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
}
}

Expand Down Expand Up @@ -2744,21 +2744,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());
Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/modules/std.compat/cuchar.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/modules/std.cppm.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
#include <barrier>
Expand Down
2 changes: 1 addition & 1 deletion libcxx/modules/std/atomic.inc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export namespace std {
using std::atomic_char _LIBCPP_USING_IF_EXISTS;
using std::atomic_char16_t _LIBCPP_USING_IF_EXISTS;
using std::atomic_char32_t _LIBCPP_USING_IF_EXISTS;
#ifndef _LIBCPP_HAS_NO_CHAR8_T
#if _LIBCPP_HAS_CHAR8_T
using std::atomic_char8_t _LIBCPP_USING_IF_EXISTS;
#endif
using std::atomic_int _LIBCPP_USING_IF_EXISTS;
Expand Down
2 changes: 1 addition & 1 deletion libcxx/modules/std/cuchar.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/modules/std/iosfwd.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions libcxx/modules/std/memory.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions libcxx/modules/std/string.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/modules/std/string_view.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/condition_variable_destructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions libcxx/src/filesystem/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
}
Expand All @@ -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>();
}
Expand Down
8 changes: 4 additions & 4 deletions libcxx/src/filesystem/format_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/filesystem/int128_builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions libcxx/src/future.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
8 changes: 4 additions & 4 deletions libcxx/src/ios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
38 changes: 19 additions & 19 deletions libcxx/src/locale.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand All @@ -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
Expand All @@ -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_) {
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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>
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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>

Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions libcxx/src/memory_resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/mutex_destructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions libcxx/src/new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -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[])),
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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[])),
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion libcxx/src/new_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions libcxx/src/ostream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/ryu/d2s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/stdexcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions libcxx/src/support/runtime/exception_fallback.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
8 changes: 4 additions & 4 deletions libcxx/src/support/runtime/exception_msvc.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion libcxx/src/system_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static_assert(!std::__libcpp_is_trivially_relocatable<std::array<NotTriviallyCop
static_assert(std::__libcpp_is_trivially_relocatable<std::array<std::unique_ptr<int>, 1> >::value, "");

// basic_string
#if defined(_LIBCPP_HAS_NO_ASAN) || !defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
#if !_LIBCPP_HAS_ASAN || !defined(_LIBCPP_INSTRUMENTED_WITH_ASAN)
struct MyChar {
char c;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{{.*}}}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,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>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#if !defined(TEST_HAS_NO_CHAR8_T)
using U = decltype(::c8rtomb);
using V = decltype(::mbrtoc8);
# if defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8)
# if !_LIBCPP_HAS_C8RTOMB_MBRTOC8
// expected-error@-3 {{no member named 'c8rtomb' in the global namespace}}
// expected-error@-3 {{no member named 'mbrtoc8' in the global namespace}}
# else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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{|}~")
Expand Down
18 changes: 9 additions & 9 deletions libcxx/test/support/test_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@
#define TEST_IS_EXECUTED_IN_A_SLOW_ENVIRONMENT
#endif

#if defined(_LIBCPP_HAS_NO_ALIGNED_ALLOCATION) || \
(!(TEST_STD_VER > 14 || \
(defined(__cpp_aligned_new) && __cpp_aligned_new >= 201606L)))
#define TEST_HAS_NO_ALIGNED_ALLOCATION
#if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_ALIGNED_ALLOCATION
# define TEST_HAS_NO_ALIGNED_ALLOCATION
#elif TEST_STD_VER < 17 && (!defined(__cpp_aligned_new) || __cpp_aligned_new < 201606L)
# define TEST_HAS_NO_ALIGNED_ALLOCATION
#endif

#if TEST_STD_VER > 17
Expand Down Expand Up @@ -397,12 +397,12 @@ inline Tp const& DoNotOptimize(Tp const& value) {
# define TEST_HAS_NO_UNICODE
#endif

#if defined(_LIBCPP_HAS_OPEN_WITH_WCHAR)
#if defined(_LIBCPP_VERSION) && _LIBCPP_HAS_OPEN_WITH_WCHAR
# define TEST_HAS_OPEN_WITH_WCHAR
#endif

#if defined(_LIBCPP_HAS_NO_INT128) || defined(_MSVC_STL_VERSION)
# define TEST_HAS_NO_INT128
#if (defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_INT128) || defined(_MSVC_STL_VERSION)
# define TEST_HAS_NO_INT128
#endif

#if defined(_LIBCPP_HAS_NO_LOCALIZATION)
Expand All @@ -421,7 +421,7 @@ inline Tp const& DoNotOptimize(Tp const& value) {
# define TEST_HAS_NO_FILESYSTEM
#endif

#if defined(_LIBCPP_HAS_NO_C8RTOMB_MBRTOC8)
#if defined(_LIBCPP_VERSION) && !_LIBCPP_HAS_C8RTOMB_MBRTOC8
# define TEST_HAS_NO_C8RTOMB_MBRTOC8
#endif

Expand Down Expand Up @@ -495,7 +495,7 @@ inline Tp const& DoNotOptimize(Tp const& value) {
#endif

// Clang-18 has support for deducing this, but it does not set the FTM.
#ifdef _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
#if defined(_LIBCPP_VERSION) && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
# define TEST_HAS_EXPLICIT_THIS_PARAMETER
#endif

Expand Down
1 change: 1 addition & 0 deletions libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ set(SOURCES
abi_tag_on_virtual.cpp
header_exportable_declarations.cpp
hide_from_abi.cpp
internal_ftm_use.cpp
proper_version_checks.cpp
qualify_declval.cpp
robust_against_adl.cpp
Expand Down
109 changes: 109 additions & 0 deletions libcxx/test/tools/clang_tidy_checks/internal_ftm_use.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

// This clang-tidy check ensures that we don't use any _LIBCPP_HAS_FOO macro
// inside `#ifdef`, `#ifndef` & friends, since the intent is to always use `#if` instead.

#include "internal_ftm_use.hpp"

#include <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_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS",

// Testing macros
"_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER",

// TODO: Why does this macro even exist?
"_LIBCPP_HAS_NO_TREE_BARRIER",

// Configuration macros
"_LIBCPP_HAS_NO_TIME_ZONE_DATABASE",
"_LIBCPP_HAS_NO_FILESYSTEM",
"_LIBCPP_HAS_NO_LOCALIZATION",
"_LIBCPP_HAS_NO_THREADS",
"_LIBCPP_HAS_NO_MONOTONIC_CLOCK",
"_LIBCPP_HAS_MUSL_LIBC",
"_LIBCPP_HAS_NO_WIDE_CHARACTERS",
"_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS",
"_LIBCPP_HAS_NO_RANDOM_DEVICE",
"_LIBCPP_HAS_NO_UNICODE",
"_LIBCPP_HAS_NO_TERMINAL",

// Atomic API macros
"_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP",
"_LIBCPP_HAS_GCC_ATOMIC_IMP",
"_LIBCPP_HAS_C_ATOMIC_IMP",

// Thread API macros
"_LIBCPP_HAS_THREAD_API_PTHREAD",
"_LIBCPP_HAS_THREAD_API_WIN32",
"_LIBCPP_HAS_THREAD_API_EXTERNAL",
"_LIBCPP_HAS_THREAD_API_C11",

// Experimental features
"_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB",
"_LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM",
"_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN",
"_LIBCPP_HAS_NO_INCOMPLETE_PSTL",
};

class internal_ftm_use_callbacks : public clang::PPCallbacks {
public:
internal_ftm_use_callbacks(clang::tidy::ClangTidyCheck& check) : check_(check) {}

void Defined(const clang::Token& token,
const clang::MacroDefinition& macro_definition,
clang::SourceRange location) override {
check_macro(token.getIdentifierInfo()->getName(), location.getBegin());
}

void Ifdef(clang::SourceLocation location, const clang::Token& token, const clang::MacroDefinition&) override {
check_macro(token.getIdentifierInfo()->getName(), location);
}

void Elifdef(clang::SourceLocation location, const clang::Token& token, const clang::MacroDefinition&) override {
check_macro(token.getIdentifierInfo()->getName(), location);
}

void Ifndef(clang::SourceLocation location, const clang::Token& token, const clang::MacroDefinition&) override {
check_macro(token.getIdentifierInfo()->getName(), location);
}

void Elifndef(clang::SourceLocation location, const clang::Token& token, const clang::MacroDefinition&) override {
check_macro(token.getIdentifierInfo()->getName(), location);
}

private:
void check_macro(std::string_view macro, clang::SourceLocation location) {
if (macro.starts_with("_LIBCPP_HAS_") && std::ranges::find(valid_macros, macro) == valid_macros.end()) {
check_.diag(location, std::string("\'") + std::string{macro} + "' is always defined to 1 or 0.");
}
}

clang::tidy::ClangTidyCheck& check_;
};
} // namespace

internal_ftm_use::internal_ftm_use(llvm::StringRef name, clang::tidy::ClangTidyContext* context)
: clang::tidy::ClangTidyCheck(name, context) {}

void internal_ftm_use::registerPPCallbacks(const clang::SourceManager& source_manager,
clang::Preprocessor* preprocessor,
clang::Preprocessor* module_expander) {
preprocessor->addPPCallbacks(std::make_unique<internal_ftm_use_callbacks>(*this));
}

} // namespace libcpp
19 changes: 19 additions & 0 deletions libcxx/test/tools/clang_tidy_checks/internal_ftm_use.hpp
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions libcxx/test/tools/clang_tidy_checks/libcpp_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion libcxx/utils/generate_feature_test_macro_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions libcxx/utils/libcxx/header_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
4 changes: 2 additions & 2 deletions libcxxabi/src/fallback_malloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void* __aligned_malloc_with_fallback(size_t size) {
#if defined(_WIN32)
if (void* dest = std::__libcpp_aligned_alloc(alignof(__aligned_type), size))
return dest;
#elif defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
#elif !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
if (void* dest = ::malloc(size))
return dest;
#else
Expand All @@ -286,7 +286,7 @@ void __aligned_free_with_fallback(void* ptr) {
if (is_fallback_ptr(ptr))
fallback_free(ptr);
else {
#if defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
#if !_LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
::free(ptr);
#else
std::__libcpp_aligned_free(ptr);
Expand Down
16 changes: 8 additions & 8 deletions libcxxabi/src/stdlib_new_delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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[])),
Expand Down Expand Up @@ -134,7 +134,7 @@ _LIBCPP_WEAK void operator delete[](void* ptr, const std::nothrow_t&) noexcept {

_LIBCPP_WEAK void operator delete[](void* ptr, size_t) noexcept { ::operator delete[](ptr); }

#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION)
#if _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION

static void* operator_new_aligned_impl(std::size_t size, std::align_val_t alignment) {
if (size == 0)
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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[])),
Expand Down Expand Up @@ -240,5 +240,5 @@ _LIBCPP_WEAK void operator delete[](void* ptr, size_t, std::align_val_t alignmen
::operator delete[](ptr, alignment);
}

#endif // !_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
#endif // _LIBCPP_HAS_LIBRARY_ALIGNED_ALLOCATION
// ------------------ END COPY ------------------