Skip to content

Commit 6f19ba7

Browse files
committed
Use AstClass::isClassExtendedFrom()
Signed-off-by: Krzysztof Bieganski <kbieganski@antmicro.com>
1 parent 3c5cfaa commit 6f19ba7

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

src/V3Randomize.cpp

+1-13
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,7 @@ class CaptureVisitor final : public VNVisitor {
799799
const bool refIsXref = VN_IS(varRefp, VarXRef);
800800
const bool varIsFuncLocal = varRefp->varp()->isFuncLocal();
801801
const bool varHasAutomaticLifetime = varRefp->varp()->lifetime().isAutomatic();
802-
const bool varIsFieldOfCaller
803-
= callerClassp && varClassp ? isSuperClassOf(varClassp, callerClassp) : false;
802+
const bool varIsFieldOfCaller = AstClass::isClassExtendedFrom(callerClassp, varClassp);
804803
if (refIsXref) return CaptureMode::CAP_VALUE | CaptureMode::CAP_F_XREF;
805804
if (varIsFuncLocal && varHasAutomaticLifetime) return CaptureMode::CAP_VALUE;
806805
// Static var in function (will not be inlined, because it's in class)
@@ -843,17 +842,6 @@ class CaptureVisitor final : public VNVisitor {
843842
m_ignore.emplace(memberSelp);
844843
}
845844

846-
// Returns true if the first class is a superclass of the second class
847-
bool isSuperClassOf(AstClass* const classIsp, AstClass* const classOfp) {
848-
if (classIsp == classOfp) return true;
849-
for (AstClassExtends* extendsp = classOfp->extendsp(); extendsp;
850-
extendsp = VN_AS(extendsp->nextp(), ClassExtends)) {
851-
AstClass* const superClassp = VN_AS(extendsp->childDTypep(), ClassRefDType)->classp();
852-
if (isSuperClassOf(classIsp, superClassp)) return true;
853-
}
854-
return false;
855-
}
856-
857845
// VISITORS
858846

859847
void visit(AstNodeVarRef* nodep) override {

0 commit comments

Comments
 (0)