blob: dc4d3a5f2cedafc4a72640a67bfa274a4db0f42b [file] [log] [blame]
Chris Lattnere86159d2003-08-30 22:48:16 +00001//===- Exception.h - Generic language-independent exceptions ----*- C++ -*-===//
Misha Brukmanfd939082005-04-21 23:48:37 +00002//
Chris Lattnerd4d02bc2004-08-05 02:27:28 +00003// 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 Brukmanfd939082005-04-21 23:48:37 +00007//
Chris Lattnerd4d02bc2004-08-05 02:27:28 +00008//===----------------------------------------------------------------------===//
Chris Lattner53375212003-08-25 22:35:36 +00009//
10// This file defines the the shared data structures used by all language
11// specific exception handling runtime libraries.
12//
Chris Lattnerd4d02bc2004-08-05 02:27:28 +000013// 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 Lattner53375212003-08-25 22:35:36 +000016//===----------------------------------------------------------------------===//
17
18#ifndef EXCEPTION_H
19#define EXCEPTION_H
20
Chris Lattnerc2c70fa2003-08-27 04:50:12 +000021struct llvm_exception {
Chris Lattner53375212003-08-25 22:35:36 +000022 // 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 Lattnerc2c70fa2003-08-27 04:50:12 +000026 void (*ExceptionDestructor)(llvm_exception *);
Misha Brukmanfd939082005-04-21 23:48:37 +000027
Chris Lattner53375212003-08-25 22:35:36 +000028 // 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 Lattnerc2c70fa2003-08-27 04:50:12 +000037 llvm_exception *Next;
Chris Lattner53375212003-08-25 22:35:36 +000038
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 Lattnerb40d5e72003-08-28 19:58:51 +000044
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 Lattnerc2c70fa2003-08-27 04:50:12 +000052};
Chris Lattner53375212003-08-25 22:35:36 +000053
54enum {
Chris Lattnered499d22003-08-30 23:29:08 +000055 ErrorException = 0,
56 SJLJException = 1,
Reid Spencer19b7e0e2006-05-24 19:21:13 +000057 CXXException = 2
Chris Lattner53375212003-08-25 22:35:36 +000058};
59
60// Language independent exception handling API...
61//
62extern "C" {
Chris Lattner7a37fa72003-08-27 22:58:51 +000063 bool __llvm_eh_has_uncaught_exception() throw();
64 void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) throw();
Chris Lattner7f455192003-08-30 23:17:51 +000065 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 Lattner53375212003-08-25 22:35:36 +000069}
70
71#endif