authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-16 19:35:31+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-07-16 19:44:15+01:00
log5093a5cd193ed3cd4107f0fcdb0ed1ab9dda30f5
treee7ae983fd3a20ba67dafad3062a3cbf0c2e2473e
parentee695c8ef40ae7cecb4b9a77c8a6dcbe53d4f013
signaturelock-open Commit is signed but in an unrecognized format.

std.Zir: some declaration traversal fixes


1 files changed, 13 insertions(+), 16 deletions(-)

lib/std/zig/Zir.zig+13-16
...@@ -3791,11 +3791,15 @@ fn findDeclsSwitch(...@@ -3791,11 +3791,15 @@ fn findDeclsSwitch(
3791 break :blk multi_cases_len;3791 break :blk multi_cases_len;
3792 } else 0;3792 } else 0;
37933793
3794 if (extra.data.bits.any_has_tag_capture) {
3795 extra_index += 1;
3796 }
3797
3794 const special_prong = extra.data.bits.specialProng();3798 const special_prong = extra.data.bits.specialProng();
3795 if (special_prong != .none) {3799 if (special_prong != .none) {
3796 const body_len: u31 = @truncate(zir.extra[extra_index]);3800 const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]);
3797 extra_index += 1;3801 extra_index += 1;
3798 const body = zir.bodySlice(extra_index, body_len);3802 const body = zir.bodySlice(extra_index, prong_info.body_len);
3799 extra_index += body.len;3803 extra_index += body.len;
38003804
3801 try zir.findDeclsBody(list, body);3805 try zir.findDeclsBody(list, body);
...@@ -3805,10 +3809,10 @@ fn findDeclsSwitch(...@@ -3805,10 +3809,10 @@ fn findDeclsSwitch(
3805 const scalar_cases_len = extra.data.bits.scalar_cases_len;3809 const scalar_cases_len = extra.data.bits.scalar_cases_len;
3806 for (0..scalar_cases_len) |_| {3810 for (0..scalar_cases_len) |_| {
3807 extra_index += 1;3811 extra_index += 1;
3808 const body_len: u31 = @truncate(zir.extra[extra_index]);3812 const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]);
3809 extra_index += 1;3813 extra_index += 1;
3810 const body = zir.bodySlice(extra_index, body_len);3814 const body = zir.bodySlice(extra_index, prong_info.body_len);
3811 extra_index += body_len;3815 extra_index += body.len;
38123816
3813 try zir.findDeclsBody(list, body);3817 try zir.findDeclsBody(list, body);
3814 }3818 }
...@@ -3819,20 +3823,13 @@ fn findDeclsSwitch(...@@ -3819,20 +3823,13 @@ fn findDeclsSwitch(
3819 extra_index += 1;3823 extra_index += 1;
3820 const ranges_len = zir.extra[extra_index];3824 const ranges_len = zir.extra[extra_index];
3821 extra_index += 1;3825 extra_index += 1;
3822 const body_len: u31 = @truncate(zir.extra[extra_index]);3826 const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]);
3823 extra_index += 1;3827 extra_index += 1;
3824 const items = zir.refSlice(extra_index, items_len);
3825 extra_index += items_len;
3826 _ = items;
38273828
3828 var range_i: usize = 0;3829 extra_index += items_len + ranges_len * 2;
3829 while (range_i < ranges_len) : (range_i += 1) {
3830 extra_index += 1;
3831 extra_index += 1;
3832 }
38333830
3834 const body = zir.bodySlice(extra_index, body_len);3831 const body = zir.bodySlice(extra_index, prong_info.body_len);
3835 extra_index += body_len;3832 extra_index += body.len;
38363833
3837 try zir.findDeclsBody(list, body);3834 try zir.findDeclsBody(list, body);
3838 }3835 }