Skip to content

Conversation

@paldepind
Copy link
Contributor

@paldepind paldepind commented Nov 12, 2024

Adds patterns as data flow nodes.

Also adds flow from the rhs. of a let statement to the lhs. which depends on patterns being in the data flow nodes. That will need some tweaking once we have the CFG layer over the AST layer.

Adds an abstract class for data flow node that corresponds to a CFG nodes for a AST nodes to factor out some common code.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Nov 12, 2024
}

/** A data flow node that corresponds to a CFG node for an AST node. */
abstract private class AstCfgFlowNode extends Node {

Check warning

Code scanning / CodeQL

UnusedField Warning

This class declares the
field n
but does not bind it in the characteristic predicate of any class between it and
ParameterNode
.
This class declares the
field n
but does not bind it in the characteristic predicate of any class between it and
ParameterNode
.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is a real problem. n is used in one of the predicates in AstCfgFlowNode and the subclasses do bind it.

Copy link
Contributor

Choose a reason for hiding this comment

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

You may be able to suppress it with something like

    bindingset[this, n]
    AstCfgFlowNode() { exists(this) and exists(n) }

@paldepind paldepind requested a review from hvitved November 18, 2024 09:16
Copy link
Contributor

@hvitved hvitved left a comment

Choose a reason for hiding this comment

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

LGTM.

}

/** A data flow node that corresponds to a CFG node for an AST node. */
abstract private class AstCfgFlowNode extends Node {
Copy link
Contributor

Choose a reason for hiding this comment

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

You may be able to suppress it with something like

    bindingset[this, n]
    AstCfgFlowNode() { exists(this) and exists(n) }

Comment on lines +293 to +296
exists(LetStmt s |
nodeFrom.getCfgNode().getAstNode() = s.getInitializer() and
nodeTo.getCfgNode().getAstNode() = s.getPat()
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not take CFG splitting into account, but that changes once #17918 lands.

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. I can also adapt this after #17918 (if you don't want to do it all yourself).

@paldepind paldepind merged commit b3668f8 into github:main Nov 19, 2024
14 checks passed
@paldepind paldepind deleted the rust-df-patterns branch November 19, 2024 10:14
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