[libcxx-commits] [libcxx] [libc++] Remove availability annotations which can't fire anymore (PR #140049)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Fri May 30 16:16:23 PDT 2025
https://github.com/philnik777 updated https://github.com/llvm/llvm-project/pull/140049
>From f76642b1e1d080947d8cbe1f33a4ac9e6d944ac1 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 15 May 2025 14:44:39 +0200
Subject: [PATCH] [libc++] Remove availability annotations which can't fire
anymore
---
libcxx/include/__configuration/availability.h | 41 ----------------
libcxx/include/__fwd/variant.h | 25 ++++------
libcxx/include/any | 11 ++---
libcxx/include/optional | 27 +++++------
libcxx/include/variant | 47 +++++++------------
libcxx/src/any.cpp | 2 +-
libcxx/src/optional.cpp | 2 +-
libcxx/test/support/any_helpers.h | 28 +++++------
.../test/support/msvc_stdlib_force_include.h | 2 -
9 files changed, 56 insertions(+), 129 deletions(-)
diff --git a/libcxx/include/__configuration/availability.h b/libcxx/include/__configuration/availability.h
index bbcdfdc784e9d..ae58e36b508b4 100644
--- a/libcxx/include/__configuration/availability.h
+++ b/libcxx/include/__configuration/availability.h
@@ -116,9 +116,6 @@
# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_PUSH /* nothing */
# define _LIBCPP_INTRODUCED_IN_LLVM_9_ATTRIBUTE_POP /* nothing */
-# define _LIBCPP_INTRODUCED_IN_LLVM_4 1
-# define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE /* nothing */
-
#elif defined(__APPLE__)
// clang-format off
@@ -258,14 +255,6 @@
_Pragma("clang attribute pop") \
_Pragma("clang attribute pop")
-// LLVM 4
-# if defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 50000
-# define _LIBCPP_INTRODUCED_IN_LLVM_4 0
-# else
-# define _LIBCPP_INTRODUCED_IN_LLVM_4 1
-# endif
-# define _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE __attribute__((availability(watchos, strict, introduced = 5.0)))
-
// clang-format on
#else
@@ -277,23 +266,6 @@
#endif
-// These macros control the availability of std::bad_optional_access and
-// other exception types. These were put in the shared library to prevent
-// code bloat from every user program defining the vtable for these exception
-// types.
-//
-// Note that when exceptions are disabled, the methods that normally throw
-// these exceptions can be used even on older deployment targets, but those
-// methods will abort instead of throwing.
-#define _LIBCPP_AVAILABILITY_HAS_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4
-#define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
-
-#define _LIBCPP_AVAILABILITY_HAS_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4
-#define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
-
-#define _LIBCPP_AVAILABILITY_HAS_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4
-#define _LIBCPP_AVAILABILITY_BAD_ANY_CAST _LIBCPP_INTRODUCED_IN_LLVM_4_ATTRIBUTE
-
// These macros control the availability of all parts of <filesystem> that
// depend on something in the dylib.
#define _LIBCPP_AVAILABILITY_HAS_FILESYSTEM_LIBRARY _LIBCPP_INTRODUCED_IN_LLVM_9
@@ -383,19 +355,6 @@
#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21
// No attribute, since we've had bad_function_call::what() in the headers before
-// Define availability attributes that depend on _LIBCPP_HAS_EXCEPTIONS.
-// Those are defined in terms of the availability attributes above, and
-// should not be vendor-specific.
-#if !_LIBCPP_HAS_EXCEPTIONS
-# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS
-# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS
-#else
-# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST
-# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS
-# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
-#endif
-
// Define availability attributes that depend on both
// _LIBCPP_HAS_EXCEPTIONS and _LIBCPP_HAS_RTTI.
#if !_LIBCPP_HAS_EXCEPTIONS || !_LIBCPP_HAS_RTTI
diff --git a/libcxx/include/__fwd/variant.h b/libcxx/include/__fwd/variant.h
index 3808268df1744..fef7071b32646 100644
--- a/libcxx/include/__fwd/variant.h
+++ b/libcxx/include/__fwd/variant.h
@@ -38,37 +38,28 @@ using variant_alternative_t = typename variant_alternative<_Ip, _Tp>::type;
inline constexpr size_t variant_npos = static_cast<size_t>(-1);
template <size_t _Ip, class... _Types>
-_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&
-get(variant<_Types...>&);
+_LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(variant<_Types...>&);
template <size_t _Ip, class... _Types>
-_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&&
-get(variant<_Types...>&&);
+_LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(variant<_Types...>&&);
template <size_t _Ip, class... _Types>
-_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
-get(const variant<_Types...>&);
+_LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>& get(const variant<_Types...>&);
template <size_t _Ip, class... _Types>
-_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
-get(const variant<_Types...>&&);
+_LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&& get(const variant<_Types...>&&);
template <class _Tp, class... _Types>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>&);
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(variant<_Types...>&);
template <class _Tp, class... _Types>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&&);
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(variant<_Types...>&&);
template <class _Tp, class... _Types>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp& get(const variant<_Types...>&);
+_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>&);
template <class _Tp, class... _Types>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&&
-get(const variant<_Types...>&&);
+_LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&&);
#endif // _LIBCPP_STD_VER >= 17
diff --git a/libcxx/include/any b/libcxx/include/any
index 8ab16882d4b0f..e4c31b08f4a21 100644
--- a/libcxx/include/any
+++ b/libcxx/include/any
@@ -120,8 +120,7 @@ _LIBCPP_PUSH_MACROS
# include <__undef_macros>
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
-class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast {
+class _LIBCPP_EXPORTED_FROM_ABI bad_any_cast : public bad_cast {
public:
const char* what() const _NOEXCEPT override;
};
@@ -132,7 +131,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
# if _LIBCPP_STD_VER >= 17
-[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST void __throw_bad_any_cast() {
+[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_any_cast() {
# if _LIBCPP_HAS_EXCEPTIONS
throw bad_any_cast();
# else
@@ -521,7 +520,7 @@ inline _LIBCPP_HIDE_FROM_ABI any make_any(initializer_list<_Up> __il, _Args&&...
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any const& __v) {
+inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any const& __v) {
using _RawValueType = __remove_cvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType const&>::value,
"ValueType is required to be a const lvalue reference "
@@ -533,7 +532,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any& __v) {
+inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any& __v) {
using _RawValueType = __remove_cvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType&>::value,
"ValueType is required to be an lvalue reference "
@@ -545,7 +544,7 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _ValueType any_cast(any&& __v) {
+inline _LIBCPP_HIDE_FROM_ABI _ValueType any_cast(any&& __v) {
using _RawValueType = __remove_cvref_t<_ValueType>;
static_assert(is_constructible<_ValueType, _RawValueType>::value,
"ValueType is required to be an rvalue reference "
diff --git a/libcxx/include/optional b/libcxx/include/optional
index b60ddb91ce5d6..d791f2d0b68a0 100644
--- a/libcxx/include/optional
+++ b/libcxx/include/optional
@@ -247,7 +247,7 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
-class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public exception {
+class _LIBCPP_EXPORTED_FROM_ABI bad_optional_access : public exception {
public:
_LIBCPP_HIDE_FROM_ABI bad_optional_access() _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_optional_access(const bad_optional_access&) _NOEXCEPT = default;
@@ -264,8 +264,7 @@ _LIBCPP_END_UNVERSIONED_NAMESPACE_STD
_LIBCPP_BEGIN_NAMESPACE_STD
-[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS void
-__throw_bad_optional_access() {
+[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_optional_access() {
# if _LIBCPP_HAS_EXCEPTIONS
throw bad_optional_access();
# else
@@ -828,25 +827,25 @@ public:
using __base::__get;
using __base::has_value;
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type const& value() const& {
+ _LIBCPP_HIDE_FROM_ABI constexpr value_type const& value() const& {
if (!this->has_value())
std::__throw_bad_optional_access();
return this->__get();
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type& value() & {
+ _LIBCPP_HIDE_FROM_ABI constexpr value_type& value() & {
if (!this->has_value())
std::__throw_bad_optional_access();
return this->__get();
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type&& value() && {
+ _LIBCPP_HIDE_FROM_ABI constexpr value_type&& value() && {
if (!this->has_value())
std::__throw_bad_optional_access();
return std::move(this->__get());
}
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr value_type const&& value() const&& {
+ _LIBCPP_HIDE_FROM_ABI constexpr value_type const&& value() const&& {
if (!this->has_value())
std::__throw_bad_optional_access();
return std::move(this->__get());
@@ -868,7 +867,7 @@ public:
# if _LIBCPP_STD_VER >= 23
template <class _Func>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) & {
+ _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) & {
using _Up = invoke_result_t<_Func, value_type&>;
static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
"Result of f(value()) must be a specialization of std::optional");
@@ -878,7 +877,7 @@ public:
}
template <class _Func>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) const& {
+ _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) const& {
using _Up = invoke_result_t<_Func, const value_type&>;
static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
"Result of f(value()) must be a specialization of std::optional");
@@ -888,7 +887,7 @@ public:
}
template <class _Func>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto and_then(_Func&& __f) && {
+ _LIBCPP_HIDE_FROM_ABI constexpr auto and_then(_Func&& __f) && {
using _Up = invoke_result_t<_Func, value_type&&>;
static_assert(__is_std_optional<remove_cvref_t<_Up>>::value,
"Result of f(std::move(value())) must be a specialization of std::optional");
@@ -908,7 +907,7 @@ public:
}
template <class _Func>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) & {
+ _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) & {
using _Up = remove_cv_t<invoke_result_t<_Func, value_type&>>;
static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");
@@ -920,7 +919,7 @@ public:
}
template <class _Func>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) const& {
+ _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const& {
using _Up = remove_cv_t<invoke_result_t<_Func, const value_type&>>;
static_assert(!is_array_v<_Up>, "Result of f(value()) should not be an Array");
static_assert(!is_same_v<_Up, in_place_t>, "Result of f(value()) should not be std::in_place_t");
@@ -932,7 +931,7 @@ public:
}
template <class _Func>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) && {
+ _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) && {
using _Up = remove_cv_t<invoke_result_t<_Func, value_type&&>>;
static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t");
@@ -944,7 +943,7 @@ public:
}
template <class _Func>
- _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS constexpr auto transform(_Func&& __f) const&& {
+ _LIBCPP_HIDE_FROM_ABI constexpr auto transform(_Func&& __f) const&& {
using _Up = remove_cvref_t<invoke_result_t<_Func, const value_type&&>>;
static_assert(!is_array_v<_Up>, "Result of f(std::move(value())) should not be an Array");
static_assert(!is_same_v<_Up, in_place_t>, "Result of f(std::move(value())) should not be std::in_place_t");
diff --git a/libcxx/include/variant b/libcxx/include/variant
index bf611aec704ca..a306c15d78dde 100644
--- a/libcxx/include/variant
+++ b/libcxx/include/variant
@@ -285,8 +285,8 @@ _LIBCPP_PUSH_MACROS
# include <__undef_macros>
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
-_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
-class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS bad_variant_access : public exception {
+
+class _LIBCPP_EXPORTED_FROM_ABI bad_variant_access : public exception {
public:
const char* what() const _NOEXCEPT override;
};
@@ -307,8 +307,7 @@ struct __farray {
_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& operator[](size_t __n) const noexcept { return __buf_[__n]; }
};
-[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS void
-__throw_bad_variant_access() {
+[[noreturn]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_variant_access() {
# if _LIBCPP_HAS_EXCEPTIONS
throw bad_variant_access();
# else
@@ -1142,16 +1141,14 @@ using __best_match_t _LIBCPP_NODEBUG = typename invoke_result_t<_MakeOverloads<_
} // namespace __variant_detail
template <class _Visitor, class... _Vs, typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto)
-visit(_Visitor&& __visitor, _Vs&&... __vs);
+_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs);
# if _LIBCPP_STD_VER >= 20
template <class _Rp,
class _Visitor,
class... _Vs,
typename = void_t<decltype(std::__as_variant(std::declval<_Vs>()))...>>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp
-visit(_Visitor&& __visitor, _Vs&&... __vs);
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs);
# endif
template <class... _Types>
@@ -1338,7 +1335,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool holds_alternative(const variant<_Types...>&
}
template <size_t _Ip, class _Vp>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr auto&& __generic_get(_Vp&& __v) {
+_LIBCPP_HIDE_FROM_ABI constexpr auto&& __generic_get(_Vp&& __v) {
using __variant_detail::__access::__variant;
if (!std::__holds_alternative<_Ip>(__v)) {
std::__throw_bad_variant_access();
@@ -1347,26 +1344,21 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr au
}
template <size_t _Ip, class... _Types>
-_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&
-get(variant<_Types...>& __v) {
+_LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>& get(variant<_Types...>& __v) {
static_assert(_Ip < sizeof...(_Types));
static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
return std::__generic_get<_Ip>(__v);
}
template <size_t _Ip, class... _Types>
-_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr variant_alternative_t<_Ip, variant<_Types...>>&&
-get(variant<_Types...>&& __v) {
+_LIBCPP_HIDE_FROM_ABI constexpr variant_alternative_t<_Ip, variant<_Types...>>&& get(variant<_Types...>&& __v) {
static_assert(_Ip < sizeof...(_Types));
static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
return std::__generic_get<_Ip>(std::move(__v));
}
template <size_t _Ip, class... _Types>
-_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
+_LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&
get(const variant<_Types...>& __v) {
static_assert(_Ip < sizeof...(_Types));
static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
@@ -1374,8 +1366,7 @@ get(const variant<_Types...>& __v) {
}
template <size_t _Ip, class... _Types>
-_LIBCPP_HIDE_FROM_ABI
-_LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
+_LIBCPP_HIDE_FROM_ABI constexpr const variant_alternative_t<_Ip, variant<_Types...>>&&
get(const variant<_Types...>&& __v) {
static_assert(_Ip < sizeof...(_Types));
static_assert(!is_void_v<variant_alternative_t<_Ip, variant<_Types...>>>);
@@ -1383,27 +1374,25 @@ get(const variant<_Types...>&& __v) {
}
template <class _Tp, class... _Types>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp& get(variant<_Types...>& __v) {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp& get(variant<_Types...>& __v) {
static_assert(!is_void_v<_Tp>);
return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
}
template <class _Tp, class... _Types>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Tp&& get(variant<_Types...>&& __v) {
+_LIBCPP_HIDE_FROM_ABI constexpr _Tp&& get(variant<_Types...>&& __v) {
static_assert(!is_void_v<_Tp>);
return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v));
}
template <class _Tp, class... _Types>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&
-get(const variant<_Types...>& __v) {
+_LIBCPP_HIDE_FROM_ABI constexpr const _Tp& get(const variant<_Types...>& __v) {
static_assert(!is_void_v<_Tp>);
return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(__v);
}
template <class _Tp, class... _Types>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr const _Tp&&
-get(const variant<_Types...>&& __v) {
+_LIBCPP_HIDE_FROM_ABI constexpr const _Tp&& get(const variant<_Types...>&& __v) {
static_assert(!is_void_v<_Tp>);
return std::get<__find_exactly_one_t<_Tp, _Types...>::value>(std::move(__v));
}
@@ -1551,7 +1540,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool operator>=(const variant<_Types...>& __lhs,
}
template <class... _Vs>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr void __throw_if_valueless(_Vs&&... __vs) {
+_LIBCPP_HIDE_FROM_ABI constexpr void __throw_if_valueless(_Vs&&... __vs) {
const bool __valueless = (... || std::__as_variant(__vs).valueless_by_exception());
if (__valueless) {
std::__throw_bad_variant_access();
@@ -1559,8 +1548,7 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr vo
}
template < class _Visitor, class... _Vs, typename>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr decltype(auto)
-visit(_Visitor&& __visitor, _Vs&&... __vs) {
+_LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) visit(_Visitor&& __visitor, _Vs&&... __vs) {
using __variant_detail::__visitation::__variant;
std::__throw_if_valueless(std::forward<_Vs>(__vs)...);
return __variant::__visit_value(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
@@ -1568,8 +1556,7 @@ visit(_Visitor&& __visitor, _Vs&&... __vs) {
# if _LIBCPP_STD_VER >= 20
template < class _Rp, class _Visitor, class... _Vs, typename>
-_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS constexpr _Rp
-visit(_Visitor&& __visitor, _Vs&&... __vs) {
+_LIBCPP_HIDE_FROM_ABI constexpr _Rp visit(_Visitor&& __visitor, _Vs&&... __vs) {
using __variant_detail::__visitation::__variant;
std::__throw_if_valueless(std::forward<_Vs>(__vs)...);
return __variant::__visit_value<_Rp>(std::forward<_Visitor>(__visitor), std::forward<_Vs>(__vs)...);
diff --git a/libcxx/src/any.cpp b/libcxx/src/any.cpp
index 8f7e88498abbf..f95a701a416ab 100644
--- a/libcxx/src/any.cpp
+++ b/libcxx/src/any.cpp
@@ -19,7 +19,7 @@ const char* bad_any_cast::what() const noexcept { return "bad any cast"; }
_LIBCPP_BEGIN_NAMESPACE_LFTS
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
-class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast {
+class _LIBCPP_EXPORTED_FROM_ABI bad_any_cast : public bad_cast {
public:
virtual const char* what() const noexcept;
};
diff --git a/libcxx/src/optional.cpp b/libcxx/src/optional.cpp
index cbf29b6202116..d1c78077069e7 100644
--- a/libcxx/src/optional.cpp
+++ b/libcxx/src/optional.cpp
@@ -24,7 +24,7 @@ const char* bad_optional_access::what() const noexcept { return "bad_optional_ac
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
_LIBCPP_BEGIN_EXPLICIT_ABI_ANNOTATIONS
-class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public std::logic_error {
+class _LIBCPP_EXPORTED_FROM_ABI bad_optional_access : public std::logic_error {
public:
bad_optional_access() : std::logic_error("Bad optional Access") {}
diff --git a/libcxx/test/support/any_helpers.h b/libcxx/test/support/any_helpers.h
index dae3ca3c90f58..0e5563142d58a 100644
--- a/libcxx/test/support/any_helpers.h
+++ b/libcxx/test/support/any_helpers.h
@@ -66,32 +66,26 @@ template <class> constexpr bool has_value_member(long) { return false; }
// Assert that an 'any' object stores the specified 'Type' and 'value'.
template <class Type>
-std::enable_if_t<has_value_member<Type>(0)>
-_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-assertContains(std::any const& a, int value) {
- assert(a.has_value());
- assert(containsType<Type>(a));
- assert(std::any_cast<Type const &>(a).value == value);
+std::enable_if_t<has_value_member<Type>(0)> assertContains(std::any const& a, int value) {
+ assert(a.has_value());
+ assert(containsType<Type>(a));
+ assert(std::any_cast<Type const&>(a).value == value);
}
template <class Type, class Value>
-std::enable_if_t<!has_value_member<Type>(0)>
-_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-assertContains(std::any const& a, Value value) {
- assert(a.has_value());
- assert(containsType<Type>(a));
- assert(std::any_cast<Type const &>(a) == value);
+std::enable_if_t<!has_value_member<Type>(0)> assertContains(std::any const& a, Value value) {
+ assert(a.has_value());
+ assert(containsType<Type>(a));
+ assert(std::any_cast<Type const&>(a) == value);
}
-
// Modify the value of a "test type" stored within an any to the specified
// 'value'.
template <class Type>
-_LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
void modifyValue(std::any& a, int value) {
- assert(a.has_value());
- assert(containsType<Type>(a));
- std::any_cast<Type&>(a).value = value;
+ assert(a.has_value());
+ assert(containsType<Type>(a));
+ std::any_cast<Type&>(a).value = value;
}
// A test type that will trigger the small object optimization within 'any'.
diff --git a/libcxx/test/support/msvc_stdlib_force_include.h b/libcxx/test/support/msvc_stdlib_force_include.h
index 785670224c3b1..2ea449c962cb4 100644
--- a/libcxx/test/support/msvc_stdlib_force_include.h
+++ b/libcxx/test/support/msvc_stdlib_force_include.h
@@ -102,6 +102,4 @@ const AssertionDialogAvoider assertion_dialog_avoider{};
#define TEST_SHORT_WCHAR
#define TEST_ABI_MICROSOFT
-#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
-
#endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H
More information about the libcxx-commits
mailing list