fix(lifetime): 裸构造判值拷贝不再依赖类型打印比较 - 修 CAM = V3(...) 全局赋值误报
This commit is contained in:
1 parent
d1dd6de070
commit
23236c88ea
1 file changed
+18
-5
@@ -1142,12 +1142,25 @@ novirtual class AssignGenMixin:
|
||||
if ct_ty is not None:
|
||||
ct_en: GenTypes.StructEntry* = self.Gen.StructGen.find_struct_by_type(ct_ty)
|
||||
if ct_en is None or ct_en.HasNew == 0:
|
||||
# 裸构造 `T(...)` 的存储是本帧入口 alloca,但**目标位置是同型聚合值**时语义是
|
||||
# 值拷贝:返回/写入会把整块聚合复制出去,拷贝与源帧无关 —— 判 LIFE_VALUE
|
||||
# (与上方裸数组名的口径一致)。只有裸构造退让成指针的位置(`&T(...)`、指针目标、
|
||||
# 异型聚合目标)才交出本帧地址,判 LIFE_FRAME。
|
||||
# 裸构造 `T(...)` 的存储是本帧入口 alloca,但只要**目标位置是值类型**
|
||||
# (函数按值返回 / 值类型槽 / 全局值存储),写入就是整块聚合拷贝,与源帧无关
|
||||
# ⇒ LIFE_VALUE(与上方 Name 分支同口径)。
|
||||
# 此前还额外要求 `_stg_ty_equal(ct_ty, target_ty)`,而它按类型打印文本比较
|
||||
# (见本类 _stg_ty_equal),`%V3` 带模块 sha1 前缀时经常不相等 ⇒ 于是
|
||||
# `CAM = V3(...)`(模块级全局赋值)被误判成"把本帧地址交给模块级全局"。
|
||||
# 目标位置是地址(`&T(...)`、指针目标、指针槽)才交出本帧地址 ⇒ LIFE_FRAME。
|
||||
if target_ty is not None and self.Gen.ExprGenBase.is_ptr_type(target_ty) == 0:
|
||||
if self._stg_ty_equal(trans.Pool, ct_ty, target_ty) != 0: return GenTypes.LIFE_VALUE
|
||||
return GenTypes.LIFE_VALUE
|
||||
# [TEMP-DIAG] 裸构造仍判帧生命期时的输入快照(定位完删除)
|
||||
hv: int = -1
|
||||
if ct_en is not None: hv = ct_en.HasNew
|
||||
tptr: int = -1
|
||||
if target_ty is not None: tptr = self.Gen.ExprGenBase.is_ptr_type(target_ty)
|
||||
fn_c: str = None
|
||||
if trans._cur_func is not None: fn_c = mlirlite.function_get_name(trans._cur_func)
|
||||
if fn_c is None: fn_c = "?"
|
||||
stdio.printf("[CTOR-DIAG] fn=%s ctor=%s hasnew=%d tptr=%d tgt_none=%d\n",
|
||||
fn_c, ctor_nm, hv, tptr, 1 if target_ty is None else 0)
|
||||
return GenTypes.LIFE_FRAME
|
||||
return GenTypes.LIFE_UNKNOWN
|
||||
if k == ast.ASTKind.New:
|
||||
|
||||
Reference in new issue
Block a user