fix(viperc/diag): 把“当前实参位置”的记录点下沉到 translate_call_arg(覆盖所有调用路径)

TEMP-DIAG 实测:node=0 curarg=0 trace=1 top=11 —— 节点是合成的(无行号),但“当前实参
位置”压根没被记录,说明该构造器调用没走 CallGenLib 的参数循环,兜底只能退回栈帧(函数定义行)。

改为在**所有调用实参的公共入口** CallGenBase.translate_call_arg 顶部记录(它持有 arg_node),
并移除 CallGenLib 里的重复挂点。这样任何调用路径(含构造器)都能把报错定位到具体实参表达式。
This commit is contained in:
TermiNexus committed 2026-10-14 17:13:38 +08:00
1 parent ca81c1185c
commit 3c6041c97c
2 files changed
+4 -3

No files matched your search

+4
View File
@@ -146,6 +146,10 @@ novirtual class CallGenBase:
trans: HT.Translator*, callee_name: str, arg_idx: int, arg_node: ast.AST*,
fpty: mlirlite.LLVMType*, use_ctx: str = "param") -> mlirlite.Value*:
"""Translate a call argument; value-reference params take the address (ref) or a temp copy (temp)."""
# 记录“当前实参位置”:被调者内部若因**合成节点**(lineno==0,如构造器内联出的参数赋值)
# 报错,可据此把报错精确定位到这个实参表达式(如 `&_on_submit`),而不是退回函数定义行。
if arg_node is not None:
self.Gen.TypeGenBase.set_cur_arg(self.Gen.TypeGenResolve.get_current_file(), arg_node.lineno, arg_node.col_offset + 1)
mode: int = self._auto_addr_mode(callee_name, arg_idx)
if mode == 0:
return self.Gen.ExprGen.translate_value(builder, pool, mod, arg_node, None, 0, trans, fpty, use_ctx)
-3
View File
@@ -221,9 +221,6 @@ novirtual class CallGenLib(CallGenBase.CallGenBase):
if self.Gen.ExprGenBase._str_rejects_ptr_kind(cur) != 0:
if VpiReader._vpi_param_annot_seg_is(sha1_buf, cls_nm, meth_nm, idx, "str") != 0 or VpiReader._vpi_param_annot_seg_is(sha1_buf, cls_nm, meth_nm, idx, "bytes") != 0:
self.Gen.ExprGenBase.fail_if_str_annot_agg_ptr(cur, 1, arg_node)
# 记录当前实参位置:被调者内部报错若是合成节点(无行号),可据此定位到这个实参表达式
if arg_node is not None:
self.Gen.TypeGenBase.set_cur_arg(self.Gen.TypeGenResolve.get_current_file(), arg_node.lineno, arg_node.col_offset + 1)
node_v = self._coerce_arg_value_to_ty(pool, builder, node_v, tgt_ty, arg_node, trans, tpl_src)
if new_head is None: new_head = node_v
else: new_tail.Next = node_v