chore(dbg): 删除 NLL 临时诊断(§13 已在 EscapeTest 上验证通过)
实测:var=h confined=1,g(l,h) 不再报错;报错前移到真正的泄漏点 `if 1==0 or a == 1: return l`(where=a return value)。
This commit is contained in:
1 parent
0f504a9010
commit
71730d920c
2 files changed
+3
-19
No files matched your search
@@ -327,15 +327,9 @@ novirtual class CallGenCtor(CallGenBase.CallGenBase):
|
|||||||
if rhs is None or rhs.kind() != ast.ASTKind.New: return 0
|
if rhs is None or rhs.kind() != ast.ASTKind.New: return 0
|
||||||
nn: ast.New* = ast.New*(rhs)
|
nn: ast.New* = ast.New*(rhs)
|
||||||
if nn is None: return 0
|
if nn is None: return 0
|
||||||
# 【临时诊断:定位 §13 NLL 为何不生效,定位后删除】
|
|
||||||
curf: int = 0
|
|
||||||
if self.Gen.StructGen.NllCurFunc is not None: curf = 1
|
|
||||||
VLogger.info(f"[NLL-DBG] var={var_name} src={nn.Source} life={nn.Life} curfunc={curf}", "NLL")
|
|
||||||
if nn.Source != ast.NEW_SRC_HEAP and nn.Source != ast.NEW_SRC_DEFAULT: return 0
|
if nn.Source != ast.NEW_SRC_HEAP and nn.Source != ast.NEW_SRC_DEFAULT: return 0
|
||||||
if nn.Life != ast.NEW_LIFE_DEFAULT: return 0
|
if nn.Life != ast.NEW_LIFE_DEFAULT: return 0
|
||||||
conf: int = self.Gen.StructGen.NllFrameConfined(trans, var_name, rhs)
|
return self.Gen.StructGen.NllFrameConfined(trans, var_name, rhs)
|
||||||
VLogger.info(f"[NLL-DBG] var={var_name} confined={conf}", "NLL")
|
|
||||||
return conf
|
|
||||||
|
|
||||||
def _new_is_owned_heap(self, new_node: ast.New*) -> int:
|
def _new_is_owned_heap(self, new_node: ast.New*) -> int:
|
||||||
"""1=`new` 生成编译器独占释放的堆绑定 / 0=不是"""
|
"""1=`new` 生成编译器独占释放的堆绑定 / 0=不是"""
|
||||||
|
|||||||
@@ -781,8 +781,6 @@ novirtual class StructGenMixin:
|
|||||||
return self._NllListMentions(ast.Tuple*(node).elts, al)
|
return self._NllListMentions(ast.Tuple*(node).elts, al)
|
||||||
ch: list[ast.AST*]* = node.children
|
ch: list[ast.AST*]* = node.children
|
||||||
if ch is not None: return self._NllListMentions(ch, al)
|
if ch is not None: return self._NllListMentions(ch, al)
|
||||||
# 【临时诊断】认不出的种类被判"提及"
|
|
||||||
VLogger.info(f"[NLL-MENTION] unknown kind={k} line={node.lineno}", "NLL")
|
|
||||||
return 1 # 认不出的种类:保守算"提及"
|
return 1 # 认不出的种类:保守算"提及"
|
||||||
|
|
||||||
def _NllAliasSource(self, value: ast.AST*, al: sizet*) -> int:
|
def _NllAliasSource(self, value: ast.AST*, al: sizet*) -> int:
|
||||||
@@ -845,12 +843,8 @@ novirtual class StructGenMixin:
|
|||||||
if a is None or a.kind() != ast.ASTKind.Name: continue
|
if a is None or a.kind() != ast.ASTKind.Name: continue
|
||||||
an: ast.Name* = ast.Name*(a)
|
an: ast.Name* = ast.Name*(a)
|
||||||
if an.id is None or self._NllInSet(al, an.id) == 0: continue
|
if an.id is None or self._NllInSet(al, an.id) == 0: continue
|
||||||
if mask < 0:
|
if mask < 0: return 1
|
||||||
VLogger.info(f"[NLL-UNSAFE] arg-mask-unknown line={node.lineno}", "NLL")
|
if ((mask >> idx) & 1) != 0: return 1
|
||||||
return 1
|
|
||||||
if ((mask >> idx) & 1) != 0:
|
|
||||||
VLogger.info(f"[NLL-UNSAFE] arg-escapes bit={idx} line={node.lineno}", "NLL")
|
|
||||||
return 1
|
|
||||||
return 0
|
return 0
|
||||||
if k == ast.ASTKind.New:
|
if k == ast.ASTKind.New:
|
||||||
# 构造实参里的调用同样要按不安全位置检查
|
# 构造实参里的调用同样要按不安全位置检查
|
||||||
@@ -872,8 +866,6 @@ novirtual class StructGenMixin:
|
|||||||
return self._NllExprUnsafe(ie.orelse, al)
|
return self._NllExprUnsafe(ie.orelse, al)
|
||||||
ch: list[ast.AST*]* = node.children
|
ch: list[ast.AST*]* = node.children
|
||||||
if ch is not None: return self._NllListUnsafe(ch, al)
|
if ch is not None: return self._NllListUnsafe(ch, al)
|
||||||
# 【临时诊断】认不出的表达式种类
|
|
||||||
VLogger.info(f"[NLL-UNSAFE] unknown-expr kind={k} line={node.lineno}", "NLL")
|
|
||||||
return 1 # 认不出的表达式种类:保守按"不安全"处理
|
return 1 # 认不出的表达式种类:保守按"不安全"处理
|
||||||
|
|
||||||
def _NllStmts(self, stmts: list[ast.AST*]*, al: sizet*, def_node: ast.AST*, depth: int) -> int:
|
def _NllStmts(self, stmts: list[ast.AST*]*, al: sizet*, def_node: ast.AST*, depth: int) -> int:
|
||||||
@@ -889,8 +881,6 @@ novirtual class StructGenMixin:
|
|||||||
i += 1
|
i += 1
|
||||||
if st is None: continue
|
if st is None: continue
|
||||||
k: int = st.kind()
|
k: int = st.kind()
|
||||||
# 【临时诊断:定位 NLL 拒绝点,定位后删除】
|
|
||||||
VLogger.info(f"[NLL-ST] line={st.lineno} kind={k}", "NLL")
|
|
||||||
if k == ast.ASTKind.Return:
|
if k == ast.ASTKind.Return:
|
||||||
if self._NllMentions(ast.Return*(st).value, al) != 0: return 0
|
if self._NllMentions(ast.Return*(st).value, al) != 0: return 0
|
||||||
elif k == ast.ASTKind.Assign:
|
elif k == ast.ASTKind.Assign:
|
||||||
|
|||||||
Reference in new issue
Block a user