Start cloning from the 2nd iteration

Signed-off-by: Ryszard Rozak <rrozak@antmicro.com>
This commit is contained in:
Ryszard Rozak 2026-02-11 10:02:47 +01:00
parent 93904eb786
commit db5f454d86
1 changed files with 5 additions and 3 deletions

View File

@ -151,15 +151,17 @@ public:
} else if (const AstStructDType* const structDtypep
= VN_CAST(lhsDtypep, StructDType)) {
AstNodeStmt* stmtsp = nullptr;
bool firstIter = true;
for (AstMemberDType* mdtp = structDtypep->membersp(); mdtp;
mdtp = VN_AS(mdtp->nextp(), MemberDType)) {
AstNodeExpr* const lhsCopyp = lhsp->cloneTreePure(false);
AstVarRef* const lhsVarRefCopyp = lhsVarRefp->clonep();
AstNodeExpr* const lhsCopyp = firstIter ? lhsp : lhsp->cloneTreePure(false);
AstVarRef* const lhsVarRefCopyp = firstIter ? lhsVarRefp : lhsVarRefp->clonep();
AstStructSel* const structSelp = new AstStructSel{flp, lhsCopyp, mdtp->name()};
structSelp->dtypep(mdtp);
AstNodeStmt* const memberStmtp
= getAssignStmtsp(structSelp, vscp, lhsVarRefCopyp, assigns);
stmtsp = stmtsp ? stmtsp->addNext(memberStmtp) : memberStmtp;
stmtsp = firstIter ? memberStmtp : stmtsp->addNext(memberStmtp);
firstIter = false;
}
return stmtsp;
} else if (const AstUnpackArrayDType* const arrayDtypep