authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-28 06:27:38+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-08-28 08:39:59+01:00
logaaa7e739831f39151a37c7beb08660f0fb6ae0ed
tree1042467c31831ccf44d7a103a29407cce3ebf779
parent0fe3fd01ddc2cd49c6a2b939577d16b9d2c65ea9
signaturelock-open Commit is signed but in an unrecognized format.

link.Dwarf: skip tests in updateComptimeNav

These won't live in the parent namespace as decls which causes problems later in this function, and tests are guaranteed not to be referenced at comptime anyway, so there's actually no need to run this logic.

1 files changed, 12 insertions(+), 4 deletions(-)

src/link/Dwarf.zig+12-4
......@@ -2477,6 +2477,18 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
24772477 assert(file.zir_loaded);
24782478 const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst));
24792479 assert(decl_inst.tag == .declaration);
2480 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2481
2482 const is_test = switch (decl_extra.data.name) {
2483 .unnamed_test, .decltest => true,
2484 .@"comptime", .@"usingnamespace" => false,
2485 _ => decl_extra.data.name.isNamedTest(file.zir),
2486 };
2487 if (is_test) {
2488 // This isn't actually a comptime Nav! It's a test, so it'll definitely never be referenced at comptime.
2489 return;
2490 }
2491
24802492 const tree = try file.getTree(dwarf.gpa);
24812493 const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);
24822494 assert(loc.line == zcu.navSrcLine(nav_index));
......@@ -2582,7 +2594,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
25822594 if (loaded_struct.zir_index == .none) break :decl_struct;
25832595
25842596 const value_inst = value_inst: {
2585 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
25862597 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
25872598 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
25882599 if (break_inst.tag != .break_inline) break :value_inst null;
......@@ -2704,7 +2715,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
27042715 if (loaded_enum.zir_index == .none) break :decl_enum;
27052716
27062717 const value_inst = value_inst: {
2707 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
27082718 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
27092719 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
27102720 if (break_inst.tag != .break_inline) break :value_inst null;
......@@ -2788,7 +2798,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
27882798
27892799 decl_union: {
27902800 const value_inst = value_inst: {
2791 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
27922801 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
27932802 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
27942803 if (break_inst.tag != .break_inline) break :value_inst null;
......@@ -2911,7 +2920,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
29112920
29122921 decl_opaque: {
29132922 const value_inst = value_inst: {
2914 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
29152923 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
29162924 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
29172925 if (break_inst.tag != .break_inline) break :value_inst null;