authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-01 01:20:50+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-01 01:20:50+00:00
log408a08708fbb0abe03bfeaa835666a72d79c843d
treea941fdcce6d66322f7b5d527d5044171cabf5f6c
parent321045cf33268e7b75e2972d898010ecacc345dc
signaturelock-open Commit is signed but in an unrecognized format.

Autodoc: do not rely on redundant block within function body


1 files changed, 3 insertions(+), 10 deletions(-)

src/Autodoc.zig+3-10
......@@ -5137,7 +5137,7 @@ fn analyzeFancyFunction(
51375137 file,
51385138 scope,
51395139 parent_src,
5140 fn_info.body[0],
5140 fn_info.body,
51415141 call_ctx,
51425142 );
51435143 } else {
......@@ -5303,7 +5303,7 @@ fn analyzeFunction(
53035303 file,
53045304 scope,
53055305 parent_src,
5306 fn_info.body[0],
5306 fn_info.body,
53075307 call_ctx,
53085308 );
53095309 } else {
......@@ -5350,17 +5350,10 @@ fn getGenericReturnType(
53505350 file: *File,
53515351 scope: *Scope,
53525352 parent_src: SrcLocInfo, // function decl line
5353 body_main_block: Zir.Inst.Index,
5353 body: []const Zir.Inst.Index,
53545354 call_ctx: ?*const CallContext,
53555355) !DocData.Expr {
53565356 const tags = file.zir.instructions.items(.tag);
5357 const data = file.zir.instructions.items(.data);
5358
5359 // We expect `body_main_block` to be the first instruction
5360 // inside the function body, and for it to be a block instruction.
5361 const pl_node = data[@intFromEnum(body_main_block)].pl_node;
5362 const extra = file.zir.extraData(Zir.Inst.Block, pl_node.payload_index);
5363 const body = file.zir.bodySlice(extra.end, extra.data.body_len);
53645357 if (body.len >= 4) {
53655358 const maybe_ret_inst = body[body.len - 4];
53665359 switch (tags[@intFromEnum(maybe_ret_inst)]) {