summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/exception
diff options
context:
space:
mode:
authorarmenqa <[email protected]>2024-01-19 12:23:50 +0300
committerarmenqa <[email protected]>2024-01-19 13:10:03 +0300
commit2de0149d0151c514b22bca0760b95b26c9b0b578 (patch)
tree2bfed9f3bce7e643ddf048bb61ce3dc0a714bcc2 /contrib/libs/cxxsupp/libcxx/include/exception
parenta8c06d218f12b2406fbce24d194885c5d7b68503 (diff)
feat contrib: aiogram 3
Relates: https://st.yandex-team.ru/, https://st.yandex-team.ru/
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/exception')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/exception74
1 files changed, 59 insertions, 15 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/exception b/contrib/libs/cxxsupp/libcxx/include/exception
index f8a00833f72..2d37d7ab091 100644
--- a/contrib/libs/cxxsupp/libcxx/include/exception
+++ b/contrib/libs/cxxsupp/libcxx/include/exception
@@ -85,8 +85,10 @@ template <class E> void rethrow_if_nested(const E& e);
#include <type_traits>
#include <version>
+// <vcruntime_exception.h> defines its own std::exception and std::bad_exception types,
+// which we use in order to be ABI-compatible with other STLs on Windows.
#if defined(_LIBCPP_ABI_VCRUNTIME)
-#include <vcruntime_exception.h>
+# include <vcruntime_exception.h>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -96,24 +98,66 @@ template <class E> void rethrow_if_nested(const E& e);
namespace std // purposefully not using versioning namespace
{
-#if !defined(_LIBCPP_ABI_VCRUNTIME)
-class _LIBCPP_EXCEPTION_ABI exception
-{
+#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
+// The std::exception class was already included above, but we're explicit about this condition here for clarity.
+
+#elif defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
+// However, <vcruntime_exception.h> does not define std::exception and std::bad_exception
+// when _HAS_EXCEPTIONS == 0.
+//
+// Since libc++ still wants to provide the std::exception hierarchy even when _HAS_EXCEPTIONS == 0
+// (after all those are simply types like any other), we define an ABI-compatible version
+// of the VCRuntime std::exception and std::bad_exception types in that mode.
+
+struct __std_exception_data {
+ char const* _What;
+ bool _DoFree;
+};
+
+class exception { // base of all library exceptions
public:
- _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
- _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;
+ exception() _NOEXCEPT : __data_() {}
+
+ explicit exception(char const* __message) _NOEXCEPT : __data_() {
+ __data_._What = __message;
+ __data_._DoFree = true;
+ }
+
+ exception(exception const&) _NOEXCEPT {}
+
+ exception& operator=(exception const&) _NOEXCEPT { return *this; }
+
+ virtual ~exception() _NOEXCEPT {}
+
+ virtual char const* what() const _NOEXCEPT { return __data_._What ? __data_._What : "Unknown exception"; }
- virtual ~exception() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+private:
+ __std_exception_data __data_;
};
-class _LIBCPP_EXCEPTION_ABI bad_exception
- : public exception
-{
+class bad_exception : public exception {
+public:
+ bad_exception() _NOEXCEPT : exception("bad exception") {}
+};
+
+#else // !defined(_LIBCPP_ABI_VCRUNTIME)
+// On all other platforms, we define our own std::exception and std::bad_exception types
+// regardless of whether exceptions are turned on as a language feature.
+
+class _LIBCPP_EXCEPTION_ABI exception {
+public:
+ _LIBCPP_INLINE_VISIBILITY exception() _NOEXCEPT {}
+ _LIBCPP_INLINE_VISIBILITY exception(const exception&) _NOEXCEPT = default;
+
+ virtual ~exception() _NOEXCEPT;
+ virtual const char* what() const _NOEXCEPT;
+};
+
+class _LIBCPP_EXCEPTION_ABI bad_exception : public exception {
public:
- _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}
- virtual ~bad_exception() _NOEXCEPT;
- virtual const char* what() const _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY bad_exception() _NOEXCEPT {}
+ ~bad_exception() _NOEXCEPT override;
+ const char* what() const _NOEXCEPT override;
};
#endif // !_LIBCPP_ABI_VCRUNTIME
@@ -261,7 +305,7 @@ struct __throw_with_nested<_Tp, _Up, false> {
#endif
template <class _Tp>
-_LIBCPP_NORETURN
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI
void
throw_with_nested(_Tp&& __t)
{