Files
RedBear-OS/local/recipes/dev/libclc/source/compiler-rt/test/cfi/simple-pass.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

127 lines
1.7 KiB
C++

// -mretpoline does not work yet on Darwin.
// XFAIL: darwin
// RUN: %clangxx_cfi -o %t %s
// RUN: %run %t
// RUN: %clangxx_cfi -mretpoline -o %t2 %s
// RUN: %run %t2
// Tests that the CFI mechanism does not crash the program when making various
// kinds of valid calls involving classes with various different linkages and
// types of inheritance, and both virtual and non-virtual member functions.
#include "utils.h"
struct A {
virtual void f();
void g();
};
void A::f() {}
void A::g() {}
struct A2 : A {
virtual void f();
void g();
};
void A2::f() {}
void A2::g() {}
struct B {
virtual void f() {}
void g() {}
};
struct B2 : B {
virtual void f() {}
void g() {}
};
namespace {
struct C {
virtual void f();
void g();
};
void C::f() {}
void C::g() {}
struct C2 : C {
virtual void f();
void g();
};
void C2::f() {}
void C2::g() {}
struct D {
virtual void f() {}
void g() {}
};
struct D2 : D {
virtual void f() {}
void g() {}
};
}
struct E {
virtual void f() {}
void g() {}
};
struct E2 : virtual E {
virtual void f() {}
void g() {}
};
int main() {
A *a = new A;
break_optimization(a);
a->f();
a->g();
a = new A2;
break_optimization(a);
a->f();
a->g();
B *b = new B;
break_optimization(b);
b->f();
b->g();
b = new B2;
break_optimization(b);
b->f();
b->g();
C *c = new C;
break_optimization(c);
c->f();
c->g();
c = new C2;
break_optimization(c);
c->f();
c->g();
D *d = new D;
break_optimization(d);
d->f();
d->g();
d = new D2;
break_optimization(d);
d->f();
d->g();
E *e = new E;
break_optimization(e);
e->f();
e->g();
e = new E2;
break_optimization(e);
e->f();
e->g();
}