This originally came up as an issue with libc++abi support (#152), but is not specific to that ABI.
* Use the C++ runtime to check for uncaught C++ exceptions.
As discussed in #152, use the function defined in the Itanium C++ ABI to
check whether the thrown exception is the current caught C++ exception
and needs rethrowing via `__cxa_rethrow()`.
Co-authored-by: Niels Grewe <grewe@ocean-insights.com>
Co-authored-by: David Chisnall <gnustep@theravensnest.org>
libsupc++ is more aggressive about internal consistency checks than
libcxxrt, so we need to be more careful in the interop. The tests from
PR #138 now pass for me on Debian with libsupc++.
* Make sure the unwind state is synchronised between the Objective-C
and C++ exception objects.
* Reintroduce the is-pointer callback so that `__cxa_begin_catch`
adjusts the pointer correctly. Objective-C++ code uses
`__cxa_begin_catch` without the `objc_begin_catch` wrapper and the
runtime does not call the `__do_catch` method on the type info if the
type info is an exact match, so the caught object ended up being a
pointer to the object. This also meant that we needed to remove the
double dereference in the `__do_catch` methods.
* Introduce a subclass of `std::type_info` for all Objective-C types
and move the `virtual` functions there. This should simplify
supporting libc++abi.
We now, the first time we encounter a foreign exception, throw a C++
exception through a frame that has a custom personality function and
probe the layout of the __cxa_exception structure.
We then use the offsets learned from this along with the public ABI
functions for allocating the structure.
At the same time, add a test that we are correctly setting the count of
uncaught exceptions.
Fixes#146
On Itanium C++ ABI platforms, there are a lot of different variations
that have subtly different structure layouts. This commit adds a
run-time test that throws a C++ exception through a function that has
its personality function replaced with a wrapper so that we can inspect
a C++ exception in controlled conditions.
Initially, this just detects the exception type value used for C++
exceptions.
The reworked wrapping of C++ exceptions meant that we were missing a
dereference of the result of __cxa_begin_catch.
Add a test that triggers this issue. It would have occurred in the
non-ARC version if we actually did anything with the exception, but
compiling it in ARC mode makes the compiler insert retain / autorelease
around the exception object to ensure that it remains live.
Throwing an Objective-C exception through a C++ catch block was broken.
This was because the C++ code inserts a cleanup handler to make sure
that it invokes `__cxa_end_catch`. Unwinding through this catchup
transformed the Objective-C exception into a C++ one. This case should
have been handled, except for two bugs:
1. A typo (`#ifdef` instead of `#ifndef`) meant that we were not
extracting the Objective-C exception from the C++ object.
2. We were skipping everything except catchalls after the search phase,
because we lose some information in the transformation.
Fixes#49
clang trunk if -fobjc-runtime-1.7 is specified and provides significantly
better interoperability with foreign exceptions.
Note: Most of the exception tests will not pass with gcc or clang < 3.3. They
test things that are impossible to implement quite correctly with the
GCC-compatible exception ABI.
Also updated the release notes to reflect recent improvements.