Internals: Add AstNode::isNull(). No functional change.
This commit is contained in:
parent
a5ad26cd28
commit
5f8c06c805
|
|
@ -1555,8 +1555,7 @@ static VCastable computeCastableImp(const AstNodeDType* toDtp, const AstNodeDTyp
|
|||
return VCastable::ENUM_IMPLICIT;
|
||||
if (fromNumericable) return VCastable::ENUM_EXPLICIT;
|
||||
} else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromConstp, Const)) {
|
||||
if (VN_IS(fromConstp, Const) && VN_AS(fromConstp, Const)->num().isNull())
|
||||
return VCastable::COMPATIBLE;
|
||||
if (fromConstp->isNull()) return VCastable::COMPATIBLE;
|
||||
} else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromDtp, ClassRefDType)) {
|
||||
const auto toClassp = VN_AS(toDtp, ClassRefDType)->classp();
|
||||
const auto fromClassp = VN_AS(fromDtp, ClassRefDType)->classp();
|
||||
|
|
|
|||
|
|
@ -2082,6 +2082,7 @@ public:
|
|||
// ACCESSORS for specific types
|
||||
// Alas these can't be virtual or they break when passed a nullptr
|
||||
inline bool isClassHandleValue() const;
|
||||
inline bool isNull() const;
|
||||
inline bool isZero() const;
|
||||
inline bool isOne() const;
|
||||
inline bool isNeqZero() const;
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ bool AstNode::isClassHandleValue() const {
|
|||
return (VN_IS(this, Const) && VN_AS(this, Const)->num().isNull())
|
||||
|| VN_IS(dtypep(), ClassRefDType);
|
||||
}
|
||||
bool AstNode::isNull() const { return VN_IS(this, Const) && VN_AS(this, Const)->num().isNull(); }
|
||||
bool AstNode::isZero() const {
|
||||
return (VN_IS(this, Const) && VN_AS(this, Const)->num().isEqZero());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,8 +82,7 @@ class CastVisitor final : public VNVisitor {
|
|||
}
|
||||
void ensureCast(AstNodeExpr* nodep) {
|
||||
if (castSize(nodep->backp()) != castSize(nodep) || !nodep->user1()) {
|
||||
const AstConst* const constp = VN_CAST(nodep, Const);
|
||||
if (!(constp && constp->num().isNull())) insertCast(nodep, castSize(nodep->backp()));
|
||||
if (!nodep->isNull()) insertCast(nodep, castSize(nodep->backp()));
|
||||
}
|
||||
}
|
||||
void ensureLower32Cast(AstCCast* nodep) {
|
||||
|
|
@ -202,7 +201,7 @@ class CastVisitor final : public VNVisitor {
|
|||
// Constants are of unknown size if smaller than 33 bits, because
|
||||
// we're too lazy to wrap every constant in the universe in
|
||||
// ((IData)#).
|
||||
nodep->user1(nodep->isQuad() || nodep->isWide() || nodep->num().isNull());
|
||||
nodep->user1(nodep->isQuad() || nodep->isWide() || nodep->isNull());
|
||||
}
|
||||
|
||||
// Null dereference protection
|
||||
|
|
|
|||
|
|
@ -6560,8 +6560,8 @@ class WidthVisitor final : public VNVisitor {
|
|||
AstNodeDType* const rhsDtypep = rhsp->dtypep()->skipRefp();
|
||||
if (AstClassRefDType* const rhsClassRefp = VN_CAST(rhsDtypep, ClassRefDType)) {
|
||||
if (isBaseClassRecurse(lhsClassRefp->classp(), rhsClassRefp->classp())) return;
|
||||
} else if (auto* const constp = VN_CAST(rhsp, Const)) {
|
||||
if (constp->num().isNull()) return;
|
||||
} else if (rhsp->isNull()) {
|
||||
return;
|
||||
}
|
||||
nodep->v3error(side << " expects a " << lhsClassRefp->prettyTypeName() << ", got "
|
||||
<< rhsDtypep->prettyTypeName());
|
||||
|
|
|
|||
Loading…
Reference in New Issue