Add warning on expression coverage class references (#5870)
This commit is contained in:
parent
c508fd5d24
commit
8c287134d7
|
@ -39,9 +39,26 @@ class ExprCoverageEligibleVisitor final : public VNVisitor {
|
|||
// STATE
|
||||
bool m_eligible = true;
|
||||
|
||||
void visit(AstNodeVarRef* nodep) override {
|
||||
AstNodeDType* dtypep = nodep->varp()->dtypep();
|
||||
// Class objecs and references not supported for expression coverage
|
||||
// because the object may not persist until the point at which
|
||||
// coverage data is gathered
|
||||
// This could be resolved in the future by protecting against dereferrencing
|
||||
// null pointers when cloning the expression for expression coverage
|
||||
if (VN_CAST(dtypep, ClassRefDType)) {
|
||||
m_eligible = false;
|
||||
} else {
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
void visit(AstNode* nodep) override {
|
||||
if (!nodep->isExprCoverageEligible()) m_eligible = false;
|
||||
iterateChildren(nodep);
|
||||
if (!nodep->isExprCoverageEligible()) {
|
||||
m_eligible = false;
|
||||
} else {
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -289,6 +289,7 @@
|
|||
logic ta, tb, tc;
|
||||
initial begin
|
||||
cls obj = new;
|
||||
cls null_obj = null;
|
||||
int q[5];
|
||||
int qv[$];
|
||||
|
||||
|
@ -310,6 +311,7 @@
|
|||
ta = '0;
|
||||
end
|
||||
if (!bit'(obj.randomize() with {x < 100;})) $write("");
|
||||
if (null_obj != null && null_obj.x == 5) $write("");
|
||||
end
|
||||
|
||||
sub the_sub_1 (.p(t1), .q(t2));
|
||||
|
|
|
@ -129,6 +129,7 @@ module t (/*AUTOARG*/
|
|||
logic ta, tb, tc;
|
||||
initial begin
|
||||
cls obj = new;
|
||||
cls null_obj = null;
|
||||
int q[5];
|
||||
int qv[$];
|
||||
|
||||
|
@ -146,6 +147,7 @@ module t (/*AUTOARG*/
|
|||
ta = '0;
|
||||
end
|
||||
if (!bit'(obj.randomize() with {x < 100;})) $write("");
|
||||
if (null_obj != null && null_obj.x == 5) $write("");
|
||||
end
|
||||
|
||||
sub the_sub_1 (.p(t1), .q(t2));
|
||||
|
|
|
@ -417,6 +417,7 @@
|
|||
logic ta, tb, tc;
|
||||
initial begin
|
||||
cls obj = new;
|
||||
cls null_obj = null;
|
||||
int q[5];
|
||||
int qv[$];
|
||||
|
||||
|
@ -438,6 +439,7 @@
|
|||
ta = '0;
|
||||
end
|
||||
if (!bit'(obj.randomize() with {x < 100;})) $write("");
|
||||
if (null_obj != null && null_obj.x == 5) $write("");
|
||||
end
|
||||
|
||||
sub the_sub_1 (.p(t1), .q(t2));
|
||||
|
|
|
@ -289,6 +289,7 @@
|
|||
logic ta, tb, tc;
|
||||
initial begin
|
||||
cls obj = new;
|
||||
cls null_obj = null;
|
||||
int q[5];
|
||||
int qv[$];
|
||||
|
||||
|
@ -310,6 +311,7 @@
|
|||
ta = '0;
|
||||
end
|
||||
if (!bit'(obj.randomize() with {x < 100;})) $write("");
|
||||
if (null_obj != null && null_obj.x == 5) $write("");
|
||||
end
|
||||
|
||||
sub the_sub_1 (.p(t1), .q(t2));
|
||||
|
|
Loading…
Reference in New Issue