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...@@ -2477,6 +2477,18 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2477 assert(file.zir_loaded);2477 assert(file.zir_loaded);
2478 const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst));2478 const decl_inst = file.zir.instructions.get(@intFromEnum(inst_info.inst));
2479 assert(decl_inst.tag == .declaration);2479 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
2480 const tree = try file.getTree(dwarf.gpa);2492 const tree = try file.getTree(dwarf.gpa);
2481 const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);2493 const loc = tree.tokenLocation(0, tree.nodes.items(.main_token)[decl_inst.data.declaration.src_node]);
2482 assert(loc.line == zcu.navSrcLine(nav_index));2494 assert(loc.line == zcu.navSrcLine(nav_index));
...@@ -2582,7 +2594,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool...@@ -2582,7 +2594,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2582 if (loaded_struct.zir_index == .none) break :decl_struct;2594 if (loaded_struct.zir_index == .none) break :decl_struct;
25832595
2584 const value_inst = value_inst: {2596 const value_inst = value_inst: {
2585 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2586 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2597 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2587 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2598 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2588 if (break_inst.tag != .break_inline) break :value_inst null;2599 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...@@ -2704,7 +2715,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
2704 if (loaded_enum.zir_index == .none) break :decl_enum;2715 if (loaded_enum.zir_index == .none) break :decl_enum;
27052716
2706 const value_inst = value_inst: {2717 const value_inst = value_inst: {
2707 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2708 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2718 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2709 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2719 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2710 if (break_inst.tag != .break_inline) break :value_inst null;2720 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...@@ -2788,7 +2798,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
27882798
2789 decl_union: {2799 decl_union: {
2790 const value_inst = value_inst: {2800 const value_inst = value_inst: {
2791 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2792 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2801 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2793 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2802 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2794 if (break_inst.tag != .break_inline) break :value_inst null;2803 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...@@ -2911,7 +2920,6 @@ pub fn updateComptimeNav(dwarf: *Dwarf, pt: Zcu.PerThread, nav_index: InternPool
29112920
2912 decl_opaque: {2921 decl_opaque: {
2913 const value_inst = value_inst: {2922 const value_inst = value_inst: {
2914 const decl_extra = file.zir.extraData(Zir.Inst.Declaration, decl_inst.data.declaration.payload_index);
2915 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;2923 const decl_value_body = decl_extra.data.getBodies(@intCast(decl_extra.end), file.zir).value_body;
2916 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));2924 const break_inst = file.zir.instructions.get(@intFromEnum(decl_value_body[decl_value_body.len - 1]));
2917 if (break_inst.tag != .break_inline) break :value_inst null;2925 if (break_inst.tag != .break_inline) break :value_inst null;