Chris Lattner | e86159d | 2003-08-30 22:48:16 +0000 | [diff] [blame] | 1 | //===- Exception.h - Generic language-independent exceptions ----*- C++ -*-===// |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 2 | // |
Chris Lattner | d4d02bc | 2004-08-05 02:27:28 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 7 | // |
Chris Lattner | d4d02bc | 2004-08-05 02:27:28 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file defines the the shared data structures used by all language |
| 11 | // specific exception handling runtime libraries. |
| 12 | // |
Chris Lattner | d4d02bc | 2004-08-05 02:27:28 +0000 | [diff] [blame] | 13 | // NOTE NOTE NOTE: A copy of this file lives in llvmgcc/libstdc++-v3/libsupc++/ |
| 14 | // Any modifications to this file must keep it in sync! |
| 15 | // |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 16 | //===----------------------------------------------------------------------===// |
| 17 | |
| 18 | #ifndef EXCEPTION_H |
| 19 | #define EXCEPTION_H |
| 20 | |
Chris Lattner | c2c70fa | 2003-08-27 04:50:12 +0000 | [diff] [blame] | 21 | struct llvm_exception { |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 22 | // ExceptionDestructor - This call-back function is used to destroy the |
| 23 | // current exception, without requiring the caller to know what the concrete |
| 24 | // exception type is. |
| 25 | // |
Chris Lattner | c2c70fa | 2003-08-27 04:50:12 +0000 | [diff] [blame] | 26 | void (*ExceptionDestructor)(llvm_exception *); |
Misha Brukman | fd93908 | 2005-04-21 23:48:37 +0000 | [diff] [blame] | 27 | |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 28 | // ExceptionType - This field identifies what runtime library this exception |
| 29 | // came from. Currently defined values are: |
| 30 | // 0 - Error |
| 31 | // 1 - longjmp exception (see longjmp-exception.c) |
| 32 | // 2 - C++ exception (see c++-exception.c) |
| 33 | // |
| 34 | unsigned ExceptionType; |
| 35 | |
| 36 | // Next - This points to the next exception in the current stack. |
Chris Lattner | c2c70fa | 2003-08-27 04:50:12 +0000 | [diff] [blame] | 37 | llvm_exception *Next; |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 38 | |
| 39 | // HandlerCount - This is a count of the number of handlers which have |
| 40 | // currently caught this exception. If the handler is caught and this number |
| 41 | // falls to zero, the exception is destroyed. |
| 42 | // |
| 43 | unsigned HandlerCount; |
Chris Lattner | b40d5e7 | 2003-08-28 19:58:51 +0000 | [diff] [blame] | 44 | |
| 45 | // isRethrown - This field is set on an exception if it has been 'throw;'n. |
| 46 | // This is needed because the exception might exit through a number of the |
| 47 | // end_catch statements matching the number of begin_catch statements that |
| 48 | // have been processed. When this happens, the exception should become |
| 49 | // uncaught, not dead. |
| 50 | // |
| 51 | int isRethrown; |
Chris Lattner | c2c70fa | 2003-08-27 04:50:12 +0000 | [diff] [blame] | 52 | }; |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 53 | |
| 54 | enum { |
Chris Lattner | ed499d2 | 2003-08-30 23:29:08 +0000 | [diff] [blame] | 55 | ErrorException = 0, |
| 56 | SJLJException = 1, |
Reid Spencer | 19b7e0e | 2006-05-24 19:21:13 +0000 | [diff] [blame] | 57 | CXXException = 2 |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | // Language independent exception handling API... |
| 61 | // |
| 62 | extern "C" { |
Chris Lattner | 7a37fa7 | 2003-08-27 22:58:51 +0000 | [diff] [blame] | 63 | bool __llvm_eh_has_uncaught_exception() throw(); |
| 64 | void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw(); |
Chris Lattner | 7f45519 | 2003-08-30 23:17:51 +0000 | [diff] [blame] | 65 | void __llvm_eh_add_uncaught_exception(llvm_exception *E) throw(); |
| 66 | |
| 67 | llvm_exception *__llvm_eh_get_uncaught_exception() throw(); |
| 68 | llvm_exception *__llvm_eh_pop_from_uncaught_stack() throw(); |
Chris Lattner | 5337521 | 2003-08-25 22:35:36 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | #endif |