Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGenCXX/ubsan-global-alignment.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

30 lines
1.0 KiB
C++

// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=alignment | FileCheck %s
struct S {
int I;
};
extern S g_S;
extern S array_S[];
// CHECK-LABEL: define{{.*}} i32 @_Z18load_extern_global
int load_extern_global() {
// FIXME: The IR builder constant-folds the alignment check away to 'true'
// here, so we never call the diagnostic. This is PR32630.
// CHECK-NOT: ptrtoint ptr {{.*}} to i32, !nosanitize
// CHECK: [[I:%.*]] = load i32, ptr @g_S, align 4
// CHECK-NEXT: ret i32 [[I]]
return g_S.I;
}
// CHECK-LABEL: define{{.*}} i32 @_Z22load_from_extern_array
int load_from_extern_array(int I) {
// CHECK: [[I:%.*]] = getelementptr inbounds nuw %struct.S, ptr {{.*}}, i32 0, i32 0
// CHECK-NEXT: [[PTRTOINT:%.*]] = ptrtoint ptr [[I]] to i64, !nosanitize
// CHECK-NEXT: [[AND:%.*]] = and i64 [[PTRTOINT]], 3, !nosanitize
// CHECK-NEXT: [[ICMP:%.*]] = icmp eq i64 [[AND]], 0, !nosanitize
// CHECK-NEXT: br i1 [[ICMP]]
// CHECK: call void @__ubsan_handle_type_mismatch
return array_S[I].I;
}