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

Rust: Add {BreakExpr,ContinueExpr}.getTarget() #17644

Merged
merged 3 commits into from
Oct 3, 2024

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Oct 2, 2024

It is convenient to be able to resolve the target of a break or continue expression, without relying on the CFG. This furthermore allows for the CFG construction to be simplified.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 2, 2024
@hvitved hvitved marked this pull request as ready for review October 2, 2024 13:47
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and certainly cleaner than the original code, though I forget some of the specifics of how ControlFlowTree nodes are supposed to be wired. The tests add a lot of confidence.

}

override predicate last(AstNode last, Completion c) { none() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is having no last node valid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, and we want it because the edge out of {Break,Continue}Expr is defined explicitly (as the jump target) in the succ relation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, having a last node would cause an (incorrect) edge to be created from the break to the next statement sequentially in the program.

@hvitved hvitved merged commit 97c2387 into github:main Oct 3, 2024
14 checks passed
@hvitved hvitved deleted the rust/break-continue-target branch October 3, 2024 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants