-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Ruby: TypeTracker: add smallstep for functions that return their arguments #8302
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
Conversation
@@ -13,7 +13,18 @@ class TypeTrackingNode = DataFlowPublic::LocalSourceNode; | |||
|
|||
predicate simpleLocalFlowStep = DataFlowPrivate::localFlowStepTypeTracker/2; | |||
|
|||
predicate jumpStep = DataFlowPrivate::jumpStep/2; | |||
predicate jumpStep(Node nodeFrom, TypeTrackingNode nodeTo) { |
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.
I don't think this should be a jump step, it should be local.
Please correct me if I'm wrong, but as I understand it, a "jump" step is one that resets the calling context (allowing flow out of a different caller than where it came in). Any reason to allow that here?
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.
I just (ab)used the jumpStep
predicate because that has a LevelStep
summary in smallstepNoCall
. Perhaps it would be better to introduce a new predicate (localStep
?) in the shared TypeTracking library.
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.
I agree that is should be part of simpleLocalFlowStep
above instead.
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.
Actually, it should perhaps be part of localFlowStepTypeTracker
instead, since then it will work recursively (i.e., a method that returns one of its arguments via a call to another method that also does). This means such summarized steps will also be included in LocalSourceNode::flowsTo
, which I guess we want?
Note that if we do this, we need to add a new disjunct to isLocalSourceNode
which includes all nodes that correspond to a ExprNodes::CallCfgNode
.
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.
@hvitved I added the new step to simpleLocalFlowStep
. Somehow this changes the expected output back to the previous version. Not sure if that is desirable or not. I am not sure if/how this can be added to localFlowStepTypeTracker
instead. I ran into some non-monotonic recursion errors.
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.
OK, I have given this some more thought, and I now understand why @aibaars used jumpStep
, namely because it uses LevelStep
. So unless we change the interface to the shared type tracking library, I think that is the best we can do for now. I will revert my changes and go back to using jumpStep
.
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.
With #8317 we should change it to using levelStep
instead.
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.
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.
Let's rebase once that PR is merged.
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.
@aibaars : That PR has now been merged, so let's rebase this PR and use the newly introduced levelStep
.
@@ -13,7 +13,18 @@ class TypeTrackingNode = DataFlowPublic::LocalSourceNode; | |||
|
|||
predicate simpleLocalFlowStep = DataFlowPrivate::localFlowStepTypeTracker/2; | |||
|
|||
predicate jumpStep = DataFlowPrivate::jumpStep/2; | |||
predicate jumpStep(Node nodeFrom, TypeTrackingNode nodeTo) { |
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.
I agree that is should be part of simpleLocalFlowStep
above instead.
@@ -13,7 +13,18 @@ class TypeTrackingNode = DataFlowPublic::LocalSourceNode; | |||
|
|||
predicate simpleLocalFlowStep = DataFlowPrivate::localFlowStepTypeTracker/2; | |||
|
|||
predicate jumpStep = DataFlowPrivate::jumpStep/2; | |||
predicate jumpStep(Node nodeFrom, TypeTrackingNode nodeTo) { |
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.
Actually, it should perhaps be part of localFlowStepTypeTracker
instead, since then it will work recursively (i.e., a method that returns one of its arguments via a call to another method that also does). This means such summarized steps will also be included in LocalSourceNode::flowsTo
, which I guess we want?
Note that if we do this, we need to add a new disjunct to isLocalSourceNode
which includes all nodes that correspond to a ExprNodes::CallCfgNode
.
4c742cc
to
f5784a7
Compare
8f25750
to
e55dd64
Compare
e55dd64
to
200a965
Compare
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.
LGTM, but let's wait for DCA to confirm that performance is not worsened.
Depends on #8317