diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2022-09-21 16:58:20 +0300 |
---|---|---|
committer | robot-contrib <robot-contrib@yandex-team.com> | 2022-09-21 16:58:20 +0300 |
commit | 853a53cd31b9b896cf1b3ffab51400cd47622e69 (patch) | |
tree | 8a1ae9dde4c2bb1784908dd2f96aea3ac5e80452 | |
parent | dd4a1b7fd16bc0a3c81046bcc276a899a06f575d (diff) | |
download | ydb-853a53cd31b9b896cf1b3ffab51400cd47622e69.tar.gz |
Update contrib/restricted/boost/throw_exception to 1.80.0
3 files changed, 350 insertions, 130 deletions
diff --git a/contrib/restricted/boost/assert/include/boost/assert/source_location.hpp b/contrib/restricted/boost/assert/include/boost/assert/source_location.hpp index 14dff9ab80..7b09e7cceb 100644 --- a/contrib/restricted/boost/assert/include/boost/assert/source_location.hpp +++ b/contrib/restricted/boost/assert/include/boost/assert/source_location.hpp @@ -75,11 +75,7 @@ public: # pragma warning( disable: 4996 ) #endif -#if ( defined(_MSC_VER) && _MSC_VER < 1900 ) || ( defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) ) # define BOOST_ASSERT_SNPRINTF(buffer, format, arg) std::sprintf(buffer, format, arg) -#else -# define BOOST_ASSERT_SNPRINTF(buffer, format, arg) std::snprintf(buffer, sizeof(buffer)/sizeof(buffer[0]), format, arg) -#endif std::string to_string() const { diff --git a/contrib/restricted/boost/throw_exception/include/boost/exception/exception.hpp b/contrib/restricted/boost/throw_exception/include/boost/exception/exception.hpp index 1dfb22a6b6..ca8d83359a 100644 --- a/contrib/restricted/boost/throw_exception/include/boost/exception/exception.hpp +++ b/contrib/restricted/boost/throw_exception/include/boost/exception/exception.hpp @@ -3,23 +3,34 @@ //Distributed under the Boost Software License, Version 1.0. (See accompanying //file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#ifndef UUID_274DA366004E11DCB1DDFE2E56D89593 -#define UUID_274DA366004E11DCB1DDFE2E56D89593 -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif +#ifndef BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593 +#define BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593 + +#include <boost/assert/source_location.hpp> +#include <boost/config.hpp> +#include <exception> #ifdef BOOST_EXCEPTION_MINI_BOOST #include <memory> namespace boost { namespace exception_detail { using std::shared_ptr; } } #else -namespace boost { template <class T> class shared_ptr; }; +namespace boost { template <class T> class shared_ptr; } namespace boost { namespace exception_detail { using boost::shared_ptr; } } #endif +#if !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) +#if __GNUC__*100+__GNUC_MINOR__>301 +#pragma GCC system_header +#endif +#ifdef __clang__ +#pragma clang system_header +#endif +#ifdef _MSC_VER +#pragma warning(push,1) +#pragma warning(disable: 4265) +#endif +#endif + namespace boost { @@ -97,6 +108,7 @@ boost typedef error_info<struct throw_function_,char const *> throw_function; typedef error_info<struct throw_file_,char const *> throw_file; typedef error_info<struct throw_line_,int> throw_line; + typedef error_info<struct throw_column_,int> throw_column; template <> class @@ -140,17 +152,23 @@ boost } }; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif - class exception; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif + template <> + class + error_info<throw_column_,int> + { + public: + typedef int value_type; + value_type v_; + explicit + error_info( value_type v ): + v_(v) + { + } + }; + + class + BOOST_SYMBOL_VISIBLE + exception; namespace exception_detail @@ -170,7 +188,7 @@ boost protected: - virtual ~error_info_container() + ~error_info_container() BOOST_NOEXCEPT_OR_NOTHROW { } }; @@ -187,6 +205,9 @@ boost template <> struct get_info<throw_line>; + template <> + struct get_info<throw_column>; + template <class> struct set_info_rv; @@ -199,6 +220,9 @@ boost template <> struct set_info_rv<throw_line>; + template <> + struct set_info_rv<throw_column>; + char const * get_diagnostic_information( exception const &, char const * ); void copy_boost_exception( exception *, exception const * ); @@ -214,14 +238,15 @@ boost template <class E> E const & set_info( E const &, throw_line const & ); + + template <class E> + E const & set_info( E const &, throw_column const & ); + + boost::source_location get_exception_throw_location( exception const & ); } -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif class + BOOST_SYMBOL_VISIBLE exception { //<N3757> @@ -235,23 +260,25 @@ boost exception(): throw_function_(0), throw_file_(0), - throw_line_(-1) + throw_line_(-1), + throw_column_(-1) { } #ifdef __HP_aCC //On HP aCC, this protected copy constructor prevents throwing boost::exception. //On all other platforms, the same effect is achieved by the pure virtual destructor. - exception( exception const & x ) noexcept: + exception( exception const & x ) BOOST_NOEXCEPT_OR_NOTHROW: data_(x.data_), throw_function_(x.throw_function_), throw_file_(x.throw_file_), - throw_line_(x.throw_line_) + throw_line_(x.throw_line_), + throw_column_(x.throw_column_) { } #endif - virtual ~exception() + virtual ~exception() BOOST_NOEXCEPT_OR_NOTHROW #ifndef __HP_aCC = 0 //Workaround for HP aCC, =0 incorrectly leads to link errors. #endif @@ -271,37 +298,40 @@ boost template <class E> friend E const & exception_detail::set_info( E const &, throw_line const & ); + template <class E> + friend E const & exception_detail::set_info( E const &, throw_column const & ); + template <class E,class Tag,class T> friend E const & exception_detail::set_info( E const &, error_info<Tag,T> const & ); friend char const * exception_detail::get_diagnostic_information( exception const &, char const * ); + friend boost::source_location exception_detail::get_exception_throw_location( exception const & ); + template <class> friend struct exception_detail::get_info; friend struct exception_detail::get_info<throw_function>; friend struct exception_detail::get_info<throw_file>; friend struct exception_detail::get_info<throw_line>; + friend struct exception_detail::get_info<throw_column>; template <class> friend struct exception_detail::set_info_rv; friend struct exception_detail::set_info_rv<throw_function>; friend struct exception_detail::set_info_rv<throw_file>; friend struct exception_detail::set_info_rv<throw_line>; + friend struct exception_detail::set_info_rv<throw_column>; friend void exception_detail::copy_boost_exception( exception *, exception const * ); #endif mutable exception_detail::refcount_ptr<exception_detail::error_info_container> data_; mutable char const * throw_function_; mutable char const * throw_file_; mutable int throw_line_; + mutable int throw_column_; }; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif inline exception:: - ~exception() + ~exception() BOOST_NOEXCEPT_OR_NOTHROW { } @@ -331,6 +361,42 @@ boost x.throw_line_=y.v_; return x; } + + template <class E> + E const & + set_info( E const & x, throw_column const & y ) + { + x.throw_column_=y.v_; + return x; + } + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + + template <> + struct + set_info_rv<throw_column> + { + template <class E> + static + E const & + set( E const & x, throw_column && y ) + { + x.throw_column_=y.v_; + return x; + } + }; + +#endif + + inline boost::source_location get_exception_throw_location( exception const & x ) + { + return boost::source_location( + x.throw_file_? x.throw_file_: "", + x.throw_line_ >= 0? x.throw_line_: 0, + x.throw_function_? x.throw_function_: "", + x.throw_column_ >= 0? x.throw_column_: 0 + ); + } } //////////////////////////////////////////////////////////////////////// @@ -338,13 +404,9 @@ boost namespace exception_detail { -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif template <class T> struct + BOOST_SYMBOL_VISIBLE error_info_injector: public T, public exception @@ -355,15 +417,10 @@ boost { } - ~error_info_injector() + ~error_info_injector() BOOST_NOEXCEPT_OR_NOTHROW { } }; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif struct large_size { char c[256]; }; large_size dispatch_boost_exception( exception const * ); @@ -407,16 +464,15 @@ boost } //////////////////////////////////////////////////////////////////////// +#if defined(BOOST_NO_EXCEPTIONS) + BOOST_NORETURN void throw_exception(std::exception const & e); // user defined +#endif namespace exception_detail { -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif class + BOOST_SYMBOL_VISIBLE clone_base { public: @@ -425,15 +481,10 @@ boost virtual void rethrow() const = 0; virtual - ~clone_base() + ~clone_base() BOOST_NOEXCEPT_OR_NOTHROW { } }; -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif inline void @@ -445,6 +496,7 @@ boost a->throw_file_ = b->throw_file_; a->throw_line_ = b->throw_line_; a->throw_function_ = b->throw_function_; + a->throw_column_ = b->throw_column_; a->data_ = data; } @@ -454,13 +506,9 @@ boost { } -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility push (default) -# endif -#endif template <class T> class + BOOST_SYMBOL_VISIBLE clone_impl: public T, public virtual clone_base @@ -481,7 +529,7 @@ boost copy_boost_exception(this,&x); } - ~clone_impl() + ~clone_impl() BOOST_NOEXCEPT_OR_NOTHROW { } @@ -496,15 +544,14 @@ boost void rethrow() const { +#if defined(BOOST_NO_EXCEPTIONS) + boost::throw_exception(*this); +#else throw*this; +#endif } }; } -#if defined(__GNUC__) -# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) -# pragma GCC visibility pop -# endif -#endif template <class T> inline @@ -518,4 +565,5 @@ boost #if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) #pragma warning(pop) #endif -#endif + +#endif // #ifndef BOOST_EXCEPTION_274DA366004E11DCB1DDFE2E56D89593 diff --git a/contrib/restricted/boost/throw_exception/include/boost/throw_exception.hpp b/contrib/restricted/boost/throw_exception/include/boost/throw_exception.hpp index aa977dfc79..c50677ac5b 100644 --- a/contrib/restricted/boost/throw_exception/include/boost/throw_exception.hpp +++ b/contrib/restricted/boost/throw_exception/include/boost/throw_exception.hpp @@ -1,11 +1,5 @@ -#ifndef UUID_AA15E74A856F11E08B8D93F24824019B -#define UUID_AA15E74A856F11E08B8D93F24824019B -#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma GCC system_header -#endif -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(push,1) -#endif +#ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED +#define BOOST_THROW_EXCEPTION_HPP_INCLUDED // MS compatible compilers support #pragma once @@ -13,90 +7,272 @@ # pragma once #endif -// // boost/throw_exception.hpp // -// Copyright (c) 2002 Peter Dimov and Multi Media Ltd. +// Copyright (c) 2002, 2018-2022 Peter Dimov // Copyright (c) 2008-2009 Emil Dotchevski and Reverge Studios, Inc. // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // -// http://www.boost.org/libs/utility/throw_exception.html -// +// http://www.boost.org/libs/throw_exception -#include <boost/detail/workaround.hpp> +#include <boost/exception/exception.hpp> +#include <boost/assert/source_location.hpp> #include <boost/config.hpp> +#include <boost/config/workaround.hpp> #include <exception> - -#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( __BORLANDC__ ) && BOOST_WORKAROUND( __BORLANDC__, BOOST_TESTED_AT(0x593) ) -# define BOOST_EXCEPTION_DISABLE +#include <utility> +#include <cstddef> +#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) +#include <type_traits> #endif -#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_MSVC ) && BOOST_WORKAROUND( BOOST_MSVC, < 1310 ) +#if !defined( BOOST_EXCEPTION_DISABLE ) && defined( BOOST_BORLANDC ) && BOOST_WORKAROUND( BOOST_BORLANDC, BOOST_TESTED_AT(0x593) ) # define BOOST_EXCEPTION_DISABLE #endif -#if !defined( BOOST_EXCEPTION_DISABLE ) -# include <boost/exception/exception.hpp> -#if !defined(BOOST_THROW_EXCEPTION_CURRENT_FUNCTION) -# include <boost/current_function.hpp> -# define BOOST_THROW_EXCEPTION_CURRENT_FUNCTION BOOST_CURRENT_FUNCTION +namespace boost +{ + +#if defined( BOOST_NO_EXCEPTIONS ) + +BOOST_NORETURN void throw_exception( std::exception const & e ); // user defined +BOOST_NORETURN void throw_exception( std::exception const & e, boost::source_location const & loc ); // user defined + #endif -# define BOOST_THROW_EXCEPTION(x) ::boost::exception_detail::throw_exception_(x,BOOST_THROW_EXCEPTION_CURRENT_FUNCTION,__FILE__,__LINE__) + +// boost::wrapexcept<E> + +namespace detail +{ + +typedef char (&wrapexcept_s1)[ 1 ]; +typedef char (&wrapexcept_s2)[ 2 ]; + +template<class T> wrapexcept_s1 wrapexcept_is_convertible( T* ); +template<class T> wrapexcept_s2 wrapexcept_is_convertible( void* ); + +template<class E, class B, std::size_t I = sizeof( wrapexcept_is_convertible<B>( static_cast< E* >( 0 ) ) ) > struct wrapexcept_add_base; + +template<class E, class B> struct wrapexcept_add_base<E, B, 1> +{ + struct type {}; +}; + +template<class E, class B> struct wrapexcept_add_base<E, B, 2> +{ + typedef B type; +}; + +} // namespace detail + +template<class E> struct BOOST_SYMBOL_VISIBLE wrapexcept: + public detail::wrapexcept_add_base<E, boost::exception_detail::clone_base>::type, + public E, + public detail::wrapexcept_add_base<E, boost::exception>::type +{ +private: + + struct deleter + { + wrapexcept * p_; + ~deleter() { delete p_; } + }; + +private: + + void copy_from( void const* ) + { + } + + void copy_from( boost::exception const* p ) + { + static_cast<boost::exception&>( *this ) = *p; + } + +public: + + explicit wrapexcept( E const & e ): E( e ) + { + copy_from( &e ); + } + + explicit wrapexcept( E const & e, boost::source_location const & loc ): E( e ) + { + copy_from( &e ); + + set_info( *this, throw_file( loc.file_name() ) ); + set_info( *this, throw_line( loc.line() ) ); + set_info( *this, throw_function( loc.function_name() ) ); + set_info( *this, throw_column( loc.column() ) ); + } + + virtual boost::exception_detail::clone_base const * clone() const BOOST_OVERRIDE + { + wrapexcept * p = new wrapexcept( *this ); + deleter del = { p }; + + boost::exception_detail::copy_boost_exception( p, this ); + + del.p_ = BOOST_NULLPTR; + return p; + } + + virtual void rethrow() const BOOST_OVERRIDE + { +#if defined( BOOST_NO_EXCEPTIONS ) + + boost::throw_exception( *this ); + #else -# define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x) + + throw *this; + #endif + } +}; + +// All boost exceptions are required to derive from std::exception, +// to ensure compatibility with BOOST_NO_EXCEPTIONS. + +inline void throw_exception_assert_compatibility( std::exception const & ) {} + +// boost::throw_exception + +#if !defined( BOOST_NO_EXCEPTIONS ) + +#if defined( BOOST_EXCEPTION_DISABLE ) + +template<class E> BOOST_NORETURN void throw_exception( E const & e ) +{ + throw_exception_assert_compatibility( e ); + throw e; +} + +template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::source_location const & ) +{ + throw_exception_assert_compatibility( e ); + throw e; +} + +#else // defined( BOOST_EXCEPTION_DISABLE ) + +template<class E> BOOST_NORETURN void throw_exception( E const & e ) +{ + throw_exception_assert_compatibility( e ); + throw wrapexcept<E>( e ); +} + +template<class E> BOOST_NORETURN void throw_exception( E const & e, boost::source_location const & loc ) +{ + throw_exception_assert_compatibility( e ); + throw wrapexcept<E>( e, loc ); +} + +#endif // defined( BOOST_EXCEPTION_DISABLE ) + +#endif // !defined( BOOST_NO_EXCEPTIONS ) + +} // namespace boost + +// BOOST_THROW_EXCEPTION + +#define BOOST_THROW_EXCEPTION(x) ::boost::throw_exception(x, BOOST_CURRENT_LOCATION) namespace boost { -#ifdef BOOST_NO_EXCEPTIONS -void throw_exception( std::exception const & e ); // user defined +// throw_with_location -#else +namespace detail +{ + +struct BOOST_SYMBOL_VISIBLE throw_location +{ + boost::source_location location_; + + explicit throw_location( boost::source_location const & loc ): location_( loc ) + { + } +}; + +template<class E> class BOOST_SYMBOL_VISIBLE with_throw_location: public E, public throw_location +{ +public: + + with_throw_location( E const & e, boost::source_location const & loc ): E( e ), throw_location( loc ) + { + } + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) + + with_throw_location( E && e, boost::source_location const & loc ): E( std::move( e ) ), throw_location( loc ) + { + } + +#endif +}; -inline void throw_exception_assert_compatibility( std::exception const & ) { } +} // namespace detail -template<class E> BOOST_NORETURN inline void throw_exception( E const & e ) +#if !defined(BOOST_NO_EXCEPTIONS) + +#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) && !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) + +template<class E> BOOST_NORETURN void throw_with_location( E && e, boost::source_location const & loc = BOOST_CURRENT_LOCATION ) { - //All boost exceptions are required to derive from std::exception, - //to ensure compatibility with BOOST_NO_EXCEPTIONS. - throw_exception_assert_compatibility(e); + throw_exception_assert_compatibility( e ); + throw detail::with_throw_location<typename std::decay<E>::type>( std::forward<E>( e ), loc ); +} -#ifndef BOOST_EXCEPTION_DISABLE - throw enable_current_exception(enable_error_info(e)); #else - throw e; + +template<class E> BOOST_NORETURN void throw_with_location( E const & e, boost::source_location const & loc = BOOST_CURRENT_LOCATION ) +{ + throw_exception_assert_compatibility( e ); + throw detail::with_throw_location<E>( e, loc ); +} + #endif + +#else + +template<class E> BOOST_NORETURN void throw_with_location( E const & e, boost::source_location const & loc = BOOST_CURRENT_LOCATION ) +{ + boost::throw_exception( e, loc ); } #endif -#if !defined( BOOST_EXCEPTION_DISABLE ) - namespace - exception_detail +// get_throw_location + +template<class E> boost::source_location get_throw_location( E const & e ) +{ +#if defined(BOOST_NO_RTTI) + + (void)e; + return boost::source_location(); + +#else + + if( detail::throw_location const* pl = dynamic_cast< detail::throw_location const* >( &e ) ) + { + return pl->location_; + } + else if( boost::exception const* px = dynamic_cast< boost::exception const* >( &e ) ) { - template <class E> - BOOST_NORETURN - void - throw_exception_( E const & x, char const * current_function, char const * file, int line ) - { - boost::throw_exception( - set_info( - set_info( - set_info( - enable_error_info(x), - throw_function(current_function)), - throw_file(file)), - throw_line(line))); - } + return exception_detail::get_exception_throw_location( *px ); } + else + { + return boost::source_location(); + } + #endif +} + } // namespace boost -#if defined(_MSC_VER) && !defined(BOOST_EXCEPTION_ENABLE_WARNINGS) -#pragma warning(pop) -#endif -#endif +#endif // #ifndef BOOST_THROW_EXCEPTION_HPP_INCLUDED |