Files
RedBear-OS/local/recipes/dev/libclc/source/clang/test/CodeGenCXX/address-space-cast.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

77 lines
3.1 KiB
C++

// RUN: %clang_cc1 %s -triple=amdgcn-amd-amdhsa -emit-llvm -o - | FileCheck %s
#define __private__ __attribute__((address_space(5)))
void func_pchar(__private__ char *x);
void func_pvoid(__private__ void *x);
void func_pint(__private__ int *x);
class Base {
};
class Derived : public Base {
};
void fn(Derived *p) {
__private__ Base *b = (__private__ Base *)p;
}
// CHECK-LABEL: test_cast
void test_cast(char *gen_char_ptr, void *gen_void_ptr, int *gen_int_ptr) {
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: store ptr addrspace(5) %[[cast]]
__private__ char *priv_char_ptr = (__private__ char *)gen_char_ptr;
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: store ptr addrspace(5) %[[cast]]
priv_char_ptr = (__private__ char *)gen_void_ptr;
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: store ptr addrspace(5) %[[cast]]
priv_char_ptr = (__private__ char *)gen_int_ptr;
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: store ptr addrspace(5) %[[cast]]
__private__ void *priv_void_ptr = (__private__ void *)gen_char_ptr;
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: store ptr addrspace(5) %[[cast]]
priv_void_ptr = (__private__ void *)gen_void_ptr;
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: store ptr addrspace(5) %[[cast]]
priv_void_ptr = (__private__ void *)gen_int_ptr;
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: store ptr addrspace(5) %[[cast]]
__private__ int *priv_int_ptr = (__private__ int *)gen_void_ptr;
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(ptr addrspace(5) noundef %[[cast]])
func_pchar((__private__ char *)gen_char_ptr);
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(ptr addrspace(5) noundef %[[cast]])
func_pchar((__private__ char *)gen_void_ptr);
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: call void @_Z10func_pcharPU3AS5c(ptr addrspace(5) noundef %[[cast]])
func_pchar((__private__ char *)gen_int_ptr);
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(ptr addrspace(5) noundef %[[cast]])
func_pvoid((__private__ void *)gen_char_ptr);
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(ptr addrspace(5) noundef %[[cast]])
func_pvoid((__private__ void *)gen_void_ptr);
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: call void @_Z10func_pvoidPU3AS5v(ptr addrspace(5) noundef %[[cast]])
func_pvoid((__private__ void *)gen_int_ptr);
// CHECK: %[[cast:.*]] = addrspacecast ptr %{{.*}} to ptr addrspace(5)
// CHECK-NEXT: call void @_Z9func_pintPU3AS5i(ptr addrspace(5) noundef %[[cast]])
func_pint((__private__ int *)gen_void_ptr);
}