Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CIR/func-simple.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

96 lines
3.5 KiB
C++

// Simple functions
// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o - | FileCheck %s
void empty() { }
// CHECK: cir.func{{.*}} @_Z5emptyv() {
// CHECK: cir.return
// CHECK: }
void voidret() { return; }
// CHECK: cir.func{{.*}} @_Z7voidretv() {
// CHECK: cir.return
// CHECK: }
int intfunc() { return 42; }
// CHECK: cir.func{{.*}} @_Z7intfuncv() -> !s32i {
// CHECK: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"] {alignment = 4 : i64}
// CHECK: %1 = cir.const #cir.int<42> : !s32i
// CHECK: cir.store %1, %0 : !s32i, !cir.ptr<!s32i>
// CHECK: %2 = cir.load %0 : !cir.ptr<!s32i>, !s32i
// CHECK: cir.return %2 : !s32i
// CHECK: }
int scopes() {
{
{
return 99;
}
}
}
// CHECK: cir.func{{.*}} @_Z6scopesv() -> !s32i {
// CHECK: %0 = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"] {alignment = 4 : i64}
// CHECK: cir.scope {
// CHECK: cir.scope {
// CHECK: %1 = cir.const #cir.int<99> : !s32i
// CHECK: cir.store %1, %0 : !s32i, !cir.ptr<!s32i>
// CHECK: %2 = cir.load %0 : !cir.ptr<!s32i>, !s32i
// CHECK: cir.return %2 : !s32i
// CHECK: }
// CHECK: }
// CHECK: cir.trap
// CHECK: }
long longfunc() { return 42l; }
// CHECK: cir.func{{.*}} @_Z8longfuncv() -> !s64i
// CHECK: %0 = cir.alloca !s64i, !cir.ptr<!s64i>, ["__retval"] {alignment = 8 : i64}
// CHECK: %1 = cir.const #cir.int<42> : !s64i
// CHECK: cir.store %1, %0 : !s64i, !cir.ptr<!s64i>
// CHECK: %2 = cir.load %0 : !cir.ptr<!s64i>, !s64i
// CHECK: cir.return %2 : !s64i
// CHECK: }
unsigned unsignedfunc() { return 42u; }
// CHECK: cir.func{{.*}} @_Z12unsignedfuncv() -> !u32i
// CHECK: %0 = cir.alloca !u32i, !cir.ptr<!u32i>, ["__retval"] {alignment = 4 : i64}
// CHECK: %1 = cir.const #cir.int<42> : !u32i
// CHECK: cir.store %1, %0 : !u32i, !cir.ptr<!u32i>
// CHECK: %2 = cir.load %0 : !cir.ptr<!u32i>, !u32i
// CHECK: cir.return %2 : !u32i
// CHECK: }
unsigned long long ullfunc() { return 42ull; }
// CHECK: cir.func{{.*}} @_Z7ullfuncv() -> !u64i
// CHECK: %0 = cir.alloca !u64i, !cir.ptr<!u64i>, ["__retval"] {alignment = 8 : i64}
// CHECK: %1 = cir.const #cir.int<42> : !u64i
// CHECK: cir.store %1, %0 : !u64i, !cir.ptr<!u64i>
// CHECK: %2 = cir.load %0 : !cir.ptr<!u64i>, !u64i
// CHECK: cir.return %2 : !u64i
// CHECK: }
bool boolfunc() { return true; }
// CHECK: cir.func{{.*}} @_Z8boolfuncv() -> !cir.bool {
// CHECK: %0 = cir.alloca !cir.bool, !cir.ptr<!cir.bool>, ["__retval"] {alignment = 1 : i64}
// CHECK: %1 = cir.const #true
// CHECK: cir.store %1, %0 : !cir.bool, !cir.ptr<!cir.bool>
// CHECK: %2 = cir.load %0 : !cir.ptr<!cir.bool>, !cir.bool
// CHECK: cir.return %2 : !cir.bool
// CHECK: }
float floatfunc() { return 42.42f; }
// CHECK: cir.func{{.*}} @_Z9floatfuncv() -> !cir.float {
// CHECK: %0 = cir.alloca !cir.float, !cir.ptr<!cir.float>, ["__retval"] {alignment = 4 : i64}
// CHECK: %1 = cir.const #cir.fp<4.242
// CHECK: cir.store %1, %0 : !cir.float, !cir.ptr<!cir.float>
// CHECK: %2 = cir.load %0 : !cir.ptr<!cir.float>, !cir.float
// CHECK: cir.return %2 : !cir.float
// CHECK: }
double doublefunc() { return 42.42; }
// CHECK: cir.func{{.*}} @_Z10doublefuncv() -> !cir.double {
// CHECK: %0 = cir.alloca !cir.double, !cir.ptr<!cir.double>, ["__retval"] {alignment = 8 : i64}
// CHECK: %1 = cir.const #cir.fp<4.242
// CHECK: cir.store %1, %0 : !cir.double, !cir.ptr<!cir.double>
// CHECK: %2 = cir.load %0 : !cir.ptr<!cir.double>, !cir.double
// CHECK: cir.return %2 : !cir.double
// CHECK: }