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

91 lines
2.1 KiB
C++

// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm %s -o - | FileCheck %s
namespace foo {
// CHECK-NOT: @a = global
extern "C" int a;
// CHECK-NOT: @_ZN3foo1bE = global
extern int b;
// CHECK: @_ZN3foo1cE = {{(dso_local )?}}global
int c = 5;
// CHECK-NOT: @_ZN3foo1dE
extern "C" struct d;
// CHECK-NOT: should_not_appear
extern "C++" int should_not_appear;
// CHECK: @_ZN3foo10extern_cxxE = {{(dso_local )?}}global
extern "C++" int extern_cxx = 0;
}
// CHECK-NOT: @global_a = {{(dso_local )?}}global
extern "C" int global_a;
// CHECK: @global_b = {{(dso_local )?}}global
extern "C" int global_b = 0;
// CHECK-NOT: should_not_appear
extern "C++" int should_not_appear;
// CHECK: @extern_cxx = {{(dso_local )?}}global
extern "C++" int extern_cxx = 0;
namespace test1 {
namespace {
struct X {};
}
extern "C" {
// CHECK: @test1_b = {{(dso_local )?}}global
X test1_b = X();
}
void *use = &test1_b;
// CHECK: @_ZN5test13useE = {{(dso_local )?}}global
}
namespace test2 {
namespace {
struct X {};
}
// CHECK: @test2_b = {{(dso_local )?}}global
extern "C" X test2_b;
X test2_b;
}
extern "C" {
static int unused_var;
static int unused_fn() { return 0; }
__attribute__((used)) static int internal_var;
__attribute__((used)) static int internal_fn() { return 0; }
__attribute__((used)) static int duplicate_internal_var;
__attribute__((used)) static int duplicate_internal_fn() { return 0; }
namespace N {
__attribute__((used)) static int duplicate_internal_var;
__attribute__((used)) static int duplicate_internal_fn() { return 0; }
}
// CHECK: @llvm.compiler.used = appending global {{.*}} @internal_var, {{.*}} @internal_fn
// CHECK-NOT: @unused
// CHECK-NOT: @duplicate_internal
// CHECK: @internal_var = internal alias i32, ptr @_ZL12internal_var
// CHECK-NOT: @unused
// CHECK-NOT: @duplicate_internal
// CHECK: @internal_fn = internal alias i32 (), ptr @_ZL11internal_fnv
// CHECK-NOT: @unused
// CHECK-NOT: @duplicate_internal
}
namespace PR19411 {
struct A { void f(); };
extern "C" void A::f() { void g(); g(); }
// CHECK-LABEL: @_ZN7PR194111A1fEv(
// CHECK: call {{.*}}void @g()
}