From ab99dd9c5d22a3d927453081654b1f75b2521b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 31 Aug 2025 15:26:15 +0200 Subject: [PATCH] zig_clang: fix ZigClangAPValueLValueBase struct layout to match Clang 21 Fixes the compiler build for various targets, especially 32-bit. --- src/clang.zig | 12 +++++++++--- src/zig_clang.h | 14 ++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/clang.zig b/src/clang.zig index 45fd4456ed..453b66696a 100644 --- a/src/clang.zig +++ b/src/clang.zig @@ -37,9 +37,15 @@ pub const QualType = extern struct { }; pub const APValueLValueBase = extern struct { - Ptr: ?*anyopaque, - CallIndex: c_uint, - Version: c_uint, + Ptr: ?*anyopaque align(@alignOf(u64)), + State: extern union { + Local: extern struct { + CallIndex: c_uint, + Version: c_uint, + }, + TypeInfoType: ?*anyopaque, + DynamicAllocType: ?*anyopaque, + }, pub const dyn_cast_Expr = ZigClangAPValueLValueBase_dyn_cast_Expr; extern fn ZigClangAPValueLValueBase_dyn_cast_Expr(APValueLValueBase) ?*const Expr; diff --git a/src/zig_clang.h b/src/zig_clang.h index 8bfc0ab2e6..f4bebe6f62 100644 --- a/src/zig_clang.h +++ b/src/zig_clang.h @@ -43,10 +43,16 @@ struct ZigClangQualType { void *ptr; }; -struct ZigClangAPValueLValueBase { - void *Ptr; - unsigned CallIndex; - unsigned Version; +struct alignas(uint64_t) ZigClangAPValueLValueBase { + void* Ptr; + union { + struct { + unsigned CallIndex; + unsigned Version; + } Local; + void* TypeInfoType; + void* DynamicAllocType; + }; }; enum ZigClangAPValueKind {