Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGen/2005-01-02-ConstantInits.c
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

69 lines
2.8 KiB
C

// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --check-globals --global-value-regex "[A-Za-z].*"
// RUN: %clang_cc1 -triple=x86_64-unknown-linux %s -emit-llvm -o - | FileCheck %s
// This tests all kinds of hard cases with initializers and
// array subscripts. This corresponds to PR487.
struct X { int a[2]; };
extern int bar();
//.
// CHECK: @test.i23 = internal global i32 4, align 4
// CHECK: @i = global i32 4, align 4
// CHECK: @Arr = global [100 x i32] zeroinitializer, align 16
// CHECK: @foo2.X = internal global ptr getelementptr (i8, ptr @Arr, i64 196), align 8
// CHECK: @foo2.i23 = internal global i32 0, align 4
//.
// CHECK-LABEL: define {{[^@]+}}@test
// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @test.i23, align 4
// CHECK-NEXT: ret i32 [[TMP0]]
//
int test(void) {
static int i23 = (int) &(((struct X *)0)->a[1]);
return i23;
}
int i = (int) &( ((struct X *)0) -> a[1]);
int Arr[100];
// CHECK-LABEL: define {{[^@]+}}@foo
// CHECK-SAME: (i32 noundef [[I:%.*]]) #[[ATTR0]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[I_ADDR:%.*]] = alloca i32, align 4
// CHECK-NEXT: store i32 [[I]], ptr [[I_ADDR]], align 4
// CHECK-NEXT: [[CALL:%.*]] = call i32 (ptr, ...) @bar(ptr noundef getelementptr inbounds ([100 x i32], ptr @Arr, i64 0, i64 49))
// CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[I_ADDR]], align 4
// CHECK-NEXT: [[IDXPROM:%.*]] = sext i32 [[TMP0]] to i64
// CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [100 x i32], ptr @Arr, i64 0, i64 [[IDXPROM]]
// CHECK-NEXT: [[CALL1:%.*]] = call i32 (ptr, ...) @bar(ptr noundef [[ARRAYIDX]])
// CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL]], [[CALL1]]
// CHECK-NEXT: ret i32 [[ADD]]
//
int foo(int i) { return bar(&Arr[49])+bar(&Arr[i]); }
// CHECK-LABEL: define {{[^@]+}}@foo2
// CHECK-SAME: (i32 noundef [[I:%.*]]) #[[ATTR0]] {
// CHECK-NEXT: entry:
// CHECK-NEXT: [[I_ADDR:%.*]] = alloca i32, align 4
// CHECK-NEXT: [[P:%.*]] = alloca ptr, align 8
// CHECK-NEXT: store i32 [[I]], ptr [[I_ADDR]], align 4
// CHECK-NEXT: store ptr @Arr, ptr [[P]], align 8
// CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[P]], align 8
// CHECK-NEXT: [[INCDEC_PTR:%.*]] = getelementptr inbounds nuw i32, ptr [[TMP0]], i32 1
// CHECK-NEXT: store ptr [[INCDEC_PTR]], ptr [[P]], align 8
// CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[I_ADDR]], align 4
// CHECK-NEXT: [[IDX_EXT:%.*]] = sext i32 [[TMP1]] to i64
// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i32, ptr @Arr, i64 [[IDX_EXT]]
// CHECK-NEXT: [[CALL:%.*]] = call i32 (ptr, ...) @bar(ptr noundef [[ADD_PTR]])
// CHECK-NEXT: ret i32 [[CALL]]
//
int foo2(int i) {
static const int *X = &Arr[49];
static int i23 = (int) &( ((struct X *)0) -> a[0]);
int *P = Arr;
++P;
return bar(Arr+i);
}