-
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
Data flow: Track call contexts in parameterValueFlow
#17876
Conversation
parameterFlow
parameterValueFlow
6dd83e4
to
9037ff0
Compare
// call may restrict the set of call sites that can be returned to | ||
ctx2.(CachedCallContextSensitivity::CcReturn).isReturn(callable, call) | ||
or | ||
// call does not restrict the set of call sites that can be returned to | ||
not exists(CachedCallContextSensitivity::CcReturn ret | ret.isReturn(callable, call)) and | ||
CachedCallContextSensitivity::viableImplNotCallContextReducedReverse(ctx2) |
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.
This calculation that derives ctx2
from the (callable, call)
pair is a deflating calculation, so it'll be more efficient to do it earlier. We can push it all the way into argumentValueFlowsThrough0
.
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.
Also, it already exists as a bindingset-annotated predicate: getCallContextReturn
, so no need to duplicate that logic.
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.
Done.
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 simplification suggested, otherwise LGTM.
9037ff0
to
045d424
Compare
Cand::argumentValueFlowsThroughCand(arg, _, _) | ||
} | ||
|
||
pragma[nomagic] | ||
private predicate argumentValueFlowsThrough0( | ||
DataFlowCall call, ArgNode arg, ReturnKind kind, ReadStepTypesOption read, string model | ||
DataFlowCall call, DataFlowCallable callable, ArgNode arg, ReturnKind kind, |
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 callable
column is unused and can be pushed into the exists
.
|
||
pragma[nomagic] | ||
private predicate argumentValueFlowsThrough( | ||
DataFlowCall call, DataFlowCallable callable, ArgNode arg, ReadStepTypesOption read, |
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 call
column can be pushed into the exists
here.
@@ -628,6 +628,8 @@ module MakeImplCommon<LocationSig Location, InputSig<Location> Lang> { | |||
override string toString() { | |||
exists(DataFlowCall call | this = TReturn(_, call) | result = "CcReturn(" + call + ")") | |||
} | |||
|
|||
predicate isReturn(DataFlowCallable c, DataFlowCall call) { this = TReturn(c, call) } |
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.
This can be removed now.
045d424
to
fc1bc3a
Compare
fc1bc3a
to
3f56fc9
Compare
When investigating a Ruby performance issue, I found that we produced some false positive return-through-parameter flow, which is because we are not tracking call contexts in the
parameterValueFlow
logic. This PR adds tracking of call contexts.