diff options
Diffstat (limited to 'contrib/libc++/include/__debug')
-rw-r--r-- | contrib/libc++/include/__debug | 108 |
1 files changed, 94 insertions, 14 deletions
diff --git a/contrib/libc++/include/__debug b/contrib/libc++/include/__debug index a21f9a8..d95e339 100644 --- a/contrib/libc++/include/__debug +++ b/contrib/libc++/include/__debug @@ -17,23 +17,103 @@ #pragma GCC system_header #endif -#if _LIBCPP_DEBUG_LEVEL >= 1 +#if defined(_LIBCPP_HAS_NO_NULLPTR) +# include <cstddef> +#endif + +#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) # include <cstdlib> # include <cstdio> # include <cstddef> -# ifndef _LIBCPP_ASSERT -# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : (_VSTD::fprintf(stderr, "%s\n", m), _VSTD::abort())) -# endif +# include <exception> +#endif + +#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT) +# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \ + _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) +#endif + +#if _LIBCPP_DEBUG_LEVEL >= 2 +#ifndef _LIBCPP_DEBUG_ASSERT +#define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m) +#endif +#define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__ #endif #ifndef _LIBCPP_ASSERT # define _LIBCPP_ASSERT(x, m) ((void)0) #endif +#ifndef _LIBCPP_DEBUG_ASSERT +# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) +#endif +#ifndef _LIBCPP_DEBUG_MODE +#define _LIBCPP_DEBUG_MODE(...) ((void)0) +#endif -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL < 1 +class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception; +#endif _LIBCPP_BEGIN_NAMESPACE_STD +struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info { + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + __libcpp_debug_info() + : __file_(nullptr), __line_(-1), __pred_(nullptr), __msg_(nullptr) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR + __libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m) + : __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {} + const char* __file_; + int __line_; + const char* __pred_; + const char* __msg_; +}; + +/// __libcpp_debug_function_type - The type of the assertion failure handler. +typedef void(*__libcpp_debug_function_type)(__libcpp_debug_info const&); + +/// __libcpp_debug_function - The handler function called when a _LIBCPP_ASSERT +/// fails. +extern __libcpp_debug_function_type __libcpp_debug_function; + +/// __libcpp_abort_debug_function - A debug handler that aborts when called. +_LIBCPP_NORETURN _LIBCPP_FUNC_VIS +void __libcpp_abort_debug_function(__libcpp_debug_info const&); + +/// __libcpp_throw_debug_function - A debug handler that throws +/// an instance of __libcpp_debug_exception when called. + _LIBCPP_NORETURN _LIBCPP_FUNC_VIS +void __libcpp_throw_debug_function(__libcpp_debug_info const&); + +/// __libcpp_set_debug_function - Set the debug handler to the specified +/// function. +_LIBCPP_FUNC_VIS +bool __libcpp_set_debug_function(__libcpp_debug_function_type __func); + +// Setup the throwing debug handler during dynamic initialization. +#if _LIBCPP_DEBUG_LEVEL >= 1 && defined(_LIBCPP_DEBUG_USE_EXCEPTIONS) +# if defined(_LIBCPP_NO_EXCEPTIONS) +# error _LIBCPP_DEBUG_USE_EXCEPTIONS cannot be used when exceptions are disabled. +# endif +static bool __init_dummy = __libcpp_set_debug_function(__libcpp_throw_debug_function); +#endif + +#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY) +class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception : public exception { +public: + __libcpp_debug_exception() _NOEXCEPT; + explicit __libcpp_debug_exception(__libcpp_debug_info const& __i); + __libcpp_debug_exception(__libcpp_debug_exception const&); + ~__libcpp_debug_exception() _NOEXCEPT; + const char* what() const _NOEXCEPT; +private: + struct __libcpp_debug_exception_imp; + __libcpp_debug_exception_imp *__imp_; +}; +#endif + +#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY) + struct _LIBCPP_TYPE_VIS __c_node; struct _LIBCPP_TYPE_VIS __i_node @@ -42,7 +122,7 @@ struct _LIBCPP_TYPE_VIS __i_node __i_node* __next_; __c_node* __c_; -#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#ifndef _LIBCPP_CXX03_LANG __i_node(const __i_node&) = delete; __i_node& operator=(const __i_node&) = delete; #else @@ -65,7 +145,7 @@ struct _LIBCPP_TYPE_VIS __c_node __i_node** end_; __i_node** cap_; -#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#ifndef _LIBCPP_CXX03_LANG __c_node(const __c_node&) = delete; __c_node& operator=(const __c_node&) = delete; #else @@ -102,7 +182,7 @@ struct _C_node }; template <class _Cont> -bool +inline bool _C_node<_Cont>::__dereferenceable(const void* __i) const { typedef typename _Cont::const_iterator iterator; @@ -112,7 +192,7 @@ _C_node<_Cont>::__dereferenceable(const void* __i) const } template <class _Cont> -bool +inline bool _C_node<_Cont>::__decrementable(const void* __i) const { typedef typename _Cont::const_iterator iterator; @@ -122,7 +202,7 @@ _C_node<_Cont>::__decrementable(const void* __i) const } template <class _Cont> -bool +inline bool _C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const { typedef typename _Cont::const_iterator iterator; @@ -132,7 +212,7 @@ _C_node<_Cont>::__addable(const void* __i, ptrdiff_t __n) const } template <class _Cont> -bool +inline bool _C_node<_Cont>::__subscriptable(const void* __i, ptrdiff_t __n) const { typedef typename _Cont::const_iterator iterator; @@ -152,7 +232,7 @@ class _LIBCPP_TYPE_VIS __libcpp_db __libcpp_db(); public: -#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#ifndef _LIBCPP_CXX03_LANG __libcpp_db(const __libcpp_db&) = delete; __libcpp_db& operator=(const __libcpp_db&) = delete; #else @@ -214,9 +294,9 @@ _LIBCPP_FUNC_VIS __libcpp_db* __get_db(); _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db(); -_LIBCPP_END_NAMESPACE_STD +#endif // _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY) -#endif +_LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_DEBUG_H |