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

C#: Adopt shared CFG construction library from shared controlflow pack #13595

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Jun 28, 2023

#13509 follow-up.

@hvitved hvitved force-pushed the csharp/use-shared-cfg-pack branch 4 times, most recently from d5bf9d5 to 2d431e9 Compare June 28, 2023 10:14
@hvitved hvitved force-pushed the csharp/use-shared-cfg-pack branch 3 times, most recently from dd8dee0 to ad5dc82 Compare August 3, 2023 09:27
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Aug 4, 2023
@hvitved hvitved marked this pull request as ready for review August 4, 2023 07:22
@hvitved hvitved requested a review from a team as a code owner August 4, 2023 07:22
Copy link
Contributor

@michaelnebel michaelnebel left a comment

Choose a reason for hiding this comment

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

Looks plausible/good to me! :-)
Thank you @hvitved !


/** An AST node. */
class AstNode extends Element, TAstNode {
AstNode() { this = getAChild*(any(@top_level_exprorstmt_parent p | not p instanceof Attribute)) }
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the AstNode class is supposed to be superset of ControlFlowElement (there are both implicit and explicit casts from AstNode -> ControlFlowElement), but it doesn't look like the ControlFlowElement class has as a requirement that its elements should be reachable (via the child relation) from a top level statement/expression?
It looks like the AstNode class is equivalent to the (now deleted) Range class in the ControlFlowTree module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct. (All ControlFlowElements are reachable from a @top_level_exprorstmt_parent; see {expr,stmt}_parent(_top_level) in the DB scheme).


/** Gets a split for this control flow node, if any. */
Split getASplit() { result = splits.getASplit() }
final Split getASplit() { result = super.getASplit() }
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it be mentioned in a change note that there are some predicates that have been made final (or maybe it is unlikely that anyone would have extended this class)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think a change note is needed.

child in [this.getPattern(), this.getCondition().(ControlFlowElement), this.getBody()]
abstract private class CaseTree extends ControlFlowTree instanceof Case {
final override predicate propagatesAbnormal(AstNode child) {
child in [super.getPattern().(ControlFlowElement), super.getCondition(), super.getBody()]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it intentional that we now require specifically that the pattern is a ControlFlowElement instead of the condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its a stylistic change only; I thought it looked nicer to have the cast on the first element in the list.

@hvitved hvitved merged commit 7cc01ea into github:main Aug 17, 2023
17 checks passed
@hvitved hvitved deleted the csharp/use-shared-cfg-pack branch August 17, 2023 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C# no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants