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

99 lines
3.7 KiB
C

// RUN: %clang_cc1 %s -triple i386-unknown-unknown -Wno-implicit-function-declaration -fvisibility=default -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-DEFAULT
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -Wno-implicit-function-declaration -fvisibility=protected -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-PROTECTED
// RUN: %clang_cc1 %s -triple i386-unknown-unknown -Wno-implicit-function-declaration -fvisibility=hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN
// CHECK-DEFAULT: @g_def ={{.*}} global i32 0
// CHECK-DEFAULT: @g_com ={{.*}} global i32 0
// CHECK-DEFAULT: @g_ext = external global i32
// CHECK-DEFAULT: @g_deferred = internal global
// CHECK-PROTECTED: @g_def = protected global i32 0
// CHECK-PROTECTED: @g_com = protected global i32 0
// CHECK-PROTECTED: @g_ext = external global i32
// CHECK-PROTECTED: @g_deferred = internal global
// CHECK-HIDDEN: @g_def = hidden global i32 0
// CHECK-HIDDEN: @g_com = hidden global i32 0
// CHECK-HIDDEN: @g_ext = external global i32
// CHECK-HIDDEN: @g_deferred = internal global
int g_com;
int g_def = 0;
extern int g_ext;
static char g_deferred[] = "hello";
// CHECK-DEFAULT: @test4 = hidden global i32 10
// CHECK-PROTECTED: @test4 = hidden global i32 10
// CHECK-HIDDEN: @test4 = hidden global i32 10
// CHECK-DEFAULT-LABEL: define{{.*}} i32 @f_def()
// CHECK-DEFAULT: declare void @f_ext()
// CHECK-DEFAULT-LABEL: define internal void @f_deferred()
// CHECK-PROTECTED-LABEL: define protected i32 @f_def()
// CHECK-PROTECTED: declare void @f_ext()
// CHECK-PROTECTED-LABEL: define internal void @f_deferred()
// CHECK-HIDDEN-LABEL: define hidden i32 @f_def()
// CHECK-HIDDEN: declare void @f_ext()
// CHECK-HIDDEN-LABEL: define internal void @f_deferred()
extern void f_ext(void);
static void f_deferred(void) {
}
int f_def(void) {
f_ext();
f_deferred();
return g_com + g_def + g_ext + g_deferred[0];
}
// PR8457
// CHECK-DEFAULT-LABEL: define{{.*}} void @test1(
// CHECK-PROTECTED-LABEL: define{{.*}} void @test1(
// CHECK-HIDDEN-LABEL: define{{.*}} void @test1(
struct Test1 { int field; };
void __attribute__((visibility("default"))) test1(struct Test1 *v) { }
// CHECK-DEFAULT-LABEL: define{{.*}} void @test2()
// CHECK-PROTECTED-LABEL: define{{.*}} void @test2()
// CHECK-HIDDEN-LABEL: define{{.*}} void @test2()
void test2(void);
void __attribute__((visibility("default"))) test2(void) {}
// CHECK-DEFAULT-LABEL: define hidden void @test3()
// CHECK-PROTECTED-LABEL: define hidden void @test3()
// CHECK-HIDDEN-LABEL: define hidden void @test3()
extern void test3(void);
__private_extern__ void test3(void) {}
// Top of file.
extern int test4;
__private_extern__ int test4 = 10;
// CHECK-DEFAULT-LABEL: define hidden void @test5()
// CHECK-PROTECTED-LABEL: define hidden void @test5()
// CHECK-HIDDEN-LABEL: define hidden void @test5()
__attribute__((availability(macosx,introduced=10.5,deprecated=10.6)))
__private_extern__ void test5(void) {}
#pragma clang attribute push([[gnu::visibility("hidden")]], apply_to=function)
// CHECK-DEFAULT-LABEL: define hidden void @func()
// CHECK-PROTECTED-LABEL: define hidden void @func()
// CHECK-HIDDEN-LABEL: define hidden void @func()
void func(void) {}
void call(void) {
implicit_function();
// CHECK-DEFAULT-LABEL: declare hidden i32 @implicit_function(...)
// CHECK-PROTECTED-LABEL: declare hidden i32 @implicit_function(...)
// CHECK-HIDDEN-LABEL: declare hidden i32 @implicit_function(...)
}
#pragma clang attribute pop
void call2(void) {
implicit_function2();
// CHECK-DEFAULT-LABEL: declare i32 @implicit_function2(...)
// CHECK-PROTECTED-LABEL: declare i32 @implicit_function2(...)
// CHECK-HIDDEN-LABEL: declare i32 @implicit_function2(...)
}