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: Extend data flow library instantiation for global data flow #18056

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

paldepind
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Nov 21, 2024
@paldepind paldepind marked this pull request as ready for review November 21, 2024 14:32
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.

Great work, nice to see that we now have some inter-procedural flow.

/**
* The value of a parameter at function entry, viewed as a node in a data
* flow graph.
*/
final class ParameterNode extends AstCfgFlowNode, TParameterNode {
final class NormalParameterNode extends ParameterNode, TParameterNode {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps PositionalParameterNode instead?

Node getPreUpdateNode() { none() }
Node getPreUpdateNode() { result = TExprNode(n) }

final override CfgScope getCfgScope() { result = n.getAstNode().getEnclosingCfgScope() }
Copy link
Contributor

Choose a reason for hiding this comment

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

result = n.getScope()


final override CfgScope getCfgScope() { result = n.getAstNode().getEnclosingCfgScope() }

final override Location getLocation() { result = n.getAstNode().getLocation() }
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for the intermediate .getAstNode()


final override Location getLocation() { result = n.getAstNode().getLocation() }

final override string toString() { result = n.getAstNode().toString() }
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for the intermediate .getAstNode()

@@ -185,7 +230,10 @@ module Node {

/** A data flow node that represents a value returned by a callable. */
final class ReturnNode extends ExprNode {
ReturnNode() { this.getCfgNode().getASuccessor() instanceof ExitCfgNode }
ReturnNode() {
this.getCfgNode().getASuccessor() instanceof ExitCfgNode or
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this disjunct actually needed?

predicate isParameterNode(ParameterNode p, DataFlowCallable c, ParameterPosition pos) { none() }
/** Holds if `p` is a parameter of `c` at the position `pos`. */
predicate isParameterNode(ParameterNode p, DataFlowCallable c, ParameterPosition pos) {
p.getCfgNode().getAstNode() = pos.getParameterIn(c.asCfgScope().(Function).getParamList())
Copy link
Contributor

Choose a reason for hiding this comment

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

Use Callable instead of Function to also include closures.

cached
newtype TParameterPosition =
TPositionalParameterPosition(int i) {
exists(any(ParamList l).getParam(i)) or exists(any(ArgList l).getArg(i))
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, i in [0 .. max([any(ParamList l).getNumberOfParams(), any(ArgList l).getNumberOfArgs()] - 1].

testFailures
| main.rs:45:10:45:10 | a | Fixed missing result: hasValueFlow=14 |
Copy link
Contributor

Choose a reason for hiding this comment

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

The MISSING marked should be removed in the test.

@paldepind
Copy link
Contributor Author

I've addressed the comments and started a DCA run :)

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.

One last thing, otherwise LGTM.

@@ -231,7 +231,7 @@ module Node {
/** A data flow node that represents a value returned by a callable. */
final class ReturnNode extends ExprNode {
ReturnNode() {
this.getCfgNode().getASuccessor() instanceof ExitCfgNode or
// this.getCfgNode().getASuccessor() instanceof ExitCfgNode or
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed 😅

@hvitved hvitved merged commit faabc99 into github:main Nov 22, 2024
15 checks passed
@paldepind paldepind deleted the rust-df-global branch November 22, 2024 12:50
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