Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/Analysis/ftime-trace.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

57 lines
2.1 KiB
C++

// RUN: %clang_analyze_cc1 -analyzer-checker=core %s -ftime-trace=%t.raw.json -ftime-trace-granularity=0 -verify
// RUN: %python -c 'import json, sys; print(json.dumps(json.load(sys.stdin), indent=4))' < %t.raw.json > %t.formatted.json
// RUN: FileCheck --input-file=%t.formatted.json --check-prefix=CHECK %s
// The trace file is rather large, but it should contain at least the duration of the analysis of 'f':
//
// CHECK: "name": "HandleCode f",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "detail": "f()",
// CHECK-NEXT: "file": "{{.+}}ftime-trace.cpp",
// CHECK-NEXT: "line": {{[0-9]+}}
// CHECK-NEXT: }
// If any reports are found, "flushing" their equivalence class (EQC) is a separate action:
//
// CHECK: "name": "Flushing EQC Division by zero",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "detail": "core.DivideZero",
// CHECK-NEXT: "file": "{{.+}}ftime-trace.cpp",
// CHECK-NEXT: "line": {{[0-9]+}}
// CHECK-NEXT: }
// The trace also contains durations of each step, but they are so short that they are not reliably present
// in each run. However, they are also aggregated into Total *, for example:
//
// CHECK: "name": "Total dispatchWorkItem PostStmt",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "count": {{[0-9]+}},
// CHECK-NEXT: "avg ms": {{[0-9]+}}
// CHECK-NEXT: }
// Additionally, the trace lists checker hook points (again, relying on totals here):
//
// CHECK: "name": "Total CheckerManager::runCheckersForStmt (Pre)",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "count": {{[0-9]+}},
// CHECK-NEXT: "avg ms": {{[0-9]+}}
// CHECK-NEXT: }
// Finally, each checker call back is also present:
//
// CHECK: "name": "Total Stmt:DivZeroChecker",
// CHECK-NEXT: "args": {
// CHECK-NEXT: "count": {{[0-9]+}},
// CHECK-NEXT: "avg ms": {{[0-9]+}}
// CHECK-NEXT: }
bool coin();
int f() {
int x = 0;
int y = 0;
while (coin()) {
x = 1;
}
return x / y; // expected-warning{{Division by zero}}
}