[cfe-commits] [libcxxabi] r146396 - in /libcxxabi/trunk: src/cxa_exception.cpp www/spec.html

Howard Hinnant hhinnant at apple.com
Mon Dec 12 11:11:42 PST 2011


Author: hhinnant
Date: Mon Dec 12 13:11:42 2011
New Revision: 146396

URL: http://llvm.org/viewvc/llvm-project?rev=146396&view=rev
Log:
Made some minor tweaks to __cxa_rethrow

Modified:
    libcxxabi/trunk/src/cxa_exception.cpp
    libcxxabi/trunk/www/spec.html

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=146396&r1=146395&r2=146396&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Mon Dec 12 13:11:42 2011
@@ -265,6 +265,7 @@
     __cxa_exception *current_exception = globals->caughtExceptions;
     
     if (NULL != current_exception) {
+        // TODO:  Handle foreign exceptions?  How?
         if (current_exception->handlerCount < 0) {
         //  The exception has been rethrown
             if (0 == incrementHandlerCount(current_exception)) {
@@ -319,19 +320,22 @@
   (in an implementation-defined way) as being rethrown. 
 * If the caughtExceptions stack is empty, it calls terminate() 
   (see [C++FDIS] [except.throw], 15.1.8). 
-* It then returns to the handler that called it, which must call 
-  __cxa_end_catch(), perform any necessary cleanup, and finally 
-  call _Unwind_Resume() to continue unwinding.
+* It then calls _Unwind_Resume_or_Rethrow which should not return
+   (terminate if it does).
 */
 extern LIBCXXABI_NORETURN void __cxa_rethrow() {
     __cxa_eh_globals *globals = __cxa_get_globals();
-    __cxa_exception *exception = exception_from_exception_object(globals->caughtExceptions );
+    __cxa_exception *exception = globals->caughtExceptions;
 
     if (NULL == exception)   // there's no current exception!
         std::terminate ();
 
-//  Mark the exception as being rethrown
-    exception->handlerCount = -exception->handlerCount ;  // TODO: Atomic
+// TODO:  Handle foreign exceptions?  How?
+
+//  Mark the exception as being rethrown (reverse the effects of __cxa_begin_catch)
+    exception->handlerCount = -exception->handlerCount;
+    globals->uncaughtExceptions += 1;
+//  __cxa_end_catch will remove this exception from the caughtExceptions stack if necessary
     
 #if __arm__
     (void) _Unwind_SjLj_Resume_or_Rethrow(&exception->unwindHeader);

Modified: libcxxabi/trunk/www/spec.html
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/www/spec.html?rev=146396&r1=146395&r2=146396&view=diff
==============================================================================
--- libcxxabi/trunk/www/spec.html (original)
+++ libcxxabi/trunk/www/spec.html Mon Dec 12 13:11:42 2011
@@ -227,9 +227,9 @@
 </p>
 </blockquote>
 </td>
-<td></td>
-<td></td>
-<td></td>
+<td>✓</td>
+<td>✓</td>
+<td>✓</td>
 </tr>
 
 <tr>





More information about the cfe-commits mailing list