Files
RedBear-OS/local/recipes/dev/libclc/source/bolt/test/lsda-section-name.cpp
T
vasilito cb424d7448 build: static patch-sanity linter (shift-left the malformed-patch class)
verify-patch-sanity.py validates every active recipe .patch has internally-
consistent hunk line counts — catching the 'malformed patch at line N' failure
at commit/CI/preflight time instead of hours into a cook. This cycle hit that
class three times (qtwaylandscanner, sddm, xwayland), each only discovered when
cookbook tried to apply the patch.

Running it across the repo found 29 latent malformed patches (validated against
GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22').
They were harmless only because they sit in vendored recipes (baked, not re-
applied) — but would fail on any version-bump re-derivation. --fix recounts the
hunk headers (body untouched) and repaired all 29.

Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test
(test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats
(empty placeholders, bare-@@ git hunks).
2026-08-01 05:13:02 +03:00

48 lines
1.3 KiB
C++

// This test check that LSDA section named by .gcc_except_table.main is
// disassembled by BOLT.
// RUN: %clang++ %cxxflags -O3 -no-pie -c %s -o %t.o
// RUN: %clang++ %cxxflags -O3 -no-pie -fuse-ld=lld %t.o -o %t
// RUN: llvm-objcopy --rename-section .gcc_except_table=.gcc_except_table.main %t
// RUN: llvm-readelf -SW %t | FileCheck %s
// RUN: llvm-bolt %t -o %t.bolt
// CHECK: .gcc_except_table.main
#include <iostream>
class MyException : public std::exception {
public:
const char *what() const throw() {
return "Custom Exception: an error occurred!";
}
};
int divide(int a, int b) {
if (b == 0) {
throw MyException();
}
return a / b;
}
int main() {
try {
int result = divide(10, 2); // normal case
std::cout << "Result: " << result << std::endl;
result = divide(5, 0); // will cause exception
std::cout << "Result: " << result << std::endl;
// this line will not execute
} catch (const MyException &e) {
// catch custom exception
std::cerr << "Caught exception: " << e.what() << std::endl;
} catch (const std::exception &e) {
// catch other C++ exceptions
std::cerr << "Caught exception: " << e.what() << std::endl;
} catch (...) {
// catch all other exceptions
std::cerr << "Caught unknown exception" << std::endl;
}
return 0;
}