astgen: fix corpus mismatches (gap 20→-17)
- endsWithNoReturn: add missing noreturn tags (RET_ERR_VALUE, RET_LOAD, COMPILE_ERROR, UNREACHABLE, TRAP, CHECK_COMPTIME_CONTROL_FLOW, SWITCH_CONTINUE) - defer body: emit dbg_node + ensure_result (unusedResultExpr pattern) - unwrap_optional: add emitDbgStmt before OPTIONAL_PAYLOAD_SAFE - slice: add emitDbgStmt to SLICE_OPEN, SLICE, SLICE_SENTINEL - switchExpr: remove erroneous save_err_ret_index (only in ErrUnion variant) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
37
astgen.c
37
astgen.c
@@ -7,7 +7,6 @@
|
|||||||
#include "astgen.h"
|
#include "astgen.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -1442,10 +1441,17 @@ static bool endsWithNoReturn(GenZir* gz) {
|
|||||||
case ZIR_INST_BREAK_INLINE:
|
case ZIR_INST_BREAK_INLINE:
|
||||||
case ZIR_INST_CONDBR:
|
case ZIR_INST_CONDBR:
|
||||||
case ZIR_INST_CONDBR_INLINE:
|
case ZIR_INST_CONDBR_INLINE:
|
||||||
case ZIR_INST_RET_IMPLICIT:
|
case ZIR_INST_COMPILE_ERROR:
|
||||||
case ZIR_INST_RET_NODE:
|
case ZIR_INST_RET_NODE:
|
||||||
|
case ZIR_INST_RET_LOAD:
|
||||||
|
case ZIR_INST_RET_IMPLICIT:
|
||||||
|
case ZIR_INST_RET_ERR_VALUE:
|
||||||
|
case ZIR_INST_UNREACHABLE:
|
||||||
case ZIR_INST_REPEAT:
|
case ZIR_INST_REPEAT:
|
||||||
case ZIR_INST_REPEAT_INLINE:
|
case ZIR_INST_REPEAT_INLINE:
|
||||||
|
case ZIR_INST_TRAP:
|
||||||
|
case ZIR_INST_CHECK_COMPTIME_CONTROL_FLOW:
|
||||||
|
case ZIR_INST_SWITCH_CONTINUE:
|
||||||
case ZIR_INST_SWITCH_BLOCK:
|
case ZIR_INST_SWITCH_BLOCK:
|
||||||
case ZIR_INST_SWITCH_BLOCK_REF:
|
case ZIR_INST_SWITCH_BLOCK_REF:
|
||||||
case ZIR_INST_SWITCH_BLOCK_ERR_UNION:
|
case ZIR_INST_SWITCH_BLOCK_ERR_UNION:
|
||||||
@@ -3099,6 +3105,10 @@ static uint32_t exprRl(GenZir* gz, Scope* scope, ResultLoc rl, uint32_t node) {
|
|||||||
// unwrap_optional (AstGen.zig:966-985).
|
// unwrap_optional (AstGen.zig:966-985).
|
||||||
case AST_NODE_UNWRAP_OPTIONAL: {
|
case AST_NODE_UNWRAP_OPTIONAL: {
|
||||||
uint32_t lhs = expr(gz, scope, nd.lhs);
|
uint32_t lhs = expr(gz, scope, nd.lhs);
|
||||||
|
advanceSourceCursorToMainToken(ag, node);
|
||||||
|
uint32_t saved_line = ag->source_line - gz->decl_line;
|
||||||
|
uint32_t saved_col = ag->source_column;
|
||||||
|
emitDbgStmt(gz, saved_line, saved_col);
|
||||||
return rvalue(gz, rl,
|
return rvalue(gz, rl,
|
||||||
addUnNode(gz, ZIR_INST_OPTIONAL_PAYLOAD_SAFE, lhs, node), node);
|
addUnNode(gz, ZIR_INST_OPTIONAL_PAYLOAD_SAFE, lhs, node), node);
|
||||||
}
|
}
|
||||||
@@ -3134,7 +3144,11 @@ static uint32_t exprRl(GenZir* gz, Scope* scope, ResultLoc rl, uint32_t node) {
|
|||||||
// slice (AstGen.zig:882-939).
|
// slice (AstGen.zig:882-939).
|
||||||
case AST_NODE_SLICE_OPEN: {
|
case AST_NODE_SLICE_OPEN: {
|
||||||
uint32_t lhs = expr(gz, scope, nd.lhs);
|
uint32_t lhs = expr(gz, scope, nd.lhs);
|
||||||
|
advanceSourceCursorToMainToken(ag, node);
|
||||||
|
uint32_t saved_line = ag->source_line - gz->decl_line;
|
||||||
|
uint32_t saved_col = ag->source_column;
|
||||||
uint32_t start = expr(gz, scope, nd.rhs);
|
uint32_t start = expr(gz, scope, nd.rhs);
|
||||||
|
emitDbgStmt(gz, saved_line, saved_col);
|
||||||
return rvalue(gz, rl,
|
return rvalue(gz, rl,
|
||||||
addPlNodeBin(gz, ZIR_INST_SLICE_START, node, lhs, start), node);
|
addPlNodeBin(gz, ZIR_INST_SLICE_START, node, lhs, start), node);
|
||||||
}
|
}
|
||||||
@@ -3142,10 +3156,14 @@ static uint32_t exprRl(GenZir* gz, Scope* scope, ResultLoc rl, uint32_t node) {
|
|||||||
// Slice[rhs]: { start, end }
|
// Slice[rhs]: { start, end }
|
||||||
const Ast* stree = ag->tree;
|
const Ast* stree = ag->tree;
|
||||||
uint32_t lhs = expr(gz, scope, nd.lhs);
|
uint32_t lhs = expr(gz, scope, nd.lhs);
|
||||||
|
advanceSourceCursorToMainToken(ag, node);
|
||||||
|
uint32_t saved_line = ag->source_line - gz->decl_line;
|
||||||
|
uint32_t saved_col = ag->source_column;
|
||||||
uint32_t start_node = stree->extra_data.arr[nd.rhs];
|
uint32_t start_node = stree->extra_data.arr[nd.rhs];
|
||||||
uint32_t end_node = stree->extra_data.arr[nd.rhs + 1];
|
uint32_t end_node = stree->extra_data.arr[nd.rhs + 1];
|
||||||
uint32_t start_ref = expr(gz, scope, start_node);
|
uint32_t start_ref = expr(gz, scope, start_node);
|
||||||
uint32_t end_ref = expr(gz, scope, end_node);
|
uint32_t end_ref = expr(gz, scope, end_node);
|
||||||
|
emitDbgStmt(gz, saved_line, saved_col);
|
||||||
ensureExtraCapacity(ag, 3);
|
ensureExtraCapacity(ag, 3);
|
||||||
uint32_t payload_index = ag->extra_len;
|
uint32_t payload_index = ag->extra_len;
|
||||||
ag->extra[ag->extra_len++] = lhs;
|
ag->extra[ag->extra_len++] = lhs;
|
||||||
@@ -3161,12 +3179,16 @@ static uint32_t exprRl(GenZir* gz, Scope* scope, ResultLoc rl, uint32_t node) {
|
|||||||
// SliceSentinel[rhs]: { start, end, sentinel }
|
// SliceSentinel[rhs]: { start, end, sentinel }
|
||||||
const Ast* stree = ag->tree;
|
const Ast* stree = ag->tree;
|
||||||
uint32_t lhs = expr(gz, scope, nd.lhs);
|
uint32_t lhs = expr(gz, scope, nd.lhs);
|
||||||
|
advanceSourceCursorToMainToken(ag, node);
|
||||||
|
uint32_t saved_line = ag->source_line - gz->decl_line;
|
||||||
|
uint32_t saved_col = ag->source_column;
|
||||||
uint32_t start_node = stree->extra_data.arr[nd.rhs];
|
uint32_t start_node = stree->extra_data.arr[nd.rhs];
|
||||||
uint32_t end_node = stree->extra_data.arr[nd.rhs + 1];
|
uint32_t end_node = stree->extra_data.arr[nd.rhs + 1];
|
||||||
uint32_t sentinel_node = stree->extra_data.arr[nd.rhs + 2];
|
uint32_t sentinel_node = stree->extra_data.arr[nd.rhs + 2];
|
||||||
uint32_t start_ref = expr(gz, scope, start_node);
|
uint32_t start_ref = expr(gz, scope, start_node);
|
||||||
uint32_t end_ref = expr(gz, scope, end_node);
|
uint32_t end_ref = expr(gz, scope, end_node);
|
||||||
uint32_t sentinel_ref = expr(gz, scope, sentinel_node);
|
uint32_t sentinel_ref = expr(gz, scope, sentinel_node);
|
||||||
|
emitDbgStmt(gz, saved_line, saved_col);
|
||||||
ensureExtraCapacity(ag, 4);
|
ensureExtraCapacity(ag, 4);
|
||||||
uint32_t payload_index = ag->extra_len;
|
uint32_t payload_index = ag->extra_len;
|
||||||
ag->extra[ag->extra_len++] = lhs;
|
ag->extra[ag->extra_len++] = lhs;
|
||||||
@@ -4554,9 +4576,8 @@ static uint32_t switchExpr(
|
|||||||
uint32_t body_node = cd.rhs;
|
uint32_t body_node = cd.rhs;
|
||||||
GenZir case_scope = makeSubBlock(gz, scope);
|
GenZir case_scope = makeSubBlock(gz, scope);
|
||||||
|
|
||||||
// save_err_ret_index (AstGen.zig:7524-7525).
|
// Note: upstream regular switchExpr (AstGen.zig:7625) does NOT emit
|
||||||
if (ag->fn_ret_ty != 0 && nodeMayAppendToErrorTrace(tree, cond_node))
|
// save_err_ret_index. Only switchExprErrUnion (AstGen.zig:7524) does.
|
||||||
addSaveErrRetIndex(&case_scope, ZIR_REF_NONE);
|
|
||||||
|
|
||||||
// Use fullBodyExpr to process body inline (AstGen.zig:8009).
|
// Use fullBodyExpr to process body inline (AstGen.zig:8009).
|
||||||
uint32_t result
|
uint32_t result
|
||||||
@@ -5534,7 +5555,11 @@ static void blockExprStmts(GenZir* gz, Scope* scope,
|
|||||||
} else {
|
} else {
|
||||||
expr_node = dnd.rhs;
|
expr_node = dnd.rhs;
|
||||||
}
|
}
|
||||||
expr(&defer_gen, &defer_gen.base, expr_node);
|
// unusedResultExpr pattern (AstGen.zig:3165, 2641-2646).
|
||||||
|
emitDbgNode(&defer_gen, expr_node);
|
||||||
|
uint32_t defer_result
|
||||||
|
= expr(&defer_gen, &defer_gen.base, expr_node);
|
||||||
|
addEnsureResult(&defer_gen, defer_result, expr_node);
|
||||||
|
|
||||||
// Add break_inline at end (AstGen.zig:3167).
|
// Add break_inline at end (AstGen.zig:3167).
|
||||||
addBreak(&defer_gen, ZIR_INST_BREAK_INLINE, 0, ZIR_REF_VOID_VALUE,
|
addBreak(&defer_gen, ZIR_INST_BREAK_INLINE, 0, ZIR_REF_VOID_VALUE,
|
||||||
|
|||||||
Reference in New Issue
Block a user