-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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() } |
There was a problem hiding this comment.
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() } |
There was a problem hiding this comment.
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() } |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
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.
I've addressed the comments and started a DCA run :) |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 😅
fb62e7a
to
e81c348
Compare
No description provided.