1// RUN: %clangxx -c -o %t %s
2// RUN: %llvm_jitlink -slab-allocate=20Mb %t
3//
4// REQUIRES: system-darwin && host-arch-compatible
5
6// Test that we can throw and catch an exception through a large number of
7// stack frames. The number (1022) is chosen to force emission of multiple
8// unwind info second-level pages.
9
10template <int N>
11void f() { try { f<N - 1>(); } catch (...) { throw; } }
12
13template <>
14void f<0>() { throw 42; }
15
16int main(int argc, char *argv[]) {
17 try {
18 f<1020>();
19 } catch (int n) {
20 return 42 - n;
21 }
22 return 1;
23}
24
25

source code of compiler-rt/test/orc/TestCases/Darwin/Generic/exceptions-stress-test-tower.cpp