Skip to content

Commit f90201e

Browse files
committed
Data flow: Remove column from mayBenefitFromCallContext
1 parent 25e2271 commit f90201e

File tree

17 files changed

+85
-126
lines changed

17 files changed

+85
-126
lines changed

cpp/ql/lib/semmle/code/cpp/dataflow/internal/DataFlowDispatch.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,6 @@ private predicate functionSignature(Function f, string qualifiedName, int nparam
5454
not f.isStatic()
5555
}
5656

57-
/**
58-
* Holds if the set of viable implementations that can be called by `call`
59-
* might be improved by knowing the call context.
60-
*/
61-
predicate mayBenefitFromCallContext(DataFlowCall call, Function f) { none() }
62-
63-
/**
64-
* Gets a viable dispatch target of `call` in the context `ctx`. This is
65-
* restricted to those `call`s for which a context might make a difference.
66-
*/
67-
Function viableImplInCallContext(DataFlowCall call, DataFlowCall ctx) { none() }
68-
6957
/** A parameter position represented by an integer. */
7058
class ParameterPosition extends int {
7159
ParameterPosition() { any(ParameterNode p).isParameterOf(_, this) }

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowDispatch.qll

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,7 @@ private predicate functionSignature(Function f, string qualifiedName, int nparam
249249
* Holds if the set of viable implementations that can be called by `call`
250250
* might be improved by knowing the call context.
251251
*/
252-
predicate mayBenefitFromCallContext(DataFlowCall call, DataFlowCallable f) {
253-
mayBenefitFromCallContext(call, f, _)
254-
}
252+
predicate mayBenefitFromCallContext(DataFlowCall call) { mayBenefitFromCallContext(call, _, _) }
255253

256254
/**
257255
* Holds if `call` is a call through a function pointer, and the pointer

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/DataFlowImplSpecific.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,8 @@ module CppDataFlow implements InputSig {
2222
predicate getAdditionalFlowIntoCallNodeTerm = Private::getAdditionalFlowIntoCallNodeTerm/2;
2323

2424
predicate validParameterAliasStep = Private::validParameterAliasStep/2;
25+
26+
predicate mayBenefitFromCallContext = Private::mayBenefitFromCallContext/1;
27+
28+
predicate viableImplInCallContext = Private::viableImplInCallContext/2;
2529
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,17 +148,17 @@ private module Cached {
148148
import Cached
149149

150150
private module DispatchImpl {
151-
/**
152-
* Holds if the set of viable implementations that can be called by `call`
153-
* might be improved by knowing the call context. This is the case if the
154-
* call is a delegate call, or if the qualifier accesses a parameter of
155-
* the enclosing callable `c` (including the implicit `this` parameter).
156-
*/
157-
predicate mayBenefitFromCallContext(DataFlowCall call, DataFlowCallable c) {
151+
private predicate mayBenefitFromCallContext(DataFlowCall call, DataFlowCallable c) {
158152
c = call.getEnclosingCallable() and
159153
call.(NonDelegateDataFlowCall).getDispatchCall().mayBenefitFromCallContext()
160154
}
161155

156+
/**
157+
* Holds if the set of viable implementations that can be called by `call`
158+
* might be improved by knowing the call context.
159+
*/
160+
predicate mayBenefitFromCallContext(DataFlowCall call) { mayBenefitFromCallContext(call, _) }
161+
162162
/**
163163
* Gets a viable dispatch target of `call` in the context `ctx`. This is
164164
* restricted to those `call`s for which a context might make a difference.

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowImplSpecific.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@ module CsharpDataFlow implements InputSig {
2020
Node exprNode(DataFlowExpr e) { result = Public::exprNode(e) }
2121

2222
predicate accessPathLimit = Private::accessPathLimit/0;
23+
24+
predicate mayBenefitFromCallContext = Private::mayBenefitFromCallContext/1;
25+
26+
predicate viableImplInCallContext = Private::viableImplInCallContext/2;
2327
}

docs/ql-libraries/dataflow/dataflow.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,18 +588,17 @@ However, joining the virtual dispatch relation with itself in this way is
588588
usually way too big to be feasible. Instead, the relation above should only be
589589
defined for those values of `call` for which the set of resulting dispatch
590590
targets might be reduced. To do this, define the set of `call`s that might for
591-
some reason benefit from a call context as the following predicate (the `c`
592-
column should be `call.getEnclosingCallable()`):
591+
some reason benefit from a call context as the following predicate:
593592
```ql
594-
predicate mayBenefitFromCallContext(DataFlowCall call, DataFlowCallable c)
593+
predicate mayBenefitFromCallContext(DataFlowCall call)
595594
```
596595
And then define `DataFlowCallable viableImplInCallContext(DataFlowCall call,
597596
DataFlowCall ctx)` as sketched above, but restricted to
598-
`mayBenefitFromCallContext(call, _)`.
597+
`mayBenefitFromCallContext(call)`.
599598

600599
The shared implementation will then compare counts of virtual dispatch targets
601600
using `viableCallable` and `viableImplInCallContext` for each `call` in
602-
`mayBenefitFromCallContext(call, _)` and track call contexts during flow
601+
`mayBenefitFromCallContext(call)` and track call contexts during flow
603602
calculation when differences in these counts show an improved precision in
604603
further calls.
605604

go/ql/lib/semmle/go/dataflow/internal/DataFlowDispatch.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,6 @@ DataFlowCallable viableCallable(DataFlowCall ma) {
104104
)
105105
}
106106

107-
/**
108-
* Holds if the set of viable implementations that can be called by `call`
109-
* might be improved by knowing the call context.
110-
*/
111-
predicate mayBenefitFromCallContext(DataFlowCall call, DataFlowCallable f) { none() }
112-
113-
/**
114-
* Gets a viable dispatch target of `call` in the context `ctx`. This is
115-
* restricted to those `call`s for which a context might make a difference.
116-
*/
117-
DataFlowCallable viableImplInCallContext(DataFlowCall call, DataFlowCall ctx) { none() }
118-
119107
private int parameterPosition() {
120108
result = [-1 .. any(DataFlowCallable c).getType().getNumParameter()]
121109
}

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowDispatch.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ private module DispatchImpl {
116116
/**
117117
* Holds if the set of viable implementations that can be called by `call`
118118
* might be improved by knowing the call context. This is the case if the
119-
* qualifier is a parameter of the enclosing callable `c`.
119+
* qualifier is a parameter of the enclosing callable of `call`.
120120
*/
121-
predicate mayBenefitFromCallContext(DataFlowCall call, DataFlowCallable c) {
122-
mayBenefitFromCallContext(call.asCall(), c.asCallable(), _)
121+
predicate mayBenefitFromCallContext(DataFlowCall call) {
122+
mayBenefitFromCallContext(call.asCall(), _, _)
123123
}
124124

125125
/**

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplSpecific.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@ module JavaDataFlow implements InputSig {
1818
import Public
1919

2020
Node exprNode(DataFlowExpr e) { result = Public::exprNode(e) }
21+
22+
predicate mayBenefitFromCallContext = Private::mayBenefitFromCallContext/1;
23+
24+
predicate viableImplInCallContext = Private::viableImplInCallContext/2;
2125
}

python/ql/lib/semmle/python/dataflow/new/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,22 +1009,6 @@ predicate attributeClearStep(Node n, AttributeContent c) {
10091009
*/
10101010
predicate isUnreachableInCall(Node n, DataFlowCall call) { none() }
10111011

1012-
//--------
1013-
// Virtual dispatch with call context
1014-
//--------
1015-
/**
1016-
* Gets a viable dispatch target of `call` in the context `ctx`. This is
1017-
* restricted to those `call`s for which a context might make a difference.
1018-
*/
1019-
DataFlowCallable viableImplInCallContext(DataFlowCall call, DataFlowCall ctx) { none() }
1020-
1021-
/**
1022-
* Holds if the set of viable implementations that can be called by `call`
1023-
* might be improved by knowing the call context. This is the case if the qualifier accesses a parameter of
1024-
* the enclosing callable `c` (including the implicit `this` parameter).
1025-
*/
1026-
predicate mayBenefitFromCallContext(DataFlowCall call, DataFlowCallable c) { none() }
1027-
10281012
/**
10291013
* Holds if access paths with `c` at their head always should be tracked at high
10301014
* precision. This disables adaptive access path precision for such access paths.

0 commit comments

Comments
 (0)