aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-01-12 22:35:21 +0000
committerMatthew Lugg <mlugg@mlugg.co.uk>2025-01-14 22:44:18 +0000
commit4b910e525d97276c64e98832663f0acfe8ff5cfb (patch)
tree2dfbf6c657f1593aee37f9281e182224b8514cad /src/codegen
parent5322459a0bd346c78ba069262a5fd7073389a750 (diff)
downloadzig-4b910e525d97276c64e98832663f0acfe8ff5cfb.tar.gz
zig-4b910e525d97276c64e98832663f0acfe8ff5cfb.zip
Sema: more validation for builtin decl types
Also improve the source locations when this validation fails. Resolves: #22465
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/llvm.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig
index fddbd07312..492506e9a6 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -5754,10 +5754,12 @@ pub const FuncGen = struct {
const o = fg.ng.object;
const zcu = o.pt.zcu;
const ip = &zcu.intern_pool;
- const panic_msg_val = zcu.builtin_decl_values.get(panic_id.toBuiltin());
- assert(panic_msg_val != .none);
- const msg_len = Value.fromInterned(panic_msg_val).typeOf(zcu).childType(zcu).arrayLen(zcu);
- const msg_ptr = try o.lowerValue(panic_msg_val);
+ const msg_len: u64, const msg_ptr: Builder.Constant = msg: {
+ const str_val = zcu.builtin_decl_values.get(panic_id.toBuiltin());
+ assert(str_val != .none);
+ const slice = ip.indexToKey(str_val).slice;
+ break :msg .{ Value.fromInterned(slice.len).toUnsignedInt(zcu), try o.lowerValue(slice.ptr) };
+ };
const null_opt_addr_global = try fg.resolveNullOptUsize();
const target = zcu.getTarget();
const llvm_usize = try o.lowerType(Type.usize);