Commit Graph

4 Commits

Author SHA1 Message Date
Tony Allevato
c68c4333b9 [NFC] Small cleanup in stdlib/public/runtime.
These changes fix minor issues that cause compilation errors with our
C++ toolchain's stricter default settings:

* `Exception.cpp`: The return type of `__cxa_begin_catch` should be
  `void *`, not `void` (see https://libcxxabi.llvm.org/spec.html).
* `Leaks.mm`: `''` is not a valid C char literal; use `'\0'` instead.
2024-09-17 10:45:28 -04:00
Alastair Houghton
88aa111677 [Runtime] Don't try to call __cxa_begin_catch if -fno-exceptions.
We shouldn't call `__cxa_begin_catch` if built with `-fno-exceptions`,
because it's possible that the environment we're in won't include
the `__cxa_begin_catch` routine.

rdar://122995672
2024-02-16 09:35:03 +00:00
Alastair Houghton
25e9ca02b0 [Runtime][Test] Add a leading underscore to swift_exceptionPersonality.
The other new runtime functions appear to have a leading underscore.
It makes sense in this case because we don't expect anything to call
this directly (other than the unwinder).

rdar://120952971
2024-02-06 16:21:09 +00:00
Alastair Houghton
143a473aa4 [Runtime][IRGen] Trap C++ exceptions on *throw*, not catch.
The previous approach was effectively to catch the exception and then
run a trap instruction.  That has the unfortunate feature that we end
up with a crash at the catch site, not at the throw site, which leaves
us with very little information about which exception was thrown or
where from.

(Strictly we do have the exception pointer and could obtain exception
information, but it still won't tell us what threw it.)

Instead of that, set a personality function for Swift functions that
call potentially throwing code, and have that personality function
trap the exception during phase 1 (i.e. *before* the original stack
has been unwound).

rdar://120952971
2024-02-06 16:19:17 +00:00