|
View:
New views
1 Messages
—
Rating Filter:
Alert me
|
|
|
[v3] libsupc++ doxygenShow doxygen bits for newer exception machinery. tested x86_64/linux -benjamin 2009-11-09 Benjamin Kosnik <bkoz@...> * doc/doxygen/user.cfg.in: Regenerate, add files. * libsupc++/eh_ptr.cc: Format. * libsupc++/exception_ptr.h: Same. * libsupc++/cxxabi.h(recursive_init_error): Move declarartion here. * libsupc++/guard.cc: From here. * libsupc++/nested_exception.h: Add markup. Index: libsupc++/eh_ptr.cc =================================================================== --- libsupc++/eh_ptr.cc (revision 154051) +++ libsupc++/eh_ptr.cc (working copy) @@ -35,41 +35,30 @@ using namespace __cxxabiv1; std::__exception_ptr::exception_ptr::exception_ptr() throw() - : _M_exception_object(0) -{ -} +: _M_exception_object(0) { } std::__exception_ptr::exception_ptr::exception_ptr(void* obj) throw() - : _M_exception_object(obj) -{ - _M_addref(); -} +: _M_exception_object(obj) { _M_addref(); } std::__exception_ptr::exception_ptr::exception_ptr(__safe_bool) throw() - : _M_exception_object(0) -{ -} +: _M_exception_object(0) { } -std::__exception_ptr::exception_ptr::exception_ptr( - const exception_ptr& other) throw() - : _M_exception_object(other._M_exception_object) -{ - _M_addref(); -} +std::__exception_ptr:: +exception_ptr::exception_ptr(const exception_ptr& other) throw() +: _M_exception_object(other._M_exception_object) +{ _M_addref(); } std::__exception_ptr::exception_ptr::~exception_ptr() throw() -{ - _M_release(); -} +{ _M_release(); } std::__exception_ptr::exception_ptr& -std::__exception_ptr::exception_ptr::operator=( - const exception_ptr& other) throw() +std::__exception_ptr:: +exception_ptr::operator=(const exception_ptr& other) throw() { exception_ptr(other).swap(*this); return *this; @@ -109,15 +98,11 @@ void* std::__exception_ptr::exception_ptr::_M_get() const throw() -{ - return _M_exception_object; -} +{ return _M_exception_object; } void -std::__exception_ptr::exception_ptr::_M_safe_bool_dummy() throw () -{ -} +std::__exception_ptr::exception_ptr::_M_safe_bool_dummy() throw () { } void @@ -132,9 +117,7 @@ // Retained for compatibility with CXXABI_1.3. bool std::__exception_ptr::exception_ptr::operator!() const throw() -{ - return _M_exception_object == 0; -} +{ return _M_exception_object == 0; } // Retained for compatibility with CXXABI_1.3. @@ -153,17 +136,13 @@ bool std::__exception_ptr::operator==(const exception_ptr& lhs, - const exception_ptr& rhs) throw() -{ - return lhs._M_exception_object == rhs._M_exception_object; -} + const exception_ptr& rhs) throw() +{ return lhs._M_exception_object == rhs._M_exception_object; } bool std::__exception_ptr::operator!=(const exception_ptr& lhs, - const exception_ptr& rhs) throw() -{ - return !(lhs == rhs); -} + const exception_ptr& rhs) throw() +{ return !(lhs == rhs);} std::exception_ptr @@ -185,8 +164,8 @@ static void -__gxx_dependent_exception_cleanup (_Unwind_Reason_Code code, - _Unwind_Exception *exc) +__gxx_dependent_exception_cleanup(_Unwind_Reason_Code code, + _Unwind_Exception *exc) { // This cleanup is set only for dependents. __cxa_dependent_exception *dep = __get_dependent_exception_from_ue (exc); @@ -236,7 +215,7 @@ // Some sort of unwinding error. Note that terminate is a handler. __cxa_begin_catch (&dep->unwindHeader); - std::terminate (); + std::terminate(); } #undef _GLIBCXX_EH_PTR_COMPAT Index: libsupc++/guard.cc =================================================================== --- libsupc++/guard.cc (revision 154051) +++ libsupc++/guard.cc (working copy) @@ -136,20 +136,6 @@ namespace __gnu_cxx { - // 6.7[stmt.dcl]/4: If control re-enters the declaration (recursively) - // while the object is being initialized, the behavior is undefined. - - // Since we already have a library function to handle locking, we might - // as well check for this situation and throw an exception. - // We use the second byte of the guard variable to remember that we're - // in the middle of an initialization. - class recursive_init_error: public std::exception - { - public: - recursive_init_error() throw() { } - virtual ~recursive_init_error() throw (); - }; - recursive_init_error::~recursive_init_error() throw() { } } Index: libsupc++/nested_exception.h =================================================================== --- libsupc++/nested_exception.h (revision 154051) +++ libsupc++/nested_exception.h (working copy) @@ -51,9 +51,11 @@ * @{ */ - /// nested_exception + /// Exception class with exception_ptr data member. class nested_exception { + exception_ptr _M_ptr; + public: nested_exception() throw() : _M_ptr(current_exception()) { } @@ -70,16 +72,12 @@ exception_ptr nested_ptr() const { return _M_ptr; } - - private: - exception_ptr _M_ptr; }; template<typename _Except> struct _Nested_exception : public _Except, public nested_exception { - explicit - _Nested_exception(_Except&& __ex) + explicit _Nested_exception(_Except&& __ex) : _Except(static_cast<_Except&&>(__ex)) { } }; @@ -89,9 +87,7 @@ { static const nested_exception* _S_get(const _Ex& __ex) - { - return dynamic_cast<const nested_exception*>(&__ex); - } + { return dynamic_cast<const nested_exception*>(&__ex); } }; template<typename _Ex> @@ -99,17 +95,13 @@ { static const nested_exception* _S_get(const _Ex* __ex) - { - return dynamic_cast<const nested_exception*>(__ex); - } + { return dynamic_cast<const nested_exception*>(__ex); } }; template<typename _Ex> inline const nested_exception* __get_nested_exception(const _Ex& __ex) - { - return __get_nested_helper<_Ex>::_S_get(__ex); - } + { return __get_nested_helper<_Ex>::_S_get(__ex); } template<typename _Ex> void @@ -126,21 +118,19 @@ template<typename _Ex> inline void __throw_with_nested(_Ex&& __ex, const nested_exception* = 0) - { - throw __ex; - } + { throw __ex; } template<typename _Ex> inline void __throw_with_nested(_Ex&& __ex, ...) - { - throw _Nested_exception<_Ex>(static_cast<_Ex&&>(__ex)); - } + { throw _Nested_exception<_Ex>(static_cast<_Ex&&>(__ex)); } template<typename _Ex> void throw_with_nested(_Ex __ex) __attribute__ ((__noreturn__)); + /// If @p __ex is derived from nested_exception, @p __ex. + /// Else, an implementation-defined object derived from both. template<typename _Ex> inline void throw_with_nested(_Ex __ex) @@ -150,6 +140,7 @@ __throw_with_nested(static_cast<_Ex&&>(__ex), &__ex); } + /// If @p __ex is derived from nested_exception, @p __ex.rethrow_nested(). template<typename _Ex> inline void rethrow_if_nested(const _Ex& __ex) @@ -158,12 +149,10 @@ __nested->rethrow_nested(); } - // see n2619 + /// Overload, See N2619 inline void rethrow_if_nested(const nested_exception& __ex) - { - __ex.rethrow_nested(); - } + { __ex.rethrow_nested(); } // @} group exceptions } // namespace std Index: libsupc++/cxxabi.h =================================================================== --- libsupc++/cxxabi.h (revision 154051) +++ libsupc++/cxxabi.h (working copy) @@ -100,7 +100,7 @@ void __cxa_vec_cleanup(void* __array_address, size_t __element_count, - size_t __element_size, __cxa_cdtor_type destructor) _GLIBCXX_NOTHROW; + size_t __s, __cxa_cdtor_type destructor) _GLIBCXX_NOTHROW; // Destruct and release array. void @@ -601,6 +601,27 @@ */ namespace abi = __cxxabiv1; +namespace __gnu_cxx +{ + /** + * @brief Exception thrown by __cxa_guard_acquire. + * @ingroup exceptions + * + * 6.7[stmt.dcl]/4: If control re-enters the declaration (recursively) + * while the object is being initialized, the behavior is undefined. + * + * Since we already have a library function to handle locking, we might + * as well check for this situation and throw an exception. + * We use the second byte of the guard variable to remember that we're + * in the middle of an initialization. + */ + class recursive_init_error: public std::exception + { + public: + recursive_init_error() throw() { } + virtual ~recursive_init_error() throw (); + }; +} #endif // __cplusplus #pragma GCC visibility pop Index: libsupc++/exception_ptr.h =================================================================== --- libsupc++/exception_ptr.h (revision 154051) +++ libsupc++/exception_ptr.h (working copy) @@ -48,42 +48,28 @@ * @addtogroup exceptions * @{ */ - - // Hide the free operators from other types namespace __exception_ptr { - /** - * @brief An opaque pointer to an arbitrary exception. - */ class exception_ptr; } using __exception_ptr::exception_ptr; - /** Obtain an %exception_ptr to the currently handled exception. If there + /** Obtain an exception_ptr to the currently handled exception. If there * is none, or the currently handled exception is foreign, return the null * value. */ exception_ptr current_exception() throw(); - /// Throw the object pointed to by the %exception_ptr. + /// Throw the object pointed to by the exception_ptr. void rethrow_exception(exception_ptr) __attribute__ ((__noreturn__)); - /// Obtain an %exception_ptr pointing to a copy of the supplied object. - template<typename _Ex> - exception_ptr - copy_exception(_Ex __ex) throw(); - namespace __exception_ptr { - bool - operator==(const exception_ptr&, const exception_ptr&) - throw() __attribute__ ((__pure__)); - - bool - operator!=(const exception_ptr&, const exception_ptr&) - throw() __attribute__ ((__pure__)); - + /** + * @brief An opaque pointer to an arbitrary exception. + * @ingroup exceptions + */ class exception_ptr { void* _M_exception_object; @@ -140,16 +126,24 @@ #endif friend bool - operator==(const exception_ptr&, const exception_ptr&) - throw() __attribute__ ((__pure__)); + operator==(const exception_ptr&, const exception_ptr&) throw() + __attribute__ ((__pure__)); const type_info* __cxa_exception_type() const throw() __attribute__ ((__pure__)); }; + bool + operator==(const exception_ptr&, const exception_ptr&) throw() + __attribute__ ((__pure__)); + + bool + operator!=(const exception_ptr&, const exception_ptr&) throw() + __attribute__ ((__pure__)); } // namespace __exception_ptr + /// Obtain an exception_ptr pointing to a copy of the supplied object. template<typename _Ex> exception_ptr copy_exception(_Ex __ex) throw() |
| Free embeddable forum powered by Nabble | Forum Help |