Fix randomizing current object with rand class instance member (#5292)

Signed-off-by: Krzysztof Bieganski <[email protected]>
This commit is contained in:
Krzysztof Bieganski
2024-07-22 14:41:12 +02:00
committed by GitHub
parent 8f4490628f
commit f5caa4b7dc
3 changed files with 31 additions and 13 deletions
+11 -11
View File
@@ -119,20 +119,20 @@ class RandomizeMarkVisitor final : public VNVisitorConst {
m_baseToDerivedMap[basep].insert(nodep);
}
}
void visit(AstMethodCall* nodep) override {
if (nodep->name() != "randomize") return;
if (const AstClassRefDType* const classRefp
= VN_CAST(nodep->fromp()->dtypep()->skipRefp(), ClassRefDType)) {
AstClass* const classp = classRefp->classp();
classp->user1(true);
markMembers(classp);
}
iterateChildrenConst(nodep);
}
void visit(AstNodeFTaskRef* nodep) override {
iterateChildrenConst(nodep);
if (nodep->name() != "randomize") return;
if (m_classp) m_classp->user1(true);
AstClass* classp = m_classp;
if (const AstMethodCall* const methodCallp = VN_CAST(nodep, MethodCall)) {
if (const AstClassRefDType* const classRefp
= VN_CAST(methodCallp->fromp()->dtypep()->skipRefp(), ClassRefDType)) {
classp = classRefp->classp();
}
}
if (classp) {
classp->user1(true);
markMembers(classp);
}
}
void visit(AstConstraintExpr* nodep) override {
VL_RESTORER(m_constraintExprp);