Fix infinite recursion in visit(AstCovergroup*) and fileline
Two bugs in the covergroup -> AstClass transformation in V3LinkParse: 1. Infinite recursion: when a covergroup has a clocking event (e.g. `@(posedge clk)`), visit(AstCovergroup*) embeds a sentinel AstCovergroup node inside the new AstClass to carry the event for V3Covergroup.cpp. The subsequent iterate(cgClassp) call then visits the sentinel via visit(AstNodeModule*) -> iterateChildren -> which hits visit(AstCovergroup*) again, creating another class with another sentinel, infinitely. Fix: skip transformation in visit(AstCovergroup*) when already inside a covergroup class (m_modp->isCovergroup()), so sentinel nodes are left alone. 2. Wrong fileline column: AstCovergroup was created with the fileline of the identifier token ($<fl>2, the name position) rather than the 'covergroup' keyword token ($<fl>1). This caused warnings about the covergroup to point to the name column instead of the keyword column. Fix: use $<fl>1 (the 'covergroup' keyword fileline) when constructing AstCovergroup in the parser. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
344586dfa2
commit
f147b0854a
|
|
@ -1151,6 +1151,10 @@ class LinkParseVisitor final : public VNVisitor {
|
|||
}
|
||||
|
||||
void visit(AstCovergroup* nodep) override {
|
||||
// If we're already inside a covergroup class, this is the sentinel AstCovergroup
|
||||
// node carrying the clocking event for V3Covergroup — don't re-transform it.
|
||||
if (m_modp && VN_IS(m_modp, Class) && VN_CAST(m_modp, Class)->isCovergroup()) return;
|
||||
|
||||
// Transform raw parse-time AstCovergroup into a fully-formed AstClass
|
||||
cleanFileline(nodep);
|
||||
|
||||
|
|
|
|||
|
|
@ -6913,7 +6913,7 @@ covergroup_declaration<nodep>: // ==IEEE: covergroup_declaration
|
|||
else
|
||||
sampleArgsp = $4;
|
||||
}
|
||||
$$ = new AstCovergroup{$<fl>2, *$2, static_cast<AstVar*>($3),
|
||||
$$ = new AstCovergroup{$<fl>1, *$2, static_cast<AstVar*>($3),
|
||||
static_cast<AstVar*>(sampleArgsp), $6, clockp};
|
||||
GRAMMARP->endLabel($<fl>8, $$, $8); }
|
||||
| yCOVERGROUP yEXTENDS idAny ';'
|
||||
|
|
|
|||
Loading…
Reference in New Issue