Chris Lattner | e86159d | 2003-08-30 22:48:16 +0000 | [diff] [blame] | 1 | //===- Exception.h - Generic language-independent exceptions ----*- C++ -*-===// |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 2 | // |
| 3 | // This file defines the the shared data structures used by all language |
| 4 | // specific exception handling runtime libraries. |
| 5 | // |
| 6 | //===----------------------------------------------------------------------===// |
| 7 | |
| 8 | #ifndef EXCEPTION_H |
| 9 | #define EXCEPTION_H |
| 10 | |
Chris Lattner | c2c70fa | 2003-08-27 04:50:12 +0000 | [diff] [blame] | 11 | struct llvm_exception { |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 12 | // ExceptionDestructor - This call-back function is used to destroy the |
| 13 | // current exception, without requiring the caller to know what the concrete |
| 14 | // exception type is. |
| 15 | // |
Chris Lattner | c2c70fa | 2003-08-27 04:50:12 +0000 | [diff] [blame] | 16 | void (*ExceptionDestructor)(llvm_exception *); |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 17 | |
| 18 | // ExceptionType - This field identifies what runtime library this exception |
| 19 | // came from. Currently defined values are: |
| 20 | // 0 - Error |
| 21 | // 1 - longjmp exception (see longjmp-exception.c) |
| 22 | // 2 - C++ exception (see c++-exception.c) |
| 23 | // |
| 24 | unsigned ExceptionType; |
| 25 | |
| 26 | // Next - This points to the next exception in the current stack. |
Chris Lattner | c2c70fa | 2003-08-27 04:50:12 +0000 | [diff] [blame] | 27 | llvm_exception *Next; |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 28 | |
| 29 | // HandlerCount - This is a count of the number of handlers which have |
| 30 | // currently caught this exception. If the handler is caught and this number |
| 31 | // falls to zero, the exception is destroyed. |
| 32 | // |
| 33 | unsigned HandlerCount; |
Chris Lattner | b40d5e7 | 2003-08-28 19:58:51 +0000 | [diff] [blame] | 34 | |
| 35 | // isRethrown - This field is set on an exception if it has been 'throw;'n. |
| 36 | // This is needed because the exception might exit through a number of the |
| 37 | // end_catch statements matching the number of begin_catch statements that |
| 38 | // have been processed. When this happens, the exception should become |
| 39 | // uncaught, not dead. |
| 40 | // |
| 41 | int isRethrown; |
Chris Lattner | c2c70fa | 2003-08-27 04:50:12 +0000 | [diff] [blame] | 42 | }; |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 43 | |
| 44 | enum { |
| 45 | ErrorException = 0, |
| 46 | LongjmpException = 1, |
| 47 | CXXException = 2, |
| 48 | }; |
| 49 | |
| 50 | // Language independent exception handling API... |
| 51 | // |
| 52 | extern "C" { |
Chris Lattner | 7a37fa7 | 2003-08-27 22:58:51 +0000 | [diff] [blame] | 53 | bool __llvm_eh_has_uncaught_exception() throw(); |
| 54 | void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw(); |
Chris Lattner | 7f45519 | 2003-08-30 23:17:51 +0000 | [diff] [blame^] | 55 | void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw(); |
| 56 | |
| 57 | llvm_exception *__llvm_eh_get_uncaught_exception() throw(); |
| 58 | llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw(); |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | #endif |