Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGenCXX/throw-expressions.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

120 lines
2.2 KiB
C++

// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -Wno-unreachable-code -Werror -triple x86_64-linux-gnu -emit-llvm -o - %s | FileCheck %s
int val = 42;
int& test1() {
return throw val, val;
}
int test2() {
return val ? throw val : val;
}
void test3() {
throw false;
}
// PR10582
int test4() {
return 1 ? throw val : val;
}
// PR15923
int test5(bool x, bool y, int z) {
return (x ? throw 1 : y) ? z : throw 2;
}
// CHECK-LABEL: define{{.*}} i32 @_Z5test5bbi(
// CHECK: br i1
//
// x.true:
// CHECK: call void @__cxa_throw(
// CHECK-NEXT: unreachable
//
// x.false:
// CHECK: br i1
//
// y.true:
// CHECK: load i32, ptr
// CHECK: br label
//
// y.false:
// CHECK: call void @__cxa_throw(
// CHECK-NEXT: unreachable
//
// end:
// CHECK: ret i32
int test6(bool x, bool y, int z) {
return (x ? throw 1 : y) ? z : (throw 2);
}
// CHECK-LABEL: define{{.*}} i32 @_Z5test6bbi(
// CHECK: br i1
//
// x.true:
// CHECK: call void @__cxa_throw(
// CHECK-NEXT: unreachable
//
// x.false:
// CHECK: br i1
//
// y.true:
// CHECK: load i32, ptr
// CHECK: br label
//
// y.false:
// CHECK: call void @__cxa_throw(
// CHECK-NEXT: unreachable
//
// end:
// CHECK: ret i32
namespace DR1560 {
struct A {
~A();
};
extern bool b;
A get();
// CHECK-LABEL: @_ZN6DR15601bE
const A &r = b ? get() : throw 0;
// CHECK-NOT: call {{.*}}@_ZN6DR15601AD1Ev
// CHECK: call {{.*}} @__cxa_atexit(ptr @_ZN6DR15601AD1Ev, ptr @_ZGRN6DR15601rE
// CHECK-NOT: call {{.*}}@_ZN6DR15601AD1Ev
// PR28184
void conditional_throw() {
int a;
(true ? throw 0 : a) = 0; // CHECK: call void @__cxa_throw({{.*}})
}
}
// CHECK-LABEL: define{{.*}} void @_Z5test7b(
void test7(bool cond) {
// CHECK: br i1
//
// x.true:
// CHECK: call void @__cxa_throw(
// CHECK-NEXT: unreachable
//
// x.false:
// CHECK: br label
//
// end:
// CHECK: ret void
cond ? throw test7 : val;
}
// CHECK-LABEL: define{{.*}} nonnull align 4 dereferenceable(4) ptr @_Z5test8b(
int &test8(bool cond) {
// CHECK: br i1
//
// x.true:
// CHECK: br label
//
// x.false:
// CHECK: call void @__cxa_throw(
// CHECK-NEXT: unreachable
//
// end:
// CHECK: ret ptr @val
return cond ? val : ((throw "foo"));
}