Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGen/fake-use-lambda.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

44 lines
1.2 KiB
C++

// RUN: %clang_cc1 %s -triple=%itanium_abi_triple -O1 -emit-llvm -fextend-variable-liveness -o - | FileCheck %s
// Make sure we don't crash compiling a lambda that is not nested in a function.
// We also check that fake uses are properly issued in lambdas.
int glob;
extern int foo();
struct S {
static const int a;
};
const int S::a = [](int b) __attribute__((noinline)) {
return b * foo();
}
(glob);
int func(int param) {
return ([=](int lambdaparm) __attribute__((noinline))->int {
int lambdalocal = lambdaparm * 2;
return lambdalocal;
}(glob));
}
// We are looking for the first lambda's call operator, which should contain
// 2 fake uses, one for 'b' and one for its 'this' pointer (in that order).
// The mangled function name contains a $_0, followed by 'cl'.
// This lambda is an orphaned lambda, i.e. one without lexical parent.
//
// CHECK-LABEL: define internal {{.+\"_Z.+\$_0.*cl.*\"}}
// CHECK-NOT: ret
// CHECK: fake.use(i32
// CHECK-NOT: ret
// CHECK: fake.use(ptr
// The second lambda. We are looking for 3 fake uses.
// CHECK-LABEL: define internal {{.+\"_Z.+\$_0.*cl.*\"}}
// CHECK-NOT: ret
// CHECK: fake.use(i32
// CHECK-NOT: ret
// CHECK: fake.use(i32
// CHECK-NOT: ret
// CHECK: fake.use(ptr