Implement uncaught_exceptions() using the newly added hooks in libc++abi, when available

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@238846 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow
2015-06-02 15:33:38 +00:00
parent 708b86b5f9
commit 8731c5da46
4 changed files with 60 additions and 7 deletions

View File

@@ -105,19 +105,25 @@ terminate() _NOEXCEPT
#endif // !__EMSCRIPTEN__
#endif // !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION)
bool uncaught_exception() _NOEXCEPT { return uncaught_exceptions() > 0; }
#if !defined(LIBCXXRT) && !defined(__GLIBCXX__) && !defined(__EMSCRIPTEN__)
bool uncaught_exception() _NOEXCEPT
int uncaught_exceptions() _NOEXCEPT
{
#if defined(__APPLE__) || defined(_LIBCPPABI_VERSION)
// on Darwin, there is a helper function so __cxa_get_globals is private
return __cxa_uncaught_exception();
// on Darwin, there is a helper function so __cxa_get_globals is private
# if _LIBCPPABI_VERSION > 1101
return __cxa_uncaught_exceptions();
# else
return __cxa_uncaught_exception() ? 1 : 0;
# endif
#else // __APPLE__
# if defined(_MSC_VER) && ! defined(__clang__)
_LIBCPP_WARNING("uncaught_exception not yet implemented")
_LIBCPP_WARNING("uncaught_exceptions not yet implemented")
# else
# warning uncaught_exception not yet implemented
# endif
fprintf(stderr, "uncaught_exception not yet implemented\n");
fprintf(stderr, "uncaught_exceptions not yet implemented\n");
::abort();
#endif // __APPLE__
}