mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-12 16:25:18 +00:00
Add new __llvm_cxxeh_begin_catch_if_isa function, change C -> C++ comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8150 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -42,9 +42,9 @@ void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===**
|
//===----------------------------------------------------------------------===//
|
||||||
* C++ Specific exception handling support...
|
// C++ Specific exception handling support...
|
||||||
*/
|
//
|
||||||
|
|
||||||
// __llvm_cxxeh_allocate_exception - This function allocates space for the
|
// __llvm_cxxeh_allocate_exception - This function allocates space for the
|
||||||
// specified number of bytes, plus a C++ exception object header.
|
// specified number of bytes, plus a C++ exception object header.
|
||||||
@@ -113,8 +113,8 @@ void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
|
|||||||
|
|
||||||
E->TypeInfo = TypeInfoPtr;
|
E->TypeInfo = TypeInfoPtr;
|
||||||
E->ExceptionObjectDestructor = DtorPtr;
|
E->ExceptionObjectDestructor = DtorPtr;
|
||||||
E->UnexpectedHandler = 0; /* FIXME */
|
E->UnexpectedHandler = 0; // FIXME
|
||||||
E->TerminateHandler = 0; /* FIXME */
|
E->TerminateHandler = 0; // FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
// __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
|
// __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
|
||||||
@@ -126,7 +126,7 @@ void *__llvm_cxxeh_current_uncaught_exception_isa(
|
|||||||
const std::type_info *CatchType) {
|
const std::type_info *CatchType) {
|
||||||
assert(UncaughtExceptionStack && "No uncaught exception!");
|
assert(UncaughtExceptionStack && "No uncaught exception!");
|
||||||
if (UncaughtExceptionStack->ExceptionType != CXXException)
|
if (UncaughtExceptionStack->ExceptionType != CXXException)
|
||||||
return 0; /* If it's not a c++ exception, it doesn't match! */
|
return 0; // If it's not a c++ exception, it doesn't match!
|
||||||
|
|
||||||
// If it is a C++ exception, use the type info object stored in the exception
|
// If it is a C++ exception, use the type info object stored in the exception
|
||||||
// to see if TypeID matches and, if so, to adjust the exception object
|
// to see if TypeID matches and, if so, to adjust the exception object
|
||||||
@@ -156,68 +156,83 @@ void *__llvm_cxxeh_current_uncaught_exception_isa(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
|
// __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
|
||||||
* which transition an exception from being uncaught to being caught. It
|
// which transition an exception from being uncaught to being caught. It
|
||||||
* returns a pointer to the exception object portion of the exception. This
|
// returns a pointer to the exception object portion of the exception. This
|
||||||
* function must work with foreign exceptions.
|
// function must work with foreign exceptions.
|
||||||
*/
|
//
|
||||||
void *__llvm_cxxeh_begin_catch(void) {
|
void *__llvm_cxxeh_begin_catch(void) {
|
||||||
llvm_exception *E = UncaughtExceptionStack;
|
llvm_exception *E = UncaughtExceptionStack;
|
||||||
assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
|
assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
|
||||||
|
|
||||||
/* The exception is now no longer uncaught... */
|
// The exception is now no longer uncaught.
|
||||||
UncaughtExceptionStack = E->Next;
|
UncaughtExceptionStack = E->Next;
|
||||||
|
|
||||||
/* The exception is now caught... */
|
// The exception is now caught.
|
||||||
E->Next = CaughtExceptionStack;
|
E->Next = CaughtExceptionStack;
|
||||||
CaughtExceptionStack = E->Next;
|
CaughtExceptionStack = E->Next;
|
||||||
|
|
||||||
/* Increment the handler count for this exception. */
|
// Increment the handler count for this exception.
|
||||||
E->HandlerCount++;
|
E->HandlerCount++;
|
||||||
|
|
||||||
/* Return a pointer to the exception object */
|
// Return a pointer to the raw exception object.
|
||||||
return E+1;
|
return E+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
|
// __llvm_cxxeh_begin_catch_if_isa - This function checks to see if the current
|
||||||
* top-level caught exception, destroying it if this is the last handler for the
|
// uncaught exception is of the specified type. If not, it returns a null
|
||||||
* exception.
|
// pointer, otherwise it 'catches' the exception and returns a pointer to the
|
||||||
*/
|
// object of the specified type. This function does never succeeds with foreign
|
||||||
|
// exceptions (because they can never be of type CatchType).
|
||||||
|
//
|
||||||
|
void *__llvm_cxxeh_begin_catch_if_isa(const std::type_info *CatchType) {
|
||||||
|
void *ObjPtr = __llvm_cxxeh_current_uncaught_exception_isa(CatchType);
|
||||||
|
if (!ObjPtr) return 0;
|
||||||
|
|
||||||
|
// begin_catch, meaning that the object is now "caught", not "uncaught"
|
||||||
|
__llvm_cxxeh_begin_catch();
|
||||||
|
return ObjPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
|
||||||
|
// top-level caught exception, destroying it if this is the last handler for the
|
||||||
|
// exception.
|
||||||
|
//
|
||||||
void __llvm_cxxeh_end_catch(void) {
|
void __llvm_cxxeh_end_catch(void) {
|
||||||
llvm_exception *E = CaughtExceptionStack;
|
llvm_exception *E = CaughtExceptionStack;
|
||||||
assert(E && "There are no caught exceptions!");
|
assert(E && "There are no caught exceptions!");
|
||||||
|
|
||||||
/* If this is the last handler using the exception, destroy it now! */
|
// If this is the last handler using the exception, destroy it now!
|
||||||
if (--E->HandlerCount == 0) {
|
if (--E->HandlerCount == 0) {
|
||||||
CaughtExceptionStack = E->Next; /* Unlink from the stack */
|
CaughtExceptionStack = E->Next; // Unlink from the stack
|
||||||
E->ExceptionDestructor(E); /* Release memory for the exception */
|
E->ExceptionDestructor(E); // Release memory for the exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* __llvm_cxxeh_rethrow - This function turns the top-level caught exception
|
// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
|
||||||
* into an uncaught exception, in preparation for an llvm.unwind, which should
|
// into an uncaught exception, in preparation for an llvm.unwind, which should
|
||||||
* follow immediately after the call to this function. This function must be
|
// follow immediately after the call to this function. This function must be
|
||||||
* prepared to deal with foreign exceptions.
|
// prepared to deal with foreign exceptions.
|
||||||
*/
|
//
|
||||||
void __llvm_cxxeh_rethrow(void) {
|
void __llvm_cxxeh_rethrow(void) {
|
||||||
llvm_exception *E = CaughtExceptionStack;
|
llvm_exception *E = CaughtExceptionStack;
|
||||||
if (E == 0) {
|
if (E == 0) {
|
||||||
/* 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
|
// 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
|
||||||
* should call terminate.
|
// should call terminate.
|
||||||
*/
|
//
|
||||||
/* FIXME */assert(0 && "FIXME: this should call E->Terminate!");
|
assert(0 && "FIXME: this should call E->Terminate!"); // FIXME!
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise we have an exception to rethrow. Move it back to the uncaught
|
// Otherwise we have an exception to rethrow. Move it back to the uncaught
|
||||||
* stack.
|
// stack.
|
||||||
*/
|
|
||||||
CaughtExceptionStack = E->Next;
|
CaughtExceptionStack = E->Next;
|
||||||
E->Next = UncaughtExceptionStack;
|
E->Next = UncaughtExceptionStack;
|
||||||
UncaughtExceptionStack = E;
|
UncaughtExceptionStack = E;
|
||||||
|
|
||||||
/* Decrement the number of handlers which are using the exception. */
|
// Decrement the number of handlers which are using the exception.
|
||||||
--E->HandlerCount;
|
--E->HandlerCount;
|
||||||
|
|
||||||
/* Return to the caller, which should perform the unwind now. */
|
// Return to the caller, which should perform the unwind now.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,6 +54,7 @@ extern "C" {
|
|||||||
|
|
||||||
void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
|
void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
|
||||||
void *__llvm_cxxeh_begin_catch(void);
|
void *__llvm_cxxeh_begin_catch(void);
|
||||||
|
void *__llvm_cxxeh_begin_catch_if_isa(const std::type_info *CatchType);
|
||||||
void __llvm_cxxeh_end_catch(void);
|
void __llvm_cxxeh_end_catch(void);
|
||||||
|
|
||||||
void __llvm_cxxeh_rethrow(void);
|
void __llvm_cxxeh_rethrow(void);
|
||||||
|
@@ -42,9 +42,9 @@ void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*===----------------------------------------------------------------------===**
|
//===----------------------------------------------------------------------===//
|
||||||
* C++ Specific exception handling support...
|
// C++ Specific exception handling support...
|
||||||
*/
|
//
|
||||||
|
|
||||||
// __llvm_cxxeh_allocate_exception - This function allocates space for the
|
// __llvm_cxxeh_allocate_exception - This function allocates space for the
|
||||||
// specified number of bytes, plus a C++ exception object header.
|
// specified number of bytes, plus a C++ exception object header.
|
||||||
@@ -113,8 +113,8 @@ void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
|
|||||||
|
|
||||||
E->TypeInfo = TypeInfoPtr;
|
E->TypeInfo = TypeInfoPtr;
|
||||||
E->ExceptionObjectDestructor = DtorPtr;
|
E->ExceptionObjectDestructor = DtorPtr;
|
||||||
E->UnexpectedHandler = 0; /* FIXME */
|
E->UnexpectedHandler = 0; // FIXME
|
||||||
E->TerminateHandler = 0; /* FIXME */
|
E->TerminateHandler = 0; // FIXME
|
||||||
}
|
}
|
||||||
|
|
||||||
// __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
|
// __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
|
||||||
@@ -126,7 +126,7 @@ void *__llvm_cxxeh_current_uncaught_exception_isa(
|
|||||||
const std::type_info *CatchType) {
|
const std::type_info *CatchType) {
|
||||||
assert(UncaughtExceptionStack && "No uncaught exception!");
|
assert(UncaughtExceptionStack && "No uncaught exception!");
|
||||||
if (UncaughtExceptionStack->ExceptionType != CXXException)
|
if (UncaughtExceptionStack->ExceptionType != CXXException)
|
||||||
return 0; /* If it's not a c++ exception, it doesn't match! */
|
return 0; // If it's not a c++ exception, it doesn't match!
|
||||||
|
|
||||||
// If it is a C++ exception, use the type info object stored in the exception
|
// If it is a C++ exception, use the type info object stored in the exception
|
||||||
// to see if TypeID matches and, if so, to adjust the exception object
|
// to see if TypeID matches and, if so, to adjust the exception object
|
||||||
@@ -156,68 +156,83 @@ void *__llvm_cxxeh_current_uncaught_exception_isa(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
|
// __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
|
||||||
* which transition an exception from being uncaught to being caught. It
|
// which transition an exception from being uncaught to being caught. It
|
||||||
* returns a pointer to the exception object portion of the exception. This
|
// returns a pointer to the exception object portion of the exception. This
|
||||||
* function must work with foreign exceptions.
|
// function must work with foreign exceptions.
|
||||||
*/
|
//
|
||||||
void *__llvm_cxxeh_begin_catch(void) {
|
void *__llvm_cxxeh_begin_catch(void) {
|
||||||
llvm_exception *E = UncaughtExceptionStack;
|
llvm_exception *E = UncaughtExceptionStack;
|
||||||
assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
|
assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
|
||||||
|
|
||||||
/* The exception is now no longer uncaught... */
|
// The exception is now no longer uncaught.
|
||||||
UncaughtExceptionStack = E->Next;
|
UncaughtExceptionStack = E->Next;
|
||||||
|
|
||||||
/* The exception is now caught... */
|
// The exception is now caught.
|
||||||
E->Next = CaughtExceptionStack;
|
E->Next = CaughtExceptionStack;
|
||||||
CaughtExceptionStack = E->Next;
|
CaughtExceptionStack = E->Next;
|
||||||
|
|
||||||
/* Increment the handler count for this exception. */
|
// Increment the handler count for this exception.
|
||||||
E->HandlerCount++;
|
E->HandlerCount++;
|
||||||
|
|
||||||
/* Return a pointer to the exception object */
|
// Return a pointer to the raw exception object.
|
||||||
return E+1;
|
return E+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
|
// __llvm_cxxeh_begin_catch_if_isa - This function checks to see if the current
|
||||||
* top-level caught exception, destroying it if this is the last handler for the
|
// uncaught exception is of the specified type. If not, it returns a null
|
||||||
* exception.
|
// pointer, otherwise it 'catches' the exception and returns a pointer to the
|
||||||
*/
|
// object of the specified type. This function does never succeeds with foreign
|
||||||
|
// exceptions (because they can never be of type CatchType).
|
||||||
|
//
|
||||||
|
void *__llvm_cxxeh_begin_catch_if_isa(const std::type_info *CatchType) {
|
||||||
|
void *ObjPtr = __llvm_cxxeh_current_uncaught_exception_isa(CatchType);
|
||||||
|
if (!ObjPtr) return 0;
|
||||||
|
|
||||||
|
// begin_catch, meaning that the object is now "caught", not "uncaught"
|
||||||
|
__llvm_cxxeh_begin_catch();
|
||||||
|
return ObjPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
|
||||||
|
// top-level caught exception, destroying it if this is the last handler for the
|
||||||
|
// exception.
|
||||||
|
//
|
||||||
void __llvm_cxxeh_end_catch(void) {
|
void __llvm_cxxeh_end_catch(void) {
|
||||||
llvm_exception *E = CaughtExceptionStack;
|
llvm_exception *E = CaughtExceptionStack;
|
||||||
assert(E && "There are no caught exceptions!");
|
assert(E && "There are no caught exceptions!");
|
||||||
|
|
||||||
/* If this is the last handler using the exception, destroy it now! */
|
// If this is the last handler using the exception, destroy it now!
|
||||||
if (--E->HandlerCount == 0) {
|
if (--E->HandlerCount == 0) {
|
||||||
CaughtExceptionStack = E->Next; /* Unlink from the stack */
|
CaughtExceptionStack = E->Next; // Unlink from the stack
|
||||||
E->ExceptionDestructor(E); /* Release memory for the exception */
|
E->ExceptionDestructor(E); // Release memory for the exception
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* __llvm_cxxeh_rethrow - This function turns the top-level caught exception
|
// __llvm_cxxeh_rethrow - This function turns the top-level caught exception
|
||||||
* into an uncaught exception, in preparation for an llvm.unwind, which should
|
// into an uncaught exception, in preparation for an llvm.unwind, which should
|
||||||
* follow immediately after the call to this function. This function must be
|
// follow immediately after the call to this function. This function must be
|
||||||
* prepared to deal with foreign exceptions.
|
// prepared to deal with foreign exceptions.
|
||||||
*/
|
//
|
||||||
void __llvm_cxxeh_rethrow(void) {
|
void __llvm_cxxeh_rethrow(void) {
|
||||||
llvm_exception *E = CaughtExceptionStack;
|
llvm_exception *E = CaughtExceptionStack;
|
||||||
if (E == 0) {
|
if (E == 0) {
|
||||||
/* 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
|
// 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
|
||||||
* should call terminate.
|
// should call terminate.
|
||||||
*/
|
//
|
||||||
/* FIXME */assert(0 && "FIXME: this should call E->Terminate!");
|
assert(0 && "FIXME: this should call E->Terminate!"); // FIXME!
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise we have an exception to rethrow. Move it back to the uncaught
|
// Otherwise we have an exception to rethrow. Move it back to the uncaught
|
||||||
* stack.
|
// stack.
|
||||||
*/
|
|
||||||
CaughtExceptionStack = E->Next;
|
CaughtExceptionStack = E->Next;
|
||||||
E->Next = UncaughtExceptionStack;
|
E->Next = UncaughtExceptionStack;
|
||||||
UncaughtExceptionStack = E;
|
UncaughtExceptionStack = E;
|
||||||
|
|
||||||
/* Decrement the number of handlers which are using the exception. */
|
// Decrement the number of handlers which are using the exception.
|
||||||
--E->HandlerCount;
|
--E->HandlerCount;
|
||||||
|
|
||||||
/* Return to the caller, which should perform the unwind now. */
|
// Return to the caller, which should perform the unwind now.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,6 +54,7 @@ extern "C" {
|
|||||||
|
|
||||||
void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
|
void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
|
||||||
void *__llvm_cxxeh_begin_catch(void);
|
void *__llvm_cxxeh_begin_catch(void);
|
||||||
|
void *__llvm_cxxeh_begin_catch_if_isa(const std::type_info *CatchType);
|
||||||
void __llvm_cxxeh_end_catch(void);
|
void __llvm_cxxeh_end_catch(void);
|
||||||
|
|
||||||
void __llvm_cxxeh_rethrow(void);
|
void __llvm_cxxeh_rethrow(void);
|
||||||
|
Reference in New Issue
Block a user