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

56 lines
1.4 KiB
C++

// RUN: %clangxx_cfi %debug_info_flags -fsanitize-stats -o %t %s
// RUN: env SANITIZER_STATS_PATH=%t.stats %run %t
// RUN: sanstats %t.stats | FileCheck %s
// FIXME: We currently emit the wrong debug info under devirtualization.
// UNSUPPORTED: devirt
// FIXME: %t.stats must be transferred from device to host for this to work on Android.
// XFAIL: android
struct ABase {};
struct A : ABase {
virtual void vf() {}
void nvf() {}
};
extern "C" __attribute__((noinline)) void vcall(A *a) {
// CHECK: stats.cpp:[[@LINE+1]] {{_?}}vcall cfi-vcall 37
a->vf();
}
extern "C" __attribute__((noinline)) void nvcall(A *a) {
// CHECK: stats.cpp:[[@LINE+1]] {{_?}}nvcall cfi-nvcall 51
a->nvf();
}
extern "C" __attribute__((noinline)) A *dcast(A *a) {
// CHECK: stats.cpp:[[@LINE+1]] {{_?}}dcast cfi-derived-cast 24
return (A *)(ABase *)a;
}
extern "C" __attribute__((noinline)) A *ucast(A *a) {
// CHECK: stats.cpp:[[@LINE+1]] {{_?}}ucast cfi-unrelated-cast 81
return (A *)(char *)a;
}
extern "C" __attribute__((noinline)) void unreachable(A *a) {
// CHECK-NOT: unreachable
a->vf();
}
int main() {
A a;
for (unsigned i = 0; i != 37; ++i)
vcall(&a);
for (unsigned i = 0; i != 51; ++i)
nvcall(&a);
for (unsigned i = 0; i != 24; ++i)
dcast(&a);
for (unsigned i = 0; i != 81; ++i)
ucast(&a);
for (unsigned i = 0; i != 0; ++i)
unreachable(&a);
}