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

79 lines
3.3 KiB
C++

// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck %s
// PR36992
namespace Implicit {
struct A { char c; A(const A&); };
struct B { int n; char c[3]; ~B(); };
struct C : B, virtual A {};
static_assert(sizeof(C) == sizeof(void*) + 8);
C f(C c) { return c; }
// CHECK: define {{.*}} @_ZN8Implicit1CC1EOS0_
// CHECK: call {{.*}} @_ZN8Implicit1AC2ERKS0_(
// Note: this must memcpy 7 bytes, not 8, to avoid trampling over the virtual base class.
// CHECK: call void @llvm.memcpy.p0.p0.i{{32|64}}(ptr {{.*}}, ptr {{.*}}, i{{32|64}} 7, i1 false)
// CHECK: store ptr {{.*}} @_ZTVN8Implicit1CE
}
namespace InitWithinNVSize {
// This is the same as the previous test, except that the A base lies
// entirely within the nvsize of C. This makes it valid to copy at the
// full width.
struct A { char c; A(const A&); };
struct B { int n; char c[3]; ~B(); };
struct C : B, virtual A { char x; };
static_assert(sizeof(C) > sizeof(void*) + 8);
C f(C c) { return c; }
// CHECK: define {{.*}} @_ZN16InitWithinNVSize1CC1EOS0_
// CHECK: call {{.*}} @_ZN16InitWithinNVSize1AC2ERKS0_(
// This copies over the 'C::x' member, but that's OK because we've not initialized it yet.
// CHECK: call void @llvm.memcpy.p0.p0.i{{32|64}}(ptr {{.*}}, ptr {{.*}}, i{{32|64}} 8, i1 false)
// CHECK: store ptr {{.*}} @_ZTVN16InitWithinNVSize1CE
// CHECK: store i8
}
namespace NoUniqueAddr {
struct A { char c; A(const A&); };
struct B { int n; char c[3]; ~B(); };
struct C : virtual A { B b; };
struct D : virtual A { [[no_unique_address]] B b; };
struct E : virtual A { [[no_unique_address]] B b; char x; };
static_assert(sizeof(C) == sizeof(void*) + 8 + alignof(void*));
static_assert(sizeof(D) == sizeof(void*) + 8);
static_assert(sizeof(E) == sizeof(void*) + 8 + alignof(void*));
// CHECK: define {{.*}} @_ZN12NoUniqueAddr1CC1EOS0_
// CHECK: call {{.*}} @_ZN12NoUniqueAddr1AC2ERKS0_(
// CHECK: store ptr {{.*}} @_ZTVN12NoUniqueAddr1CE
// Copy the full size of B.
// CHECK: call void @llvm.memcpy.p0.p0.i{{32|64}}(ptr {{.*}}, ptr {{.*}}, i{{32|64}} 8, i1 false)
C f(C c) { return c; }
// CHECK: define {{.*}} @_ZN12NoUniqueAddr1DC1EOS0_
// CHECK: call {{.*}} @_ZN12NoUniqueAddr1AC2ERKS0_(
// CHECK: store ptr {{.*}} @_ZTVN12NoUniqueAddr1DE
// Copy just the data size of B, to avoid overwriting the A base class.
// CHECK: call void @llvm.memcpy.p0.p0.i{{32|64}}(ptr {{.*}}, ptr {{.*}}, i{{32|64}} 7, i1 false)
D f(D d) { return d; }
// CHECK: define {{.*}} @_ZN12NoUniqueAddr1EC1EOS0_
// CHECK: call {{.*}} @_ZN12NoUniqueAddr1AC2ERKS0_(
// CHECK: store ptr {{.*}} @_ZTVN12NoUniqueAddr1EE
// We can copy the full size of B here. (As it happens, we fold the copy of 'x' into
// this memcpy, so we're copying 8 bytes either way.)
// CHECK: call void @llvm.memcpy.p0.p0.i{{32|64}}(ptr {{.*}}, ptr {{.*}}, i{{32|64}} 8, i1 false)
E f(E e) { return e; }
struct F : virtual A {
F(const F &o) : A(o), b(o.b) {}
[[no_unique_address]] B b;
};
// CHECK: define {{.*}} @_ZN12NoUniqueAddr1FC1ERKS0_
// CHECK: call {{.*}} @_ZN12NoUniqueAddr1AC2ERKS0_(
// CHECK: store ptr {{.*}} @_ZTVN12NoUniqueAddr1FE
// CHECK: call void @llvm.memcpy.p0.p0.i{{32|64}}(ptr {{.*}}, ptr {{.*}}, i{{32|64}} 7, i1 false)
F f(F x) { return x; }
}