diff options
author | Remko Tronçon <git@el-tramo.be> | 2012-12-23 13:16:26 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2012-12-23 14:43:26 (GMT) |
commit | 491ddd570a752cf9bda85933bed0c6942e39b1f9 (patch) | |
tree | 10c25c1be8cc08d0497df1dccd56a10fbb30beee /3rdParty/Boost/src/boost/exception | |
parent | da7d7a0ca71b80281aa9ff2526290b61ccb0cc60 (diff) | |
download | swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.zip swift-491ddd570a752cf9bda85933bed0c6942e39b1f9.tar.bz2 |
Update Boost to 1.52.0.
Change-Id: I1e56bea2600bf2ed9c5b3aba8c4f9d2a0f350e77
Diffstat (limited to '3rdParty/Boost/src/boost/exception')
8 files changed, 339 insertions, 152 deletions
diff --git a/3rdParty/Boost/src/boost/exception/detail/attribute_noreturn.hpp b/3rdParty/Boost/src/boost/exception/detail/attribute_noreturn.hpp index f6a0b59..ae9f031 100644 --- a/3rdParty/Boost/src/boost/exception/detail/attribute_noreturn.hpp +++ b/3rdParty/Boost/src/boost/exception/detail/attribute_noreturn.hpp @@ -9,7 +9,7 @@ #if defined(_MSC_VER) #define BOOST_ATTRIBUTE_NORETURN __declspec(noreturn) #elif defined(__GNUC__) -#define BOOST_ATTRIBUTE_NORETURN __attribute__((noreturn)) +#define BOOST_ATTRIBUTE_NORETURN __attribute__((__noreturn__)) #else #define BOOST_ATTRIBUTE_NORETURN #endif diff --git a/3rdParty/Boost/src/boost/exception/detail/clone_current_exception.hpp b/3rdParty/Boost/src/boost/exception/detail/clone_current_exception.hpp new file mode 100644 index 0000000..cc201b9 --- /dev/null +++ b/3rdParty/Boost/src/boost/exception/detail/clone_current_exception.hpp @@ -0,0 +1,47 @@ +//Copyright (c) 2006-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) + +#ifndef UUID_81522C0EB56511DFAB613DB0DFD72085 +#define UUID_81522C0EB56511DFAB613DB0DFD72085 + +#ifdef BOOST_NO_EXCEPTIONS +# error This header requires exception handling to be enabled. +#endif + +namespace +boost + { + namespace + exception_detail + { + class clone_base; + +#ifdef BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR + int clone_current_exception_non_intrusive( clone_base const * & cloned ); +#endif + + namespace + clone_current_exception_result + { + int const success=0; + int const bad_alloc=1; + int const bad_exception=2; + int const not_supported=3; + } + + inline + int + clone_current_exception( clone_base const * & cloned ) + { +#ifdef BOOST_ENABLE_NON_INTRUSIVE_EXCEPTION_PTR + return clone_current_exception_non_intrusive(cloned); +#else + return clone_current_exception_result::not_supported; +#endif + } + } + } + +#endif diff --git a/3rdParty/Boost/src/boost/exception/detail/error_info_impl.hpp b/3rdParty/Boost/src/boost/exception/detail/error_info_impl.hpp index 883d313..a8d1aa7 100644 --- a/3rdParty/Boost/src/boost/exception/detail/error_info_impl.hpp +++ b/3rdParty/Boost/src/boost/exception/detail/error_info_impl.hpp @@ -30,6 +30,7 @@ boost protected: + virtual ~error_info_base() throw() { } diff --git a/3rdParty/Boost/src/boost/exception/detail/exception_ptr.hpp b/3rdParty/Boost/src/boost/exception/detail/exception_ptr.hpp index 0510fe2..5e5a267 100644 --- a/3rdParty/Boost/src/boost/exception/detail/exception_ptr.hpp +++ b/3rdParty/Boost/src/boost/exception/detail/exception_ptr.hpp @@ -20,18 +20,52 @@ #include <boost/exception/info.hpp> #include <boost/exception/diagnostic_information.hpp> #include <boost/exception/detail/type_info.hpp> +#include <boost/exception/detail/clone_current_exception.hpp> #include <boost/shared_ptr.hpp> #include <stdexcept> #include <new> #include <ios> +#include <stdlib.h> namespace boost { - typedef shared_ptr<exception_detail::clone_base const> exception_ptr; - + class exception_ptr; + BOOST_ATTRIBUTE_NORETURN void rethrow_exception( exception_ptr const & ); exception_ptr current_exception(); + class + exception_ptr + { + typedef boost::shared_ptr<exception_detail::clone_base const> impl; + impl ptr_; + friend void rethrow_exception( exception_ptr const & ); + typedef exception_detail::clone_base const * (impl::*unspecified_bool_type)() const; + public: + exception_ptr() + { + } + explicit + exception_ptr( impl const & ptr ): + ptr_(ptr) + { + } + bool + operator==( exception_ptr const & other ) const + { + return ptr_==other.ptr_; + } + bool + operator!=( exception_ptr const & other ) const + { + return ptr_!=other.ptr_; + } + operator unspecified_bool_type() const + { + return ptr_?&impl::get:0; + } + }; + template <class T> inline exception_ptr @@ -67,35 +101,49 @@ boost boost::exception, std::bad_alloc { + ~bad_alloc_() throw() { } }; - template <int Dummy> + struct + bad_exception_: + boost::exception, + std::bad_exception + { + ~bad_exception_() throw() { } + }; + + template <class Exception> exception_ptr - get_bad_alloc() + get_static_exception_object() { - bad_alloc_ ba; - exception_detail::clone_impl<bad_alloc_> c(ba); + Exception ba; + exception_detail::clone_impl<Exception> c(ba); c << throw_function(BOOST_CURRENT_FUNCTION) << throw_file(__FILE__) << throw_line(__LINE__); - static exception_ptr ep(new exception_detail::clone_impl<bad_alloc_>(c)); + static exception_ptr ep(shared_ptr<exception_detail::clone_base const>(new exception_detail::clone_impl<Exception>(c))); return ep; } - template <int Dummy> + template <class Exception> struct - exception_ptr_bad_alloc + exception_ptr_static_exception_object { static exception_ptr const e; }; - template <int Dummy> + template <class Exception> exception_ptr const - exception_ptr_bad_alloc<Dummy>:: - e = get_bad_alloc<Dummy>(); + exception_ptr_static_exception_object<Exception>:: + e = get_static_exception_object<Exception>(); } +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility push (default) +# endif +#endif class unknown_exception: public boost::exception, @@ -135,6 +183,11 @@ boost #endif } }; +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility pop +# endif +#endif namespace exception_detail @@ -244,101 +297,131 @@ boost exception_ptr current_exception_impl() { - try - { - throw; - } - catch( - exception_detail::clone_base & e ) - { - return exception_ptr(e.clone()); - } - catch( - std::domain_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::invalid_argument & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::length_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::out_of_range & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::logic_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::range_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::overflow_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::underflow_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::ios_base::failure & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::runtime_error & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::bad_alloc & e ) - { - return exception_detail::current_exception_std_exception(e); - } + exception_detail::clone_base const * e=0; + switch( + exception_detail::clone_current_exception(e) ) + { + case exception_detail::clone_current_exception_result:: + success: + { + BOOST_ASSERT(e!=0); + return exception_ptr(shared_ptr<exception_detail::clone_base const>(e)); + } + case exception_detail::clone_current_exception_result:: + bad_alloc: + { + BOOST_ASSERT(!e); + return exception_detail::exception_ptr_static_exception_object<bad_alloc_>::e; + } + case exception_detail::clone_current_exception_result:: + bad_exception: + { + BOOST_ASSERT(!e); + return exception_detail::exception_ptr_static_exception_object<bad_exception_>::e; + } + default: + BOOST_ASSERT(0); + case exception_detail::clone_current_exception_result:: + not_supported: + { + BOOST_ASSERT(!e); + try + { + throw; + } + catch( + exception_detail::clone_base & e ) + { + return exception_ptr(shared_ptr<exception_detail::clone_base const>(e.clone())); + } + catch( + std::domain_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::invalid_argument & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::length_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::out_of_range & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::logic_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::range_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::overflow_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::underflow_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::ios_base::failure & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::runtime_error & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::bad_alloc & e ) + { + return exception_detail::current_exception_std_exception(e); + } #ifndef BOOST_NO_TYPEID - catch( - std::bad_cast & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::bad_typeid & e ) - { - return exception_detail::current_exception_std_exception(e); - } + catch( + std::bad_cast & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::bad_typeid & e ) + { + return exception_detail::current_exception_std_exception(e); + } #endif - catch( - std::bad_exception & e ) - { - return exception_detail::current_exception_std_exception(e); - } - catch( - std::exception & e ) - { - return exception_detail::current_exception_unknown_std_exception(e); - } - catch( - boost::exception & e ) - { - return exception_detail::current_exception_unknown_boost_exception(e); - } - catch( - ... ) - { - return exception_detail::current_exception_unknown_exception(); + catch( + std::bad_exception & e ) + { + return exception_detail::current_exception_std_exception(e); + } + catch( + std::exception & e ) + { + return exception_detail::current_exception_unknown_std_exception(e); + } + catch( + boost::exception & e ) + { + return exception_detail::current_exception_unknown_boost_exception(e); + } + catch( + ... ) + { + return exception_detail::current_exception_unknown_exception(); + } + } } } } @@ -348,7 +431,6 @@ boost current_exception() { exception_ptr ret; - BOOST_ASSERT(!ret); try { ret=exception_detail::current_exception_impl(); @@ -356,36 +438,31 @@ boost catch( std::bad_alloc & ) { - ret=exception_detail::exception_ptr_bad_alloc<42>::e; + ret=exception_detail::exception_ptr_static_exception_object<exception_detail::bad_alloc_>::e; } catch( ... ) { - try - { - ret=exception_detail::current_exception_std_exception(std::bad_exception()); - } - catch( - std::bad_alloc & ) - { - ret=exception_detail::exception_ptr_bad_alloc<42>::e; - } - catch( - ... ) - { - BOOST_ASSERT(0); - } + ret=exception_detail::exception_ptr_static_exception_object<exception_detail::bad_exception_>::e; } BOOST_ASSERT(ret); return ret; } + BOOST_ATTRIBUTE_NORETURN inline void rethrow_exception( exception_ptr const & p ) { BOOST_ASSERT(p); - p->rethrow(); + p.ptr_->rethrow(); + BOOST_ASSERT(0); + #if defined(UNDER_CE) + // some CE platforms don't define ::abort() + exit(-1); + #else + abort(); + #endif } inline diff --git a/3rdParty/Boost/src/boost/exception/detail/type_info.hpp b/3rdParty/Boost/src/boost/exception/detail/type_info.hpp index 9ab1c57..92f8464 100644 --- a/3rdParty/Boost/src/boost/exception/detail/type_info.hpp +++ b/3rdParty/Boost/src/boost/exception/detail/type_info.hpp @@ -53,11 +53,11 @@ boost struct type_info_ { - detail::sp_typeinfo const & type_; + detail::sp_typeinfo const * type_; explicit type_info_( detail::sp_typeinfo const & type ): - type_(type) + type_(&type) { } @@ -65,7 +65,7 @@ boost bool operator<( type_info_ const & a, type_info_ const & b ) { - return 0!=(a.type_.before(b.type_)); + return 0!=(a.type_->before(*b.type_)); } }; } diff --git a/3rdParty/Boost/src/boost/exception/diagnostic_information.hpp b/3rdParty/Boost/src/boost/exception/diagnostic_information.hpp index 2297676..ef89d73 100644 --- a/3rdParty/Boost/src/boost/exception/diagnostic_information.hpp +++ b/3rdParty/Boost/src/boost/exception/diagnostic_information.hpp @@ -14,6 +14,7 @@ #include <boost/config.hpp> #include <boost/exception/get_error_info.hpp> +#include <boost/exception/info.hpp> #include <boost/utility/enable_if.hpp> #ifndef BOOST_NO_RTTI #include <boost/units/detail/utility.hpp> @@ -85,19 +86,23 @@ boost char const * get_diagnostic_information( exception const & x, char const * header ) { - if( error_info_container * c=x.data_.get() ) #ifndef BOOST_NO_EXCEPTIONS - try - { + try + { #endif - return c->diagnostic_information(header); + error_info_container * c=x.data_.get(); + if( !c ) + x.data_.adopt(c=new exception_detail::error_info_container_impl); + char const * di=c->diagnostic_information(header); + BOOST_ASSERT(di!=0); + return di; #ifndef BOOST_NO_EXCEPTIONS - } - catch(...) - { - } + } + catch(...) + { + return 0; + } #endif - return 0; } inline @@ -122,22 +127,30 @@ boost std::ostringstream tmp; if( be ) { - if( char const * const * f=get_error_info<throw_file>(*be) ) + char const * const * f=get_error_info<throw_file>(*be); + int const * l=get_error_info<throw_line>(*be); + char const * const * fn=get_error_info<throw_function>(*be); + if( !f && !l && !fn ) + tmp << "Throw location unknown (consider using BOOST_THROW_EXCEPTION)\n"; + else { - tmp << *f; - if( int const * l=get_error_info<throw_line>(*be) ) - tmp << '(' << *l << "): "; + if( f ) + { + tmp << *f; + if( int const * l=get_error_info<throw_line>(*be) ) + tmp << '(' << *l << "): "; + } + tmp << "Throw in function "; + if( char const * const * fn=get_error_info<throw_function>(*be) ) + tmp << *fn; + else + tmp << "(unknown)"; + tmp << '\n'; } - tmp << "Throw in function "; - if( char const * const * fn=get_error_info<throw_function>(*be) ) - tmp << *fn; - else - tmp << "(unknown)"; - tmp << '\n'; } #ifndef BOOST_NO_RTTI tmp << std::string("Dynamic exception type: ") << - units::detail::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_.name()) << '\n'; + units::detail::demangle((be?(BOOST_EXCEPTION_DYNAMIC_TYPEID(*be)):(BOOST_EXCEPTION_DYNAMIC_TYPEID(*se))).type_->name()) << '\n'; #endif if( with_what && se ) tmp << "std::exception::what: " << wh << '\n'; @@ -166,7 +179,10 @@ boost { #endif (void) exception_detail::diagnostic_information_impl(&e,0,false); - return exception_detail::get_diagnostic_information(e,0); + if( char const * di=exception_detail::get_diagnostic_information(e,0) ) + return di; + else + return "Failed to produce boost::diagnostic_information_what()"; #ifndef BOOST_NO_EXCEPTIONS } catch( diff --git a/3rdParty/Boost/src/boost/exception/exception.hpp b/3rdParty/Boost/src/boost/exception/exception.hpp index adaac68..42d2787 100644 --- a/3rdParty/Boost/src/boost/exception/exception.hpp +++ b/3rdParty/Boost/src/boost/exception/exception.hpp @@ -132,7 +132,17 @@ 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 T> class shared_ptr; @@ -189,6 +199,11 @@ boost E const & set_info( E const &, throw_line const & ); } +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility push (default) +# endif +#endif class exception { @@ -250,6 +265,11 @@ boost mutable char const * throw_file_; mutable int throw_line_; }; +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility pop +# endif +#endif inline exception:: @@ -290,6 +310,11 @@ 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 error_info_injector: @@ -306,6 +331,11 @@ boost { } }; +#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 * ); @@ -334,7 +364,7 @@ boost struct enable_error_info_return_type { - typedef typename enable_error_info_helper<T,sizeof(exception_detail::dispatch_boost_exception((T*)0))>::type type; + typedef typename enable_error_info_helper<T,sizeof(exception_detail::dispatch_boost_exception(static_cast<T *>(0)))>::type type; }; } @@ -353,6 +383,11 @@ boost namespace exception_detail { +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility push (default) +# endif +#endif class clone_base { @@ -366,6 +401,11 @@ boost { } }; +#if defined(__GNUC__) +# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 1) || (__GNUC__ > 4) +# pragma GCC visibility pop +# endif +#endif inline void @@ -390,8 +430,15 @@ boost class clone_impl: public T, - public clone_base + public virtual clone_base { + struct clone_tag { }; + clone_impl( clone_impl const & x, clone_tag ): + T(x) + { + copy_boost_exception(this,&x); + } + public: explicit @@ -410,7 +457,7 @@ boost clone_base const * clone() const { - return new clone_impl(*this); + return new clone_impl(*this,clone_tag()); } void diff --git a/3rdParty/Boost/src/boost/exception/info.hpp b/3rdParty/Boost/src/boost/exception/info.hpp index c918dbd..7b56076 100644 --- a/3rdParty/Boost/src/boost/exception/info.hpp +++ b/3rdParty/Boost/src/boost/exception/info.hpp @@ -97,7 +97,7 @@ boost { shared_ptr<error_info_base> const & p = i->second; #ifndef BOOST_NO_RTTI - BOOST_ASSERT( BOOST_EXCEPTION_DYNAMIC_TYPEID(*p).type_==ti.type_ ); + BOOST_ASSERT( *BOOST_EXCEPTION_DYNAMIC_TYPEID(*p).type_==*ti.type_ ); #endif return p; } @@ -109,7 +109,6 @@ boost { if( header ) { - BOOST_ASSERT(*header!=0); std::ostringstream tmp; tmp << header; for( error_info_map::const_iterator i=info_.begin(),end=info_.end(); i!=end; ++i ) |