4 void erringFunc() { throw std::runtime_error("Hello"); }
6 void libCallA() { erringFunc(); }
8 void libCallB() { throw std::runtime_error("World"); }
13 } catch (std::runtime_error
&E
) {
14 std::cout
<< "handleEventA: unhandled error " << E
.what() << "\n";
22 } catch (std::runtime_error
&E
) {
23 std::cout
<< "handleEventB: handle error " << E
.what() << "\n";
28 unsigned RemainingEvents
= 5;
32 if (RemainingEvents
> 0) {
34 return (RemainingEvents
% 3) + 1;
40 class TerminateException
: public std::runtime_error
{
42 TerminateException() : std::runtime_error("Time to stop!") {}
45 void runEventLoop(EventGen
&EG
) {
48 int Ev
= EG
.generateEvent();
51 throw TerminateException();
59 } catch (TerminateException
&E
) {
60 std::cout
<< "Terminated?\n";
62 } catch (std::runtime_error
&E
) {
63 std::cout
<< "Unhandled error: " << E
.what() << "\n";
69 ~CleanUp() { std::cout
<< "Cleanup\n"; }
77 } catch (TerminateException
&E
) {
78 std::cout
<< "Terminated!\n";
84 REQUIRES: system-linux
86 RUN: %clang++ %cflags %s -o %t.exe -Wl,-q
87 RUN: llvm-bolt %t.exe --split-functions --split-strategy=randomN \
88 RUN: --split-all-cold --split-eh --bolt-seed=7 -o %t.bolt
89 RUN: %t.bolt | FileCheck %s
91 CHECK: handleEventB: handle error World
92 CHECK-NEXT: handleEventA: unhandled error Hello
93 CHECK-NEXT: Unhandled error: Hello
94 CHECK-NEXT: handleEventB: handle error World
95 CHECK-NEXT: handleEventA: unhandled error Hello
96 CHECK-NEXT: Unhandled error: Hello
97 CHECK-NEXT: Terminated?
99 CHECK-NEXT: Terminated!