[cfe-commits] [libcxxabi] r149520 - /libcxxabi/trunk/src/cxa_exception.cpp

Howard Hinnant hhinnant at apple.com
Wed Feb 1 10:44:21 PST 2012


Author: hhinnant
Date: Wed Feb  1 12:44:21 2012
New Revision: 149520

URL: http://llvm.org/viewvc/llvm-project?rev=149520&view=rev
Log:
Teach exception_cleanup_func about dependent exceptions.

Modified:
    libcxxabi/trunk/src/cxa_exception.cpp

Modified: libcxxabi/trunk/src/cxa_exception.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_exception.cpp?rev=149520&r1=149519&r2=149520&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_exception.cpp (original)
+++ libcxxabi/trunk/src/cxa_exception.cpp Wed Feb  1 12:44:21 2012
@@ -128,12 +128,9 @@
     __cxa_exception* exception_header = cxa_exception_from_exception_unwind_exception(unwind_exception);
     if (_URC_FOREIGN_EXCEPTION_CAUGHT != reason)
         std::__terminate(exception_header->terminateHandler);
-
-    // TODO: Shouldn't this check the reference count first?
-    void * thrown_object = thrown_object_from_cxa_exception(exception_header);
-    if (NULL != exception_header->exceptionDestructor)
-        exception_header->exceptionDestructor(thrown_object);
-    __cxa_free_exception(thrown_object);
+    // Just in case there exists a dependent exception that is pointing to this,
+    //    check the reference count and only destroy this if that count goes to zero.
+    __cxa_decrement_exception_refcount(unwind_exception + 1);
 }
 
 static LIBCXXABI_NORETURN void failed_throw(__cxa_exception* exception_header) {





More information about the cfe-commits mailing list