authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-26 04:39:01+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-26 13:48:07+00:00
logb8d114a29e341a0cbd4c22cf02cb1588b0154446
treed20f9c0ac9f6f4307445ecdff3abbfb596d798d4
parent0d8c7ae0078e970af39a3be760f25c51829b44f9
signaturelock-open Commit is signed but in an unrecognized format.

Zcu: use `Value` instead of `TypedValue` when initializing legacy anon decls

Also removes some unnecessary uses of legacy anon decls for constructing the array of test functions for the test runner.

2 files changed, 121 insertions(+), 105 deletions(-)

src/Module.zig+24-50
...@@ -22,7 +22,6 @@ const Compilation = @import("Compilation.zig");...@@ -22,7 +22,6 @@ const Compilation = @import("Compilation.zig");
22const Cache = std.Build.Cache;22const Cache = std.Build.Cache;
23const Value = @import("Value.zig");23const Value = @import("Value.zig");
24const Type = @import("type.zig").Type;24const Type = @import("type.zig").Type;
25const TypedValue = @import("TypedValue.zig");
26const Package = @import("Package.zig");25const Package = @import("Package.zig");
27const link = @import("link.zig");26const link = @import("link.zig");
28const Air = @import("Air.zig");27const Air = @import("Air.zig");
...@@ -4827,40 +4826,18 @@ pub fn errorSetBits(mod: *Module) u16 {...@@ -4827,40 +4826,18 @@ pub fn errorSetBits(mod: *Module) u16 {
4827 return std.math.log2_int_ceil(ErrorInt, mod.error_limit + 1); // +1 for no error4826 return std.math.log2_int_ceil(ErrorInt, mod.error_limit + 1); // +1 for no error
4828}4827}
48294828
4830pub fn createAnonymousDecl(mod: *Module, block: *Sema.Block, typed_value: TypedValue) !Decl.Index {
4831 const src_decl = mod.declPtr(block.src_decl);
4832 return mod.createAnonymousDeclFromDecl(src_decl, block.namespace, typed_value);
4833}
4834
4835pub fn createAnonymousDeclFromDecl(
4836 mod: *Module,
4837 src_decl: *Decl,
4838 namespace: Namespace.Index,
4839 tv: TypedValue,
4840) !Decl.Index {
4841 const new_decl_index = try mod.allocateNewDecl(namespace, src_decl.src_node);
4842 errdefer mod.destroyDecl(new_decl_index);
4843 const name = try mod.intern_pool.getOrPutStringFmt(mod.gpa, "{}__anon_{d}", .{
4844 src_decl.name.fmt(&mod.intern_pool), @intFromEnum(new_decl_index),
4845 });
4846 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, tv, name);
4847 return new_decl_index;
4848}
4849
4850pub fn initNewAnonDecl(4829pub fn initNewAnonDecl(
4851 mod: *Module,4830 mod: *Module,
4852 new_decl_index: Decl.Index,4831 new_decl_index: Decl.Index,
4853 src_line: u32,4832 src_line: u32,
4854 typed_value: TypedValue,4833 val: Value,
4855 name: InternPool.NullTerminatedString,4834 name: InternPool.NullTerminatedString,
4856) Allocator.Error!void {4835) Allocator.Error!void {
4857 assert(typed_value.ty.toIntern() == mod.intern_pool.typeOf(typed_value.val.toIntern()));
4858
4859 const new_decl = mod.declPtr(new_decl_index);4836 const new_decl = mod.declPtr(new_decl_index);
48604837
4861 new_decl.name = name;4838 new_decl.name = name;
4862 new_decl.src_line = src_line;4839 new_decl.src_line = src_line;
4863 new_decl.val = typed_value.val;4840 new_decl.val = val;
4864 new_decl.alignment = .none;4841 new_decl.alignment = .none;
4865 new_decl.@"linksection" = .none;4842 new_decl.@"linksection" = .none;
4866 new_decl.has_tv = true;4843 new_decl.has_tv = true;
...@@ -5391,7 +5368,7 @@ pub fn populateTestFunctions(...@@ -5391,7 +5368,7 @@ pub fn populateTestFunctions(
5391 const decl = mod.declPtr(decl_index);5368 const decl = mod.declPtr(decl_index);
5392 const test_fn_ty = decl.typeOf(mod).slicePtrFieldType(mod).childType(mod);5369 const test_fn_ty = decl.typeOf(mod).slicePtrFieldType(mod).childType(mod);
53935370
5394 const array_decl_index = d: {5371 const array_anon_decl: InternPool.Key.Ptr.Addr.AnonDecl = array: {
5395 // Add mod.test_functions to an array decl then make the test_functions5372 // Add mod.test_functions to an array decl then make the test_functions
5396 // decl reference it as a slice.5373 // decl reference it as a slice.
5397 const test_fn_vals = try gpa.alloc(InternPool.Index, mod.test_functions.count());5374 const test_fn_vals = try gpa.alloc(InternPool.Index, mod.test_functions.count());
...@@ -5401,21 +5378,20 @@ pub fn populateTestFunctions(...@@ -5401,21 +5378,20 @@ pub fn populateTestFunctions(
5401 const test_decl = mod.declPtr(test_decl_index);5378 const test_decl = mod.declPtr(test_decl_index);
5402 const test_decl_name = try gpa.dupe(u8, ip.stringToSlice(try test_decl.fullyQualifiedName(mod)));5379 const test_decl_name = try gpa.dupe(u8, ip.stringToSlice(try test_decl.fullyQualifiedName(mod)));
5403 defer gpa.free(test_decl_name);5380 defer gpa.free(test_decl_name);
5404 const test_name_decl_index = n: {5381 const test_name_anon_decl: InternPool.Key.Ptr.Addr.AnonDecl = n: {
5405 const test_name_decl_ty = try mod.arrayType(.{5382 const test_name_ty = try mod.arrayType(.{
5406 .len = test_decl_name.len,5383 .len = test_decl_name.len,
5407 .child = .u8_type,5384 .child = .u8_type,
5408 });5385 });
5409 const test_name_decl_index = try mod.createAnonymousDeclFromDecl(decl, decl.src_namespace, .{5386 const test_name_val = try mod.intern(.{ .aggregate = .{
5410 .ty = test_name_decl_ty,5387 .ty = test_name_ty.toIntern(),
5411 .val = Value.fromInterned((try mod.intern(.{ .aggregate = .{5388 .storage = .{ .bytes = test_decl_name },
5412 .ty = test_name_decl_ty.toIntern(),5389 } });
5413 .storage = .{ .bytes = test_decl_name },5390 break :n .{
5414 } }))),5391 .orig_ty = (try mod.singleConstPtrType(test_name_ty)).toIntern(),
5415 });5392 .val = test_name_val,
5416 break :n test_name_decl_index;5393 };
5417 };5394 };
5418 try mod.linkerUpdateDecl(test_name_decl_index);
54195395
5420 const test_fn_fields = .{5396 const test_fn_fields = .{
5421 // name5397 // name
...@@ -5423,7 +5399,7 @@ pub fn populateTestFunctions(...@@ -5423,7 +5399,7 @@ pub fn populateTestFunctions(
5423 .ty = .slice_const_u8_type,5399 .ty = .slice_const_u8_type,
5424 .ptr = try mod.intern(.{ .ptr = .{5400 .ptr = try mod.intern(.{ .ptr = .{
5425 .ty = .manyptr_const_u8_type,5401 .ty = .manyptr_const_u8_type,
5426 .addr = .{ .decl = test_name_decl_index },5402 .addr = .{ .anon_decl = test_name_anon_decl },
5427 } }),5403 } }),
5428 .len = try mod.intern(.{ .int = .{5404 .len = try mod.intern(.{ .int = .{
5429 .ty = .usize_type,5405 .ty = .usize_type,
...@@ -5447,22 +5423,20 @@ pub fn populateTestFunctions(...@@ -5447,22 +5423,20 @@ pub fn populateTestFunctions(
5447 } });5423 } });
5448 }5424 }
54495425
5450 const array_decl_ty = try mod.arrayType(.{5426 const array_ty = try mod.arrayType(.{
5451 .len = test_fn_vals.len,5427 .len = test_fn_vals.len,
5452 .child = test_fn_ty.toIntern(),5428 .child = test_fn_ty.toIntern(),
5453 .sentinel = .none,5429 .sentinel = .none,
5454 });5430 });
5455 const array_decl_index = try mod.createAnonymousDeclFromDecl(decl, decl.src_namespace, .{5431 const array_val = try mod.intern(.{ .aggregate = .{
5456 .ty = array_decl_ty,5432 .ty = array_ty.toIntern(),
5457 .val = Value.fromInterned((try mod.intern(.{ .aggregate = .{5433 .storage = .{ .elems = test_fn_vals },
5458 .ty = array_decl_ty.toIntern(),5434 } });
5459 .storage = .{ .elems = test_fn_vals },5435 break :array .{
5460 } }))),5436 .orig_ty = (try mod.singleConstPtrType(array_ty)).toIntern(),
5461 });5437 .val = array_val,
54625438 };
5463 break :d array_decl_index;
5464 };5439 };
5465 try mod.linkerUpdateDecl(array_decl_index);
54665440
5467 {5441 {
5468 const new_ty = try mod.ptrType(.{5442 const new_ty = try mod.ptrType(.{
...@@ -5477,7 +5451,7 @@ pub fn populateTestFunctions(...@@ -5477,7 +5451,7 @@ pub fn populateTestFunctions(
5477 .ty = new_ty.toIntern(),5451 .ty = new_ty.toIntern(),
5478 .ptr = try mod.intern(.{ .ptr = .{5452 .ptr = try mod.intern(.{ .ptr = .{
5479 .ty = new_ty.slicePtrFieldType(mod).toIntern(),5453 .ty = new_ty.slicePtrFieldType(mod).toIntern(),
5480 .addr = .{ .decl = array_decl_index },5454 .addr = .{ .anon_decl = array_anon_decl },
5481 } }),5455 } }),
5482 .len = (try mod.intValue(Type.usize, mod.test_functions.count())).toIntern(),5456 .len = (try mod.intValue(Type.usize, mod.test_functions.count())).toIntern(),
5483 } });5457 } });
src/Sema.zig+97-55
...@@ -2825,10 +2825,14 @@ fn zirStructDecl(...@@ -2825,10 +2825,14 @@ fn zirStructDecl(
2825 });2825 });
2826 errdefer wip_ty.cancel(ip);2826 errdefer wip_ty.cancel(ip);
28272827
2828 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{2828 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
2829 .ty = Type.type,2829 block,
2830 .val = Value.fromInterned(wip_ty.index),2830 src,
2831 }, small.name_strategy, "struct", inst);2831 Value.fromInterned(wip_ty.index),
2832 small.name_strategy,
2833 "struct",
2834 inst,
2835 );
2832 mod.declPtr(new_decl_index).owns_tv = true;2836 mod.declPtr(new_decl_index).owns_tv = true;
2833 errdefer mod.abortAnonDecl(new_decl_index);2837 errdefer mod.abortAnonDecl(new_decl_index);
28342838
...@@ -2861,7 +2865,7 @@ fn createAnonymousDeclTypeNamed(...@@ -2861,7 +2865,7 @@ fn createAnonymousDeclTypeNamed(
2861 sema: *Sema,2865 sema: *Sema,
2862 block: *Block,2866 block: *Block,
2863 src: LazySrcLoc,2867 src: LazySrcLoc,
2864 typed_value: TypedValue,2868 val: Value,
2865 name_strategy: Zir.Inst.NameStrategy,2869 name_strategy: Zir.Inst.NameStrategy,
2866 anon_prefix: []const u8,2870 anon_prefix: []const u8,
2867 inst: ?Zir.Inst.Index,2871 inst: ?Zir.Inst.Index,
...@@ -2887,12 +2891,12 @@ fn createAnonymousDeclTypeNamed(...@@ -2887,12 +2891,12 @@ fn createAnonymousDeclTypeNamed(
2887 const name = mod.intern_pool.getOrPutStringFmt(gpa, "{}__{s}_{d}", .{2891 const name = mod.intern_pool.getOrPutStringFmt(gpa, "{}__{s}_{d}", .{
2888 src_decl.name.fmt(&mod.intern_pool), anon_prefix, @intFromEnum(new_decl_index),2892 src_decl.name.fmt(&mod.intern_pool), anon_prefix, @intFromEnum(new_decl_index),
2889 }) catch unreachable;2893 }) catch unreachable;
2890 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, typed_value, name);2894 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name);
2891 return new_decl_index;2895 return new_decl_index;
2892 },2896 },
2893 .parent => {2897 .parent => {
2894 const name = mod.declPtr(block.src_decl).name;2898 const name = mod.declPtr(block.src_decl).name;
2895 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, typed_value, name);2899 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name);
2896 return new_decl_index;2900 return new_decl_index;
2897 },2901 },
2898 .func => {2902 .func => {
...@@ -2915,7 +2919,7 @@ fn createAnonymousDeclTypeNamed(...@@ -2915,7 +2919,7 @@ fn createAnonymousDeclTypeNamed(
2915 // function and the name doesn't matter since it will later2919 // function and the name doesn't matter since it will later
2916 // result in a compile error.2920 // result in a compile error.
2917 const arg_val = sema.resolveConstValue(block, .unneeded, arg, undefined) catch2921 const arg_val = sema.resolveConstValue(block, .unneeded, arg, undefined) catch
2918 return sema.createAnonymousDeclTypeNamed(block, src, typed_value, .anon, anon_prefix, null);2922 return sema.createAnonymousDeclTypeNamed(block, src, val, .anon, anon_prefix, null);
29192923
2920 if (arg_i != 0) try writer.writeByte(',');2924 if (arg_i != 0) try writer.writeByte(',');
2921 try writer.print("{}", .{arg_val.fmtValue(sema.typeOf(arg), sema.mod)});2925 try writer.print("{}", .{arg_val.fmtValue(sema.typeOf(arg), sema.mod)});
...@@ -2928,7 +2932,7 @@ fn createAnonymousDeclTypeNamed(...@@ -2928,7 +2932,7 @@ fn createAnonymousDeclTypeNamed(
29282932
2929 try writer.writeByte(')');2933 try writer.writeByte(')');
2930 const name = try mod.intern_pool.getOrPutString(gpa, buf.items);2934 const name = try mod.intern_pool.getOrPutString(gpa, buf.items);
2931 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, typed_value, name);2935 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name);
2932 return new_decl_index;2936 return new_decl_index;
2933 },2937 },
2934 .dbg_var => {2938 .dbg_var => {
...@@ -2943,12 +2947,12 @@ fn createAnonymousDeclTypeNamed(...@@ -2943,12 +2947,12 @@ fn createAnonymousDeclTypeNamed(
2943 src_decl.name.fmt(&mod.intern_pool), zir_data[i].str_op.getStr(sema.code),2947 src_decl.name.fmt(&mod.intern_pool), zir_data[i].str_op.getStr(sema.code),
2944 });2948 });
29452949
2946 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, typed_value, name);2950 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, val, name);
2947 return new_decl_index;2951 return new_decl_index;
2948 },2952 },
2949 else => {},2953 else => {},
2950 };2954 };
2951 return sema.createAnonymousDeclTypeNamed(block, src, typed_value, .anon, anon_prefix, null);2955 return sema.createAnonymousDeclTypeNamed(block, src, val, .anon, anon_prefix, null);
2952 },2956 },
2953 }2957 }
2954}2958}
...@@ -3048,10 +3052,14 @@ fn zirEnumDecl(...@@ -3048,10 +3052,14 @@ fn zirEnumDecl(
30483052
3049 errdefer if (!done) wip_ty.cancel(ip);3053 errdefer if (!done) wip_ty.cancel(ip);
30503054
3051 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{3055 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
3052 .ty = Type.type,3056 block,
3053 .val = Value.fromInterned(wip_ty.index),3057 src,
3054 }, small.name_strategy, "enum", inst);3058 Value.fromInterned(wip_ty.index),
3059 small.name_strategy,
3060 "enum",
3061 inst,
3062 );
3055 const new_decl = mod.declPtr(new_decl_index);3063 const new_decl = mod.declPtr(new_decl_index);
3056 new_decl.owns_tv = true;3064 new_decl.owns_tv = true;
3057 errdefer if (!done) mod.abortAnonDecl(new_decl_index);3065 errdefer if (!done) mod.abortAnonDecl(new_decl_index);
...@@ -3315,10 +3323,14 @@ fn zirUnionDecl(...@@ -3315,10 +3323,14 @@ fn zirUnionDecl(
3315 });3323 });
3316 errdefer wip_ty.cancel(ip);3324 errdefer wip_ty.cancel(ip);
33173325
3318 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{3326 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
3319 .ty = Type.type,3327 block,
3320 .val = Value.fromInterned(wip_ty.index),3328 src,
3321 }, small.name_strategy, "union", inst);3329 Value.fromInterned(wip_ty.index),
3330 small.name_strategy,
3331 "union",
3332 inst,
3333 );
3322 mod.declPtr(new_decl_index).owns_tv = true;3334 mod.declPtr(new_decl_index).owns_tv = true;
3323 errdefer mod.abortAnonDecl(new_decl_index);3335 errdefer mod.abortAnonDecl(new_decl_index);
33243336
...@@ -3399,10 +3411,14 @@ fn zirOpaqueDecl(...@@ -3399,10 +3411,14 @@ fn zirOpaqueDecl(
3399 };3411 };
3400 errdefer wip_ty.cancel(ip);3412 errdefer wip_ty.cancel(ip);
34013413
3402 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{3414 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
3403 .ty = Type.type,3415 block,
3404 .val = Value.fromInterned(wip_ty.index),3416 src,
3405 }, small.name_strategy, "opaque", inst);3417 Value.fromInterned(wip_ty.index),
3418 small.name_strategy,
3419 "opaque",
3420 inst,
3421 );
3406 mod.declPtr(new_decl_index).owns_tv = true;3422 mod.declPtr(new_decl_index).owns_tv = true;
3407 errdefer mod.abortAnonDecl(new_decl_index);3423 errdefer mod.abortAnonDecl(new_decl_index);
34083424
...@@ -3462,10 +3478,14 @@ fn zirErrorSetDecl(...@@ -3462,10 +3478,14 @@ fn zirErrorSetDecl(
34623478
3463 const error_set_ty = try mod.errorSetFromUnsortedNames(names.keys());3479 const error_set_ty = try mod.errorSetFromUnsortedNames(names.keys());
34643480
3465 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{3481 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
3466 .ty = Type.type,3482 block,
3467 .val = error_set_ty.toValue(),3483 src,
3468 }, name_strategy, "error", inst);3484 error_set_ty.toValue(),
3485 name_strategy,
3486 "error",
3487 inst,
3488 );
3469 const new_decl = mod.declPtr(new_decl_index);3489 const new_decl = mod.declPtr(new_decl_index);
3470 new_decl.owns_tv = true;3490 new_decl.owns_tv = true;
3471 errdefer mod.abortAnonDecl(new_decl_index);3491 errdefer mod.abortAnonDecl(new_decl_index);
...@@ -21490,10 +21510,14 @@ fn zirReify(...@@ -21490,10 +21510,14 @@ fn zirReify(
21490 };21510 };
21491 errdefer wip_ty.cancel(ip);21511 errdefer wip_ty.cancel(ip);
2149221512
21493 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{21513 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
21494 .ty = Type.type,21514 block,
21495 .val = Value.fromInterned(wip_ty.index),21515 src,
21496 }, name_strategy, "opaque", inst);21516 Value.fromInterned(wip_ty.index),
21517 name_strategy,
21518 "opaque",
21519 inst,
21520 );
21497 mod.declPtr(new_decl_index).owns_tv = true;21521 mod.declPtr(new_decl_index).owns_tv = true;
21498 errdefer mod.abortAnonDecl(new_decl_index);21522 errdefer mod.abortAnonDecl(new_decl_index);
2149921523
...@@ -21686,10 +21710,14 @@ fn reifyEnum(...@@ -21686,10 +21710,14 @@ fn reifyEnum(
21686 return sema.fail(block, src, "Type.Enum.tag_type must be an integer type", .{});21710 return sema.fail(block, src, "Type.Enum.tag_type must be an integer type", .{});
21687 }21711 }
2168821712
21689 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{21713 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
21690 .ty = Type.type,21714 block,
21691 .val = Value.fromInterned(wip_ty.index),21715 src,
21692 }, name_strategy, "enum", inst);21716 Value.fromInterned(wip_ty.index),
21717 name_strategy,
21718 "enum",
21719 inst,
21720 );
21693 mod.declPtr(new_decl_index).owns_tv = true;21721 mod.declPtr(new_decl_index).owns_tv = true;
21694 errdefer mod.abortAnonDecl(new_decl_index);21722 errdefer mod.abortAnonDecl(new_decl_index);
2169521723
...@@ -21829,10 +21857,14 @@ fn reifyUnion(...@@ -21829,10 +21857,14 @@ fn reifyUnion(
21829 };21857 };
21830 errdefer wip_ty.cancel(ip);21858 errdefer wip_ty.cancel(ip);
2183121859
21832 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{21860 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
21833 .ty = Type.type,21861 block,
21834 .val = Value.fromInterned(wip_ty.index),21862 src,
21835 }, name_strategy, "union", inst);21863 Value.fromInterned(wip_ty.index),
21864 name_strategy,
21865 "union",
21866 inst,
21867 );
21836 mod.declPtr(new_decl_index).owns_tv = true;21868 mod.declPtr(new_decl_index).owns_tv = true;
21837 errdefer mod.abortAnonDecl(new_decl_index);21869 errdefer mod.abortAnonDecl(new_decl_index);
2183821870
...@@ -22084,10 +22116,14 @@ fn reifyStruct(...@@ -22084,10 +22116,14 @@ fn reifyStruct(
22084 .auto => {},22116 .auto => {},
22085 };22117 };
2208622118
22087 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{22119 const new_decl_index = try sema.createAnonymousDeclTypeNamed(
22088 .ty = Type.type,22120 block,
22089 .val = Value.fromInterned(wip_ty.index),22121 src,
22090 }, name_strategy, "struct", inst);22122 Value.fromInterned(wip_ty.index),
22123 name_strategy,
22124 "struct",
22125 inst,
22126 );
22091 mod.declPtr(new_decl_index).owns_tv = true;22127 mod.declPtr(new_decl_index).owns_tv = true;
22092 errdefer mod.abortAnonDecl(new_decl_index);22128 errdefer mod.abortAnonDecl(new_decl_index);
2209322129
...@@ -26139,9 +26175,10 @@ fn zirBuiltinExtern(...@@ -26139,9 +26175,10 @@ fn zirBuiltinExtern(
26139 const new_decl_index = try mod.allocateNewDecl(sema.owner_decl.src_namespace, sema.owner_decl.src_node);26175 const new_decl_index = try mod.allocateNewDecl(sema.owner_decl.src_namespace, sema.owner_decl.src_node);
26140 errdefer mod.destroyDecl(new_decl_index);26176 errdefer mod.destroyDecl(new_decl_index);
26141 const new_decl = mod.declPtr(new_decl_index);26177 const new_decl = mod.declPtr(new_decl_index);
26142 try mod.initNewAnonDecl(new_decl_index, sema.owner_decl.src_line, .{26178 try mod.initNewAnonDecl(
26143 .ty = Type.fromInterned(ptr_info.child),26179 new_decl_index,
26144 .val = Value.fromInterned(26180 sema.owner_decl.src_line,
26181 Value.fromInterned(
26145 if (Type.fromInterned(ptr_info.child).zigTypeTag(mod) == .Fn)26182 if (Type.fromInterned(ptr_info.child).zigTypeTag(mod) == .Fn)
26146 try ip.getExternFunc(sema.gpa, .{26183 try ip.getExternFunc(sema.gpa, .{
26147 .ty = ptr_info.child,26184 .ty = ptr_info.child,
...@@ -26160,7 +26197,8 @@ fn zirBuiltinExtern(...@@ -26160,7 +26197,8 @@ fn zirBuiltinExtern(
26160 .is_weak_linkage = options.linkage == .weak,26197 .is_weak_linkage = options.linkage == .weak,
26161 } }),26198 } }),
26162 ),26199 ),
26163 }, options.name);26200 options.name,
26201 );
26164 new_decl.owns_tv = true;26202 new_decl.owns_tv = true;
26165 // Note that this will queue the anon decl for codegen, so that the backend can26203 // Note that this will queue the anon decl for codegen, so that the backend can
26166 // correctly handle the extern, including duplicate detection.26204 // correctly handle the extern, including duplicate detection.
...@@ -37381,10 +37419,12 @@ fn generateUnionTagTypeNumbered(...@@ -37381,10 +37419,12 @@ fn generateUnionTagTypeNumbered(
37381 errdefer mod.destroyDecl(new_decl_index);37419 errdefer mod.destroyDecl(new_decl_index);
37382 const fqn = try union_owner_decl.fullyQualifiedName(mod);37420 const fqn = try union_owner_decl.fullyQualifiedName(mod);
37383 const name = try ip.getOrPutStringFmt(gpa, "@typeInfo({}).Union.tag_type.?", .{fqn.fmt(ip)});37421 const name = try ip.getOrPutStringFmt(gpa, "@typeInfo({}).Union.tag_type.?", .{fqn.fmt(ip)});
37384 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, .{37422 try mod.initNewAnonDecl(
37385 .ty = Type.noreturn,37423 new_decl_index,
37386 .val = Value.@"unreachable",37424 src_decl.src_line,
37387 }, name);37425 Value.@"unreachable",
37426 name,
37427 );
37388 errdefer mod.abortAnonDecl(new_decl_index);37428 errdefer mod.abortAnonDecl(new_decl_index);
3738937429
37390 const new_decl = mod.declPtr(new_decl_index);37430 const new_decl = mod.declPtr(new_decl_index);
...@@ -37425,10 +37465,12 @@ fn generateUnionTagTypeSimple(...@@ -37425,10 +37465,12 @@ fn generateUnionTagTypeSimple(
37425 const new_decl_index = try mod.allocateNewDecl(block.namespace, src_decl.src_node);37465 const new_decl_index = try mod.allocateNewDecl(block.namespace, src_decl.src_node);
37426 errdefer mod.destroyDecl(new_decl_index);37466 errdefer mod.destroyDecl(new_decl_index);
37427 const name = try ip.getOrPutStringFmt(gpa, "@typeInfo({}).Union.tag_type.?", .{fqn.fmt(ip)});37467 const name = try ip.getOrPutStringFmt(gpa, "@typeInfo({}).Union.tag_type.?", .{fqn.fmt(ip)});
37428 try mod.initNewAnonDecl(new_decl_index, src_decl.src_line, .{37468 try mod.initNewAnonDecl(
37429 .ty = Type.noreturn,37469 new_decl_index,
37430 .val = Value.@"unreachable",37470 src_decl.src_line,
37431 }, name);37471 Value.@"unreachable",
37472 name,
37473 );
37432 mod.declPtr(new_decl_index).name_fully_qualified = true;37474 mod.declPtr(new_decl_index).name_fully_qualified = true;
37433 break :new_decl_index new_decl_index;37475 break :new_decl_index new_decl_index;
37434 };37476 };