llvm.org GIT mirror llvm / 5337521
Initial checking of C++ exception handling library git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8146 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
7 changed file(s) with 685 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 //===- c++-exception.cpp - Exception handling support for C++ exceptions --===//
1 //
2 // This file defines the methods used to implement C++ exception handling in
3 // terms of the invoke and %llvm.unwind intrinsic. These primitives implement
4 // an exception handling ABI similar (but simpler and more efficient than) the
5 // Itanium C++ ABI exception handling standard.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "c++-exception.h"
10 #include
11 #include
12
13 //===----------------------------------------------------------------------===//
14 // Generic exception support
15 //
16
17 // Thread local state for exception handling.
18 // FIXME: This should really be made thread-local!
19 //
20 static llvm_exception *CaughtExceptionStack = 0;
21
22 // UncaughtExceptionStack - The stack of exceptions currently being thrown.
23 static llvm_exception *UncaughtExceptionStack = 0;
24
25 // __llvm_eh_has_uncaught_exception - This is used to implement
26 // std::uncaught_exception.
27 //
28 bool __llvm_eh_has_uncaught_exception(void) {
29 return UncaughtExceptionStack != 0;
30 }
31
32 // __llvm_eh_current_uncaught_exception - This function checks to see if the
33 // current uncaught exception is of the specified language type. If so, it
34 // returns a pointer to the exception area data.
35 //
36 void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) {
37 assert(UncaughtExceptionStack && "No uncaught exception!");
38 if (UncaughtExceptionStack->ExceptionType == HandlerType)
39 return UncaughtExceptionStack+1;
40 return 0;
41 }
42
43
44 /*===----------------------------------------------------------------------===**
45 * C++ Specific exception handling support...
46 */
47
48 // __llvm_cxxeh_allocate_exception - This function allocates space for the
49 // specified number of bytes, plus a C++ exception object header.
50 //
51 void *__llvm_cxxeh_allocate_exception(unsigned NumBytes) {
52 // FIXME: This should eventually have back-up buffers for out-of-memory
53 // situations.
54 //
55 llvm_cxx_exception *E =
56 (llvm_cxx_exception *)malloc(NumBytes+sizeof(llvm_cxx_exception));
57 E->BaseException.ExceptionType = 0; // intialize to invalid
58
59 return E+1; // return the pointer after the header
60 }
61
62 // __llvm_cxxeh_free_exception - Low-level function to free an exception. This
63 // is called directly from generated C++ code if evaluating the exception value
64 // into the exception location throws. Otherwise it is called from the C++
65 // exception object destructor.
66 //
67 void __llvm_cxxeh_free_exception(void *ObjectPtr) {
68 llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
69 free(E);
70 }
71
72 // cxx_destructor - This function is called through the generic
73 // exception->ExceptionDestructor function pointer to destroy a caught
74 // exception.
75 //
76 static void cxx_destructor(llvm_exception *LE) {
77 void *ObjectPtr = LE+1;
78 llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
79
80 // The exception is no longer caught.
81 assert(CaughtExceptionStack == LE &&
82 "Destroying an exception which is not the current caught exception?");
83 CaughtExceptionStack = LE->Next;
84
85 struct ExceptionFreer {
86 void *Ptr;
87 ExceptionFreer(void *P) : Ptr(P) {}
88 ~ExceptionFreer() {
89 // Free the memory for the exception, when the function is left, even if
90 // the exception object dtor throws its own exception!
91 __llvm_cxxeh_free_exception(Ptr);
92 }
93 } EF(E+1);
94
95 // Run the exception object dtor if it exists. */
96 if (E->ExceptionObjectDestructor)
97 E->ExceptionObjectDestructor(E);
98 }
99
100 // __llvm_cxxeh_throw - Given a pointer to memory which has an exception object
101 // evaluated into it, this sets up all of the fields of the exception allowing
102 // it to be thrown. After calling this, the code should call %llvm.unwind
103 //
104 void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
105 void (*DtorPtr)(void*)) {
106 llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
107 E->BaseException.ExceptionDestructor = cxx_destructor;
108 E->BaseException.ExceptionType = CXXException;
109 E->BaseException.Next = UncaughtExceptionStack;
110 UncaughtExceptionStack = &E->BaseException;
111 E->BaseException.HandlerCount = 0;
112
113 E->TypeInfo = TypeInfoPtr;
114 E->ExceptionObjectDestructor = DtorPtr;
115 E->UnexpectedHandler = 0; /* FIXME */
116 E->TerminateHandler = 0; /* FIXME */
117 }
118
119 // __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
120 // the current uncaught exception is a C++ exception, and if it is of the
121 // specified type id. If so, it returns a pointer to the object adjusted as
122 // appropriate, otherwise it returns null.
123 //
124 void *__llvm_cxxeh_current_uncaught_exception_isa(
125 const std::type_info *CatchType) {
126 assert(UncaughtExceptionStack && "No uncaught exception!");
127 if (UncaughtExceptionStack->ExceptionType != CXXException)
128 return 0; /* If it's not a c++ exception, it doesn't match! */
129
130 // If it is a C++ exception, use the type info object stored in the exception
131 // to see if TypeID matches and, if so, to adjust the exception object
132 // pointer.
133 //
134 llvm_cxx_exception *E = (llvm_cxx_exception*)UncaughtExceptionStack;
135
136 // ThrownPtr is a pointer to the object being thrown...
137 void *ThrownPtr = E+1;
138 const std::type_info *ThrownType = E->TypeInfo;
139
140 // FIXME: this code exists in the GCC exception handling library: I haven't
141 // thought about this yet, so it should be verified at some point!
142 #if 1
143 // Pointer types need to adjust the actual pointer, not
144 // the pointer to pointer that is the exception object.
145 // This also has the effect of passing pointer types
146 // "by value" through the __cxa_begin_catch return value.
147 if (ThrownType->__is_pointer_p())
148 ThrownPtr = *(void **)ThrownPtr;
149 #endif
150
151 if (CatchType->__do_catch(ThrownType, &ThrownPtr, 1))
152 return ThrownPtr;
153
154 return 0;
155 }
156
157
158 /* __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
159 * which transition an exception from being uncaught to being caught. It
160 * returns a pointer to the exception object portion of the exception. This
161 * function must work with foreign exceptions.
162 */
163 void *__llvm_cxxeh_begin_catch(void) {
164 llvm_exception *E = UncaughtExceptionStack;
165 assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
166
167 /* The exception is now no longer uncaught... */
168 UncaughtExceptionStack = E->Next;
169
170 /* The exception is now caught... */
171 E->Next = CaughtExceptionStack;
172 CaughtExceptionStack = E->Next;
173
174 /* Increment the handler count for this exception. */
175 E->HandlerCount++;
176
177 /* Return a pointer to the exception object */
178 return E+1;
179 }
180
181 /* __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
182 * top-level caught exception, destroying it if this is the last handler for the
183 * exception.
184 */
185 void __llvm_cxxeh_end_catch(void) {
186 llvm_exception *E = CaughtExceptionStack;
187 assert(E && "There are no caught exceptions!");
188
189 /* If this is the last handler using the exception, destroy it now! */
190 if (--E->HandlerCount == 0) {
191 CaughtExceptionStack = E->Next; /* Unlink from the stack */
192 E->ExceptionDestructor(E); /* Release memory for the exception */
193 }
194 }
195
196 /* __llvm_cxxeh_rethrow - This function turns the top-level caught exception
197 * into an uncaught exception, in preparation for an llvm.unwind, which should
198 * follow immediately after the call to this function. This function must be
199 * prepared to deal with foreign exceptions.
200 */
201 void __llvm_cxxeh_rethrow(void) {
202 llvm_exception *E = CaughtExceptionStack;
203 if (E == 0) {
204 /* 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
205 * should call terminate.
206 */
207 /* FIXME */assert(0 && "FIXME: this should call E->Terminate!");
208 }
209
210 /* Otherwise we have an exception to rethrow. Move it back to the uncaught
211 * stack.
212 */
213 CaughtExceptionStack = E->Next;
214 E->Next = UncaughtExceptionStack;
215 UncaughtExceptionStack = E;
216
217 /* Decrement the number of handlers which are using the exception. */
218 --E->HandlerCount;
219
220 /* Return to the caller, which should perform the unwind now. */
221 }
222
0 //===- c++-exception.h - C++ Specific exception Handling --------*- C++ -*-===//
1 //
2 // This file defines the data structures and API used by the C++ exception
3 // handling runtime library.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef CXX_EXCEPTION_H
8 #define CXX_EXCEPTION_H
9
10 #include "exception.h"
11 #include
12
13 typedef struct llvm_cxx_exception {
14 /* TypeInfo - A pointer to the C++ std::type_info object for this exception
15 * class. This is required because the class may not be polymorphic.
16 */
17 const std::type_info *TypeInfo;
18
19 /* ExceptionObjectDestructor - A pointer to the function which destroys the
20 * object represented by this exception. This is required because the class
21 * may not be polymorphic. This may be null if there is no cleanup required.
22 */
23 void (*ExceptionObjectDestructor)(void *);
24
25 /* UnexpectedHandler - This contains a pointer to the "unexpected" handler
26 * which may be registered by the user program with set_unexpected. Calls to
27 * unexpected which are a result of an exception throw are supposed to use the
28 * value of the handler at the time of the throw, not the currently set value.
29 */
30 void *UnexpectedHandler;
31
32 /* TerminateHandler - This contains a pointer to the "terminate" handler which
33 * may be registered by the user program with set_terminate. Calls to
34 * unexpected which are a result of an exception throw are supposed to use the
35 * value of the handler at the time of the throw, not the currently set value.
36 */
37 void *TerminateHandler;
38
39 /* BaseException - The language independent portion of the exception state.
40 * This is at the end of the record so that we can add additional members to
41 * this structure without breaking binary compatibility.
42 */
43 llvm_exception BaseException;
44 } llvm_cxx_exception;
45
46
47
48 extern "C" {
49 void *__llvm_cxxeh_allocate_exception(unsigned NumBytes);
50 void __llvm_cxxeh_free_exception(void *ObjectPtr);
51 void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
52 void (*DtorPtr)(void*));
53
54 void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
55 void *__llvm_cxxeh_begin_catch(void);
56 void __llvm_cxxeh_end_catch(void);
57
58 void __llvm_cxxeh_rethrow(void);
59 }
60
61 #endif
0 //===- exception.h - Generic language-independent exceptions ----*- C++ -*-===//
1 //
2 // This file defines the the shared data structures used by all language
3 // specific exception handling runtime libraries.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef EXCEPTION_H
8 #define EXCEPTION_H
9
10 typedef struct llvm_exception {
11 // ExceptionDestructor - This call-back function is used to destroy the
12 // current exception, without requiring the caller to know what the concrete
13 // exception type is.
14 //
15 void (*ExceptionDestructor)(struct llvm_exception *);
16
17 // ExceptionType - This field identifies what runtime library this exception
18 // came from. Currently defined values are:
19 // 0 - Error
20 // 1 - longjmp exception (see longjmp-exception.c)
21 // 2 - C++ exception (see c++-exception.c)
22 //
23 unsigned ExceptionType;
24
25 // Next - This points to the next exception in the current stack.
26 struct llvm_exception *Next;
27
28 // HandlerCount - This is a count of the number of handlers which have
29 // currently caught this exception. If the handler is caught and this number
30 // falls to zero, the exception is destroyed.
31 //
32 unsigned HandlerCount;
33 } llvm_exception;
34
35 enum {
36 ErrorException = 0,
37 LongjmpException = 1,
38 CXXException = 2,
39 };
40
41 // Language independent exception handling API...
42 //
43 extern "C" {
44 bool __llvm_eh_has_uncaught_exception(void);
45 void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType);
46 }
47
48 #endif
0 //===- c++-exception.cpp - Exception handling support for C++ exceptions --===//
1 //
2 // This file defines the methods used to implement C++ exception handling in
3 // terms of the invoke and %llvm.unwind intrinsic. These primitives implement
4 // an exception handling ABI similar (but simpler and more efficient than) the
5 // Itanium C++ ABI exception handling standard.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "c++-exception.h"
10 #include
11 #include
12
13 //===----------------------------------------------------------------------===//
14 // Generic exception support
15 //
16
17 // Thread local state for exception handling.
18 // FIXME: This should really be made thread-local!
19 //
20 static llvm_exception *CaughtExceptionStack = 0;
21
22 // UncaughtExceptionStack - The stack of exceptions currently being thrown.
23 static llvm_exception *UncaughtExceptionStack = 0;
24
25 // __llvm_eh_has_uncaught_exception - This is used to implement
26 // std::uncaught_exception.
27 //
28 bool __llvm_eh_has_uncaught_exception(void) {
29 return UncaughtExceptionStack != 0;
30 }
31
32 // __llvm_eh_current_uncaught_exception - This function checks to see if the
33 // current uncaught exception is of the specified language type. If so, it
34 // returns a pointer to the exception area data.
35 //
36 void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType) {
37 assert(UncaughtExceptionStack && "No uncaught exception!");
38 if (UncaughtExceptionStack->ExceptionType == HandlerType)
39 return UncaughtExceptionStack+1;
40 return 0;
41 }
42
43
44 /*===----------------------------------------------------------------------===**
45 * C++ Specific exception handling support...
46 */
47
48 // __llvm_cxxeh_allocate_exception - This function allocates space for the
49 // specified number of bytes, plus a C++ exception object header.
50 //
51 void *__llvm_cxxeh_allocate_exception(unsigned NumBytes) {
52 // FIXME: This should eventually have back-up buffers for out-of-memory
53 // situations.
54 //
55 llvm_cxx_exception *E =
56 (llvm_cxx_exception *)malloc(NumBytes+sizeof(llvm_cxx_exception));
57 E->BaseException.ExceptionType = 0; // intialize to invalid
58
59 return E+1; // return the pointer after the header
60 }
61
62 // __llvm_cxxeh_free_exception - Low-level function to free an exception. This
63 // is called directly from generated C++ code if evaluating the exception value
64 // into the exception location throws. Otherwise it is called from the C++
65 // exception object destructor.
66 //
67 void __llvm_cxxeh_free_exception(void *ObjectPtr) {
68 llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
69 free(E);
70 }
71
72 // cxx_destructor - This function is called through the generic
73 // exception->ExceptionDestructor function pointer to destroy a caught
74 // exception.
75 //
76 static void cxx_destructor(llvm_exception *LE) {
77 void *ObjectPtr = LE+1;
78 llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
79
80 // The exception is no longer caught.
81 assert(CaughtExceptionStack == LE &&
82 "Destroying an exception which is not the current caught exception?");
83 CaughtExceptionStack = LE->Next;
84
85 struct ExceptionFreer {
86 void *Ptr;
87 ExceptionFreer(void *P) : Ptr(P) {}
88 ~ExceptionFreer() {
89 // Free the memory for the exception, when the function is left, even if
90 // the exception object dtor throws its own exception!
91 __llvm_cxxeh_free_exception(Ptr);
92 }
93 } EF(E+1);
94
95 // Run the exception object dtor if it exists. */
96 if (E->ExceptionObjectDestructor)
97 E->ExceptionObjectDestructor(E);
98 }
99
100 // __llvm_cxxeh_throw - Given a pointer to memory which has an exception object
101 // evaluated into it, this sets up all of the fields of the exception allowing
102 // it to be thrown. After calling this, the code should call %llvm.unwind
103 //
104 void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
105 void (*DtorPtr)(void*)) {
106 llvm_cxx_exception *E = (llvm_cxx_exception *)ObjectPtr - 1;
107 E->BaseException.ExceptionDestructor = cxx_destructor;
108 E->BaseException.ExceptionType = CXXException;
109 E->BaseException.Next = UncaughtExceptionStack;
110 UncaughtExceptionStack = &E->BaseException;
111 E->BaseException.HandlerCount = 0;
112
113 E->TypeInfo = TypeInfoPtr;
114 E->ExceptionObjectDestructor = DtorPtr;
115 E->UnexpectedHandler = 0; /* FIXME */
116 E->TerminateHandler = 0; /* FIXME */
117 }
118
119 // __llvm_cxxeh_current_uncaught_exception_isa - This function checks to see if
120 // the current uncaught exception is a C++ exception, and if it is of the
121 // specified type id. If so, it returns a pointer to the object adjusted as
122 // appropriate, otherwise it returns null.
123 //
124 void *__llvm_cxxeh_current_uncaught_exception_isa(
125 const std::type_info *CatchType) {
126 assert(UncaughtExceptionStack && "No uncaught exception!");
127 if (UncaughtExceptionStack->ExceptionType != CXXException)
128 return 0; /* If it's not a c++ exception, it doesn't match! */
129
130 // If it is a C++ exception, use the type info object stored in the exception
131 // to see if TypeID matches and, if so, to adjust the exception object
132 // pointer.
133 //
134 llvm_cxx_exception *E = (llvm_cxx_exception*)UncaughtExceptionStack;
135
136 // ThrownPtr is a pointer to the object being thrown...
137 void *ThrownPtr = E+1;
138 const std::type_info *ThrownType = E->TypeInfo;
139
140 // FIXME: this code exists in the GCC exception handling library: I haven't
141 // thought about this yet, so it should be verified at some point!
142 #if 1
143 // Pointer types need to adjust the actual pointer, not
144 // the pointer to pointer that is the exception object.
145 // This also has the effect of passing pointer types
146 // "by value" through the __cxa_begin_catch return value.
147 if (ThrownType->__is_pointer_p())
148 ThrownPtr = *(void **)ThrownPtr;
149 #endif
150
151 if (CatchType->__do_catch(ThrownType, &ThrownPtr, 1))
152 return ThrownPtr;
153
154 return 0;
155 }
156
157
158 /* __llvm_cxxeh_begin_catch - This function is called by "exception handlers",
159 * which transition an exception from being uncaught to being caught. It
160 * returns a pointer to the exception object portion of the exception. This
161 * function must work with foreign exceptions.
162 */
163 void *__llvm_cxxeh_begin_catch(void) {
164 llvm_exception *E = UncaughtExceptionStack;
165 assert(UncaughtExceptionStack && "There are no uncaught exceptions!?!?");
166
167 /* The exception is now no longer uncaught... */
168 UncaughtExceptionStack = E->Next;
169
170 /* The exception is now caught... */
171 E->Next = CaughtExceptionStack;
172 CaughtExceptionStack = E->Next;
173
174 /* Increment the handler count for this exception. */
175 E->HandlerCount++;
176
177 /* Return a pointer to the exception object */
178 return E+1;
179 }
180
181 /* __llvm_cxxeh_end_catch - This function decrements the HandlerCount of the
182 * top-level caught exception, destroying it if this is the last handler for the
183 * exception.
184 */
185 void __llvm_cxxeh_end_catch(void) {
186 llvm_exception *E = CaughtExceptionStack;
187 assert(E && "There are no caught exceptions!");
188
189 /* If this is the last handler using the exception, destroy it now! */
190 if (--E->HandlerCount == 0) {
191 CaughtExceptionStack = E->Next; /* Unlink from the stack */
192 E->ExceptionDestructor(E); /* Release memory for the exception */
193 }
194 }
195
196 /* __llvm_cxxeh_rethrow - This function turns the top-level caught exception
197 * into an uncaught exception, in preparation for an llvm.unwind, which should
198 * follow immediately after the call to this function. This function must be
199 * prepared to deal with foreign exceptions.
200 */
201 void __llvm_cxxeh_rethrow(void) {
202 llvm_exception *E = CaughtExceptionStack;
203 if (E == 0) {
204 /* 15.1.8 - If there are no uncaught exceptions being thrown, 'throw;'
205 * should call terminate.
206 */
207 /* FIXME */assert(0 && "FIXME: this should call E->Terminate!");
208 }
209
210 /* Otherwise we have an exception to rethrow. Move it back to the uncaught
211 * stack.
212 */
213 CaughtExceptionStack = E->Next;
214 E->Next = UncaughtExceptionStack;
215 UncaughtExceptionStack = E;
216
217 /* Decrement the number of handlers which are using the exception. */
218 --E->HandlerCount;
219
220 /* Return to the caller, which should perform the unwind now. */
221 }
222
0 //===- c++-exception.h - C++ Specific exception Handling --------*- C++ -*-===//
1 //
2 // This file defines the data structures and API used by the C++ exception
3 // handling runtime library.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef CXX_EXCEPTION_H
8 #define CXX_EXCEPTION_H
9
10 #include "exception.h"
11 #include
12
13 typedef struct llvm_cxx_exception {
14 /* TypeInfo - A pointer to the C++ std::type_info object for this exception
15 * class. This is required because the class may not be polymorphic.
16 */
17 const std::type_info *TypeInfo;
18
19 /* ExceptionObjectDestructor - A pointer to the function which destroys the
20 * object represented by this exception. This is required because the class
21 * may not be polymorphic. This may be null if there is no cleanup required.
22 */
23 void (*ExceptionObjectDestructor)(void *);
24
25 /* UnexpectedHandler - This contains a pointer to the "unexpected" handler
26 * which may be registered by the user program with set_unexpected. Calls to
27 * unexpected which are a result of an exception throw are supposed to use the
28 * value of the handler at the time of the throw, not the currently set value.
29 */
30 void *UnexpectedHandler;
31
32 /* TerminateHandler - This contains a pointer to the "terminate" handler which
33 * may be registered by the user program with set_terminate. Calls to
34 * unexpected which are a result of an exception throw are supposed to use the
35 * value of the handler at the time of the throw, not the currently set value.
36 */
37 void *TerminateHandler;
38
39 /* BaseException - The language independent portion of the exception state.
40 * This is at the end of the record so that we can add additional members to
41 * this structure without breaking binary compatibility.
42 */
43 llvm_exception BaseException;
44 } llvm_cxx_exception;
45
46
47
48 extern "C" {
49 void *__llvm_cxxeh_allocate_exception(unsigned NumBytes);
50 void __llvm_cxxeh_free_exception(void *ObjectPtr);
51 void __llvm_cxxeh_throw(void *ObjectPtr, const std::type_info *TypeInfoPtr,
52 void (*DtorPtr)(void*));
53
54 void * __llvm_cxxeh_current_uncaught_exception_isa(const std::type_info *Ty);
55 void *__llvm_cxxeh_begin_catch(void);
56 void __llvm_cxxeh_end_catch(void);
57
58 void __llvm_cxxeh_rethrow(void);
59 }
60
61 #endif
0 //===- exception.h - Generic language-independent exceptions ----*- C++ -*-===//
1 //
2 // This file defines the the shared data structures used by all language
3 // specific exception handling runtime libraries.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef EXCEPTION_H
8 #define EXCEPTION_H
9
10 typedef struct llvm_exception {
11 // ExceptionDestructor - This call-back function is used to destroy the
12 // current exception, without requiring the caller to know what the concrete
13 // exception type is.
14 //
15 void (*ExceptionDestructor)(struct llvm_exception *);
16
17 // ExceptionType - This field identifies what runtime library this exception
18 // came from. Currently defined values are:
19 // 0 - Error
20 // 1 - longjmp exception (see longjmp-exception.c)
21 // 2 - C++ exception (see c++-exception.c)
22 //
23 unsigned ExceptionType;
24
25 // Next - This points to the next exception in the current stack.
26 struct llvm_exception *Next;
27
28 // HandlerCount - This is a count of the number of handlers which have
29 // currently caught this exception. If the handler is caught and this number
30 // falls to zero, the exception is destroyed.
31 //
32 unsigned HandlerCount;
33 } llvm_exception;
34
35 enum {
36 ErrorException = 0,
37 LongjmpException = 1,
38 CXXException = 2,
39 };
40
41 // Language independent exception handling API...
42 //
43 extern "C" {
44 bool __llvm_eh_has_uncaught_exception(void);
45 void *__llvm_eh_current_uncaught_exception_type(unsigned HandlerType);
46 }
47
48 #endif
0 LEVEL = ../../..
1 BYTECODE_LIBRARY=1
2 DONT_BUILD_RELINKED=1
3 LIBRARYNAME=exception
4
5 #Source = crtend.c listend.ll
6
7 ###EXPORTED_SYMBOL_LIST = __main,llvm.global_ctors,llvm.global_dtors
8
9 include $(LEVEL)/Makefile.common
10
11
12 $(LLVMGCCDIR)/bytecode-libs/crtend.o: $(LIBNAME_BC)
13 @cp $< $@
14
15 install:: $(LLVMGCCDIR)/bytecode-libs/crtend.o
16 @rm $(LLVMGCCDIR)/bytecode-libs/libcrtend.bc