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(...@@ -5137,7 +5137,7 @@ fn analyzeFancyFunction(
5137 file,5137 file,
5138 scope,5138 scope,
5139 parent_src,5139 parent_src,
5140 fn_info.body[0],5140 fn_info.body,
5141 call_ctx,5141 call_ctx,
5142 );5142 );
5143 } else {5143 } else {
...@@ -5303,7 +5303,7 @@ fn analyzeFunction(...@@ -5303,7 +5303,7 @@ fn analyzeFunction(
5303 file,5303 file,
5304 scope,5304 scope,
5305 parent_src,5305 parent_src,
5306 fn_info.body[0],5306 fn_info.body,
5307 call_ctx,5307 call_ctx,
5308 );5308 );
5309 } else {5309 } else {
...@@ -5350,17 +5350,10 @@ fn getGenericReturnType(...@@ -5350,17 +5350,10 @@ fn getGenericReturnType(
5350 file: *File,5350 file: *File,
5351 scope: *Scope,5351 scope: *Scope,
5352 parent_src: SrcLocInfo, // function decl line5352 parent_src: SrcLocInfo, // function decl line
5353 body_main_block: Zir.Inst.Index,5353 body: []const Zir.Inst.Index,
5354 call_ctx: ?*const CallContext,5354 call_ctx: ?*const CallContext,
5355) !DocData.Expr {5355) !DocData.Expr {
5356 const tags = file.zir.instructions.items(.tag);5356 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);
5364 if (body.len >= 4) {5357 if (body.len >= 4) {
5365 const maybe_ret_inst = body[body.len - 4];5358 const maybe_ret_inst = body[body.len - 4];
5366 switch (tags[@intFromEnum(maybe_ret_inst)]) {5359 switch (tags[@intFromEnum(maybe_ret_inst)]) {