Skip to content

Commit 58926c9

Browse files
author
Howard Hinnant
committed
Made some minor tweaks to __cxa_rethrow
llvm-svn: 146396
1 parent ff07af1 commit 58926c9

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

libcxxabi/src/cxa_exception.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ void __cxa_end_catch() {
265265
__cxa_exception *current_exception = globals->caughtExceptions;
266266

267267
if (NULL != current_exception) {
268+
// TODO: Handle foreign exceptions? How?
268269
if (current_exception->handlerCount < 0) {
269270
// The exception has been rethrown
270271
if (0 == incrementHandlerCount(current_exception)) {
@@ -319,19 +320,22 @@ std::type_info * __cxa_current_exception_type() {
319320
(in an implementation-defined way) as being rethrown.
320321
* If the caughtExceptions stack is empty, it calls terminate()
321322
(see [C++FDIS] [except.throw], 15.1.8).
322-
* It then returns to the handler that called it, which must call
323-
__cxa_end_catch(), perform any necessary cleanup, and finally
324-
call _Unwind_Resume() to continue unwinding.
323+
* It then calls _Unwind_Resume_or_Rethrow which should not return
324+
(terminate if it does).
325325
*/
326326
extern LIBCXXABI_NORETURN void __cxa_rethrow() {
327327
__cxa_eh_globals *globals = __cxa_get_globals();
328-
__cxa_exception *exception = exception_from_exception_object(globals->caughtExceptions );
328+
__cxa_exception *exception = globals->caughtExceptions;
329329

330330
if (NULL == exception) // there's no current exception!
331331
std::terminate ();
332332

333-
// Mark the exception as being rethrown
334-
exception->handlerCount = -exception->handlerCount ; // TODO: Atomic
333+
// TODO: Handle foreign exceptions? How?
334+
335+
// Mark the exception as being rethrown (reverse the effects of __cxa_begin_catch)
336+
exception->handlerCount = -exception->handlerCount;
337+
globals->uncaughtExceptions += 1;
338+
// __cxa_end_catch will remove this exception from the caughtExceptions stack if necessary
335339

336340
#if __arm__
337341
(void) _Unwind_SjLj_Resume_or_Rethrow(&exception->unwindHeader);

libcxxabi/www/spec.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@
227227
</p>
228228
</blockquote>
229229
</td>
230-
<td></td>
231-
<td></td>
232-
<td></td>
230+
<td>&#10003;</td>
231+
<td>&#10003;</td>
232+
<td>&#10003;</td>
233233
</tr>
234234

235235
<tr>

0 commit comments

Comments
 (0)