Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

101 lines
2.1 KiB
C++

#include <iostream>
#include <stdexcept>
void erringFunc() { throw std::runtime_error("Hello"); }
void libCallA() { erringFunc(); }
void libCallB() { throw std::runtime_error("World"); }
void handleEventA() {
try {
libCallA();
} catch (std::runtime_error &E) {
std::cout << "handleEventA: unhandled error " << E.what() << "\n";
throw;
}
}
void handleEventB() {
try {
libCallB();
} catch (std::runtime_error &E) {
std::cout << "handleEventB: handle error " << E.what() << "\n";
}
}
class EventGen {
unsigned RemainingEvents = 5;
public:
int generateEvent() {
if (RemainingEvents > 0) {
--RemainingEvents;
return (RemainingEvents % 3) + 1;
}
return 0;
}
};
class TerminateException : public std::runtime_error {
public:
TerminateException() : std::runtime_error("Time to stop!") {}
};
void runEventLoop(EventGen &EG) {
while (true) {
try {
int Ev = EG.generateEvent();
switch (Ev) {
case 0:
throw TerminateException();
case 1:
handleEventA();
break;
case 2:
handleEventB();
break;
}
} catch (TerminateException &E) {
std::cout << "Terminated?\n";
throw;
} catch (std::runtime_error &E) {
std::cout << "Unhandled error: " << E.what() << "\n";
}
}
}
struct CleanUp {
~CleanUp() { std::cout << "Cleanup\n"; }
};
int main() {
EventGen EG;
try {
CleanUp CU;
runEventLoop(EG);
} catch (TerminateException &E) {
std::cout << "Terminated!\n";
}
return 0;
}
/*
REQUIRES: system-linux
RUN: %clang++ %cflags %s -o %t.exe -Wl,-q
RUN: llvm-bolt %t.exe --split-functions --split-strategy=randomN \
RUN: --split-all-cold --split-eh --bolt-seed=7 -o %t.bolt
RUN: %t.bolt | FileCheck %s
CHECK: handleEventB: handle error World
CHECK-NEXT: handleEventA: unhandled error Hello
CHECK-NEXT: Unhandled error: Hello
CHECK-NEXT: handleEventB: handle error World
CHECK-NEXT: handleEventA: unhandled error Hello
CHECK-NEXT: Unhandled error: Hello
CHECK-NEXT: Terminated?
CHECK-NEXT: Cleanup
CHECK-NEXT: Terminated!
*/