[PATCH] Add a new routine to libc++abi to get the number of uncaught exceptions

Marshall Clow mclow.lists at gmail.com
Wed May 27 11:25:41 PDT 2015


Hi EricWF, jroelofs,

In http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4259, the method `std::uncaught_exceptions()` (note the 's') on the end was added to the C++ working paper. This returns the number of currently uncaught exceptions.

The old routine `uncaught_exception` was deprecated.
libc++abi knows the number, but the call `__cxa_uncaught_exception` just returns if it is `!= 0`.

Add a new call `__cxa_uncaught_exceptions`, (with an 's') and make `__cxa_uncaught_exception` call it.

After this is landed, there will need to be changes to libc++ to use it.

http://reviews.llvm.org/D10067

Files:
  include/cxxabi.h
  src/cxa_exception.cpp

Index: include/cxxabi.h
===================================================================
--- include/cxxabi.h
+++ include/cxxabi.h
@@ -162,7 +162,8 @@
 extern void __cxa_decrement_exception_refcount(void* primary_exception) throw();
 
 // Apple addition to support std::uncaught_exception()
-extern bool __cxa_uncaught_exception() throw();
+extern bool          __cxa_uncaught_exception () throw();
+extern unsigned int  __cxa_uncaught_exceptions() throw();
 
 #ifdef __linux__
 // Linux TLS support. Not yet an official part of the Itanium ABI.
Index: src/cxa_exception.cpp
===================================================================
--- src/cxa_exception.cpp
+++ src/cxa_exception.cpp
@@ -710,13 +710,16 @@
 }
 
 bool
-__cxa_uncaught_exception() throw()
+__cxa_uncaught_exception() throw() { return __cxa_uncaught_exceptions() != 0; }
+
+unsigned int
+__cxa_uncaught_exceptions() throw()
 {
     // This does not report foreign exceptions in flight
     __cxa_eh_globals* globals = __cxa_get_globals_fast();
     if (globals == 0)
         return false;
-    return globals->uncaughtExceptions != 0;
+    return globals->uncaughtExceptions;
 }
 
 }  // extern "C"

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10067.26618.patch
Type: text/x-patch
Size: 1177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150527/7302288c/attachment.bin>


More information about the cfe-commits mailing list