Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[P4Testgen] Only look ahead for the else branch when it is not null. #4191

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ bool CmdStepper::preorder(const IR::IfStatement *ifStatement) {
// Some path selection strategies depend on looking ahead and collecting potential
// nodes. If that is the case, apply the CoverableNodesScanner visitor.
P4::Coverage::CoverageSet coveredNodes;
if (requiresLookahead(TestgenOptions::get().pathSelectionPolicy)) {
if (ifStatement->ifFalse != nullptr &&
requiresLookahead(TestgenOptions::get().pathSelectionPolicy)) {
auto collector = CoverableNodesScanner(state);
collector.updateNodeCoverage(ifStatement->ifFalse, coveredNodes);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ const P4::Coverage::CoverageSet &CoverableNodesScanner::getCoverableNodes() {

void CoverableNodesScanner::updateNodeCoverage(const IR::Node *node,
P4::Coverage::CoverageSet &nodes) {
CHECK_NULL(node);

static NodeCache CACHED_NODES;
// If the node is already in the cache, return it.
auto it = CACHED_NODES.find(node);
Expand Down