summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-08-27 04:51:26 +0000
committerChris Lattner <sabre@nondot.org>2003-08-27 04:51:26 +0000
commit5eb79390570ffd5674f260621988afac2b91a60d (patch)
tree4184af0e8df0f559070354b58a271db7d3d702d0 /runtime
parent5cf1199059db83e3f4ad1616da60f1792c435acf (diff)
downloadllvm-5eb79390570ffd5674f260621988afac2b91a60d.tar.gz
llvm-5eb79390570ffd5674f260621988afac2b91a60d.tar.bz2
llvm-5eb79390570ffd5674f260621988afac2b91a60d.tar.xz
Fix several _killer_ bugs. This now actually WORKS for really complex testcases :)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r--runtime/GCCLibraries/crtend/C++-Exception.cpp15
-rw-r--r--runtime/GCCLibraries/libexception/C++-Exception.cpp15
2 files changed, 8 insertions, 22 deletions
diff --git a/runtime/GCCLibraries/crtend/C++-Exception.cpp b/runtime/GCCLibraries/crtend/C++-Exception.cpp
index 532c3ec30d..04c9113b41 100644
--- a/runtime/GCCLibraries/crtend/C++-Exception.cpp
+++ b/runtime/GCCLibraries/crtend/C++-Exception.cpp
@@ -9,7 +9,6 @@
#include "c++-exception.h"
#include <cstdlib>
-#include <cassert>
//===----------------------------------------------------------------------===//
// Generic exception support
@@ -75,8 +74,7 @@ void __llvm_cxxeh_free_exception(void *ObjectPtr) {
// exception.
//
static void cxx_destructor(llvm_exception *LE) {
- void *ObjectPtr = LE+1;
- llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
+ llvm_cxx_exception *E = get_cxx_exception(LE);
// The exception is no longer caught.
assert(CaughtExceptionStack == LE &&
@@ -132,7 +130,7 @@ void *__llvm_cxxeh_current_uncaught_exception_isa(
// to see if TypeID matches and, if so, to adjust the exception object
// pointer.
//
- llvm_cxx_exception *E = (llvm_cxx_exception*)UncaughtExceptionStack;
+ llvm_cxx_exception *E = get_cxx_exception(UncaughtExceptionStack);
// ThrownPtr is a pointer to the object being thrown...
void *ThrownPtr = E+1;
@@ -170,7 +168,7 @@ void *__llvm_cxxeh_begin_catch(void) {
// The exception is now caught.
E->Next = CaughtExceptionStack;
- CaughtExceptionStack = E->Next;
+ CaughtExceptionStack = E;
// Increment the handler count for this exception.
E->HandlerCount++;
@@ -204,10 +202,8 @@ void __llvm_cxxeh_end_catch(void) {
assert(E && "There are no caught exceptions!");
// If this is the last handler using the exception, destroy it now!
- if (--E->HandlerCount == 0) {
- CaughtExceptionStack = E->Next; // Unlink from the stack
+ if (--E->HandlerCount == 0)
E->ExceptionDestructor(E); // Release memory for the exception
- }
}
// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
@@ -229,9 +225,6 @@ void __llvm_cxxeh_rethrow(void) {
CaughtExceptionStack = E->Next;
E->Next = UncaughtExceptionStack;
UncaughtExceptionStack = E;
-
- // Decrement the number of handlers which are using the exception.
- --E->HandlerCount;
// Return to the caller, which should perform the unwind now.
}
diff --git a/runtime/GCCLibraries/libexception/C++-Exception.cpp b/runtime/GCCLibraries/libexception/C++-Exception.cpp
index 532c3ec30d..04c9113b41 100644
--- a/runtime/GCCLibraries/libexception/C++-Exception.cpp
+++ b/runtime/GCCLibraries/libexception/C++-Exception.cpp
@@ -9,7 +9,6 @@
#include "c++-exception.h"
#include <cstdlib>
-#include <cassert>
//===----------------------------------------------------------------------===//
// Generic exception support
@@ -75,8 +74,7 @@ void __llvm_cxxeh_free_exception(void *ObjectPtr) {
// exception.
//
static void cxx_destructor(llvm_exception *LE) {
- void *ObjectPtr = LE+1;
- llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
+ llvm_cxx_exception *E = get_cxx_exception(LE);
// The exception is no longer caught.
assert(CaughtExceptionStack == LE &&
@@ -132,7 +130,7 @@ void *__llvm_cxxeh_current_uncaught_exception_isa(
// to see if TypeID matches and, if so, to adjust the exception object
// pointer.
//
- llvm_cxx_exception *E = (llvm_cxx_exception*)UncaughtExceptionStack;
+ llvm_cxx_exception *E = get_cxx_exception(UncaughtExceptionStack);
// ThrownPtr is a pointer to the object being thrown...
void *ThrownPtr = E+1;
@@ -170,7 +168,7 @@ void *__llvm_cxxeh_begin_catch(void) {
// The exception is now caught.
E->Next = CaughtExceptionStack;
- CaughtExceptionStack = E->Next;
+ CaughtExceptionStack = E;
// Increment the handler count for this exception.
E->HandlerCount++;
@@ -204,10 +202,8 @@ void __llvm_cxxeh_end_catch(void) {
assert(E && "There are no caught exceptions!");
// If this is the last handler using the exception, destroy it now!
- if (--E->HandlerCount == 0) {
- CaughtExceptionStack = E->Next; // Unlink from the stack
+ if (--E->HandlerCount == 0)
E->ExceptionDestructor(E); // Release memory for the exception
- }
}
// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
@@ -229,9 +225,6 @@ void __llvm_cxxeh_rethrow(void) {
CaughtExceptionStack = E->Next;
E->Next = UncaughtExceptionStack;
UncaughtExceptionStack = E;
-
- // Decrement the number of handlers which are using the exception.
- --E->HandlerCount;
// Return to the caller, which should perform the unwind now.
}