Skip to content

Commit f17f19c

Browse files
committed
Java: Switch to qualified imports.
1 parent 2ed8d5d commit f17f19c

File tree

1 file changed

+25
-20
lines changed

1 file changed

+25
-20
lines changed

java/ql/lib/semmle/code/java/dispatch/DispatchFlow.qll

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
import java
1010
private import VirtualDispatch
1111
private import semmle.code.java.dataflow.internal.BaseSSA
12-
private import semmle.code.java.dataflow.internal.DataFlowUtil
13-
private import semmle.code.java.dataflow.internal.DataFlowPrivate
12+
private import semmle.code.java.dataflow.internal.DataFlowUtil as DataFlow
13+
private import semmle.code.java.dataflow.internal.DataFlowPrivate as DataFlowPrivate
1414
private import semmle.code.java.dataflow.InstanceAccess
1515
private import semmle.code.java.Collections
1616
private import semmle.code.java.Maps
@@ -122,7 +122,7 @@ private predicate relevant(RefType t) {
122122
}
123123

124124
/** A node with a type that is relevant for dispatch flow. */
125-
private class RelevantNode extends Node {
125+
private class RelevantNode extends DataFlow::Node {
126126
RelevantNode() { relevant(this.getType()) }
127127
}
128128

@@ -131,8 +131,8 @@ private class RelevantNode extends Node {
131131
* The instance parameter is considered to have index `-1`.
132132
*/
133133
pragma[nomagic]
134-
private predicate viableParamCand(Call call, int i, ParameterNode p) {
135-
exists(DataFlowCallable callable |
134+
private predicate viableParamCand(Call call, int i, DataFlow::ParameterNode p) {
135+
exists(DataFlowPrivate::DataFlowCallable callable |
136136
callable.asCallable() = dispatchCand(call) and
137137
p.isParameterOf(callable, i) and
138138
p instanceof RelevantNode
@@ -142,8 +142,8 @@ private predicate viableParamCand(Call call, int i, ParameterNode p) {
142142
/**
143143
* Holds if `arg` is a possible argument to `p` taking virtual dispatch into account.
144144
*/
145-
private predicate viableArgParamCand(ArgumentNode arg, ParameterNode p) {
146-
exists(int i, DataFlowCall call |
145+
private predicate viableArgParamCand(DataFlowPrivate::ArgumentNode arg, DataFlow::ParameterNode p) {
146+
exists(int i, DataFlowPrivate::DataFlowCall call |
147147
viableParamCand(call.asCall(), i, p) and
148148
arg.argumentOf(call, i)
149149
)
@@ -182,17 +182,20 @@ private predicate flowStep(RelevantNode n1, RelevantNode n2) {
182182
v.getAUse() = n2.asExpr()
183183
)
184184
or
185-
exists(Callable c | n1.(InstanceParameterNode).getCallable() = c |
185+
exists(Callable c | n1.(DataFlow::InstanceParameterNode).getCallable() = c |
186186
exists(InstanceAccess ia |
187187
ia = n2.asExpr() and ia.getEnclosingCallable() = c and ia.isOwnInstanceAccess()
188188
)
189189
or
190-
n2.(ImplicitInstanceAccess).getInstanceAccess().(OwnInstanceAccess).getEnclosingCallable() = c
190+
n2.(DataFlow::ImplicitInstanceAccess)
191+
.getInstanceAccess()
192+
.(OwnInstanceAccess)
193+
.getEnclosingCallable() = c
191194
)
192195
or
193-
n2.(FieldValueNode).getField().getAnAssignedValue() = n1.asExpr()
196+
n2.(DataFlow::FieldValueNode).getField().getAnAssignedValue() = n1.asExpr()
194197
or
195-
n2.asExpr().(FieldRead).getField() = n1.(FieldValueNode).getField()
198+
n2.asExpr().(FieldRead).getField() = n1.(DataFlow::FieldValueNode).getField()
196199
or
197200
exists(EnumType enum, Method getValue |
198201
enum.getAnEnumConstant().getAnAssignedValue() = n1.asExpr() and
@@ -214,7 +217,9 @@ private predicate flowStep(RelevantNode n1, RelevantNode n2) {
214217
n2.asExpr().(ArrayAccess).getArray() = n1.asExpr()
215218
or
216219
exists(Argument arg |
217-
n1.asExpr() = arg and arg.isVararg() and n2.(ImplicitVarargsArray).getCall() = arg.getCall()
220+
n1.asExpr() = arg and
221+
arg.isVararg() and
222+
n2.(DataFlow::ImplicitVarargsArray).getCall() = arg.getCall()
218223
)
219224
or
220225
exists(AssignExpr a, Variable v |
@@ -255,37 +260,37 @@ private predicate flowStep(RelevantNode n1, RelevantNode n2) {
255260
/**
256261
* Holds if `n` is forward-reachable from a relevant `ClassInstanceExpr`.
257262
*/
258-
private predicate nodeCandFwd(Node n) {
263+
private predicate nodeCandFwd(DataFlow::Node n) {
259264
dispatchOrigin(n.asExpr(), _, _)
260265
or
261-
exists(Node mid | nodeCandFwd(mid) | flowStep(mid, n) or callFlowStepCand(mid, n))
266+
exists(DataFlow::Node mid | nodeCandFwd(mid) | flowStep(mid, n) or callFlowStepCand(mid, n))
262267
}
263268

264269
/**
265270
* Holds if `n` may occur on a dispatch flow path. That is, a path from a
266271
* relevant `ClassInstanceExpr` to a qualifier of a relevant `MethodAccess`.
267272
*/
268-
private predicate nodeCand(Node n) {
273+
private predicate nodeCand(DataFlow::Node n) {
269274
exists(MethodAccess ma |
270275
dispatchOrigin(_, ma, _) and
271-
n = getInstanceArgument(ma) and
276+
n = DataFlow::getInstanceArgument(ma) and
272277
nodeCandFwd(n)
273278
)
274279
or
275-
exists(Node mid | nodeCand(mid) | flowStep(n, mid) or callFlowStepCand(n, mid)) and
280+
exists(DataFlow::Node mid | nodeCand(mid) | flowStep(n, mid) or callFlowStepCand(n, mid)) and
276281
nodeCandFwd(n)
277282
}
278283

279284
/**
280285
* Holds if `n1 -> n2` is a relevant dispatch flow step.
281286
*/
282-
private predicate step(Node n1, Node n2) {
287+
private predicate step(DataFlow::Node n1, DataFlow::Node n2) {
283288
(flowStep(n1, n2) or callFlowStepCand(n1, n2)) and
284289
nodeCand(n1) and
285290
nodeCand(n2)
286291
}
287292

288-
private predicate stepPlus(Node n1, Node n2) = fastTC(step/2)(n1, n2)
293+
private predicate stepPlus(DataFlow::Node n1, DataFlow::Node n2) = fastTC(step/2)(n1, n2)
289294

290295
/**
291296
* Holds if there is flow from a `ClassInstanceExpr` instantiating a type that
@@ -296,7 +301,7 @@ pragma[inline]
296301
private predicate hasDispatchFlow(MethodAccess ma, Method m) {
297302
exists(ClassInstanceExpr cie |
298303
dispatchOrigin(cie, ma, m) and
299-
stepPlus(exprNode(cie), getInstanceArgument(ma))
304+
stepPlus(DataFlow::exprNode(cie), DataFlow::getInstanceArgument(ma))
300305
)
301306
}
302307

0 commit comments

Comments
 (0)