Skip to content

Commit 2cf58fc

Browse files
committed
Dataflow: Remove type from PartialAccessPath.
1 parent e5d36ff commit 2cf58fc

File tree

1 file changed

+21
-32
lines changed

1 file changed

+21
-32
lines changed

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

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3903,46 +3903,35 @@ module Impl<FullStateConfigSig Config> {
39033903
private int distSink(DataFlowCallable c) { result = distSinkExt(TCallable(c)) - 1 }
39043904

39053905
private newtype TPartialAccessPath =
3906-
TPartialNil(DataFlowType t) or
3907-
TPartialCons(TypedContent tc, int len) { len in [1 .. accessPathLimit()] }
3906+
TPartialNil() or
3907+
TPartialCons(Content c, int len) { len in [1 .. accessPathLimit()] }
39083908

39093909
/**
3910-
* Conceptually a list of `TypedContent`s followed by a `Type`, but only the first
3911-
* element of the list and its length are tracked. If data flows from a source to
3912-
* a given node with a given `AccessPath`, this indicates the sequence of
3913-
* dereference operations needed to get from the value in the node to the
3914-
* tracked object. The final type indicates the type of the tracked object.
3910+
* Conceptually a list of `Content`s, but only the first
3911+
* element of the list and its length are tracked.
39153912
*/
39163913
private class PartialAccessPath extends TPartialAccessPath {
39173914
abstract string toString();
39183915

3919-
TypedContent getHead() { this = TPartialCons(result, _) }
3916+
Content getHead() { this = TPartialCons(result, _) }
39203917

39213918
int len() {
3922-
this = TPartialNil(_) and result = 0
3919+
this = TPartialNil() and result = 0
39233920
or
39243921
this = TPartialCons(_, result)
39253922
}
3926-
3927-
DataFlowType getType() {
3928-
this = TPartialNil(result)
3929-
or
3930-
exists(TypedContent head | this = TPartialCons(head, _) | result = head.getContainerType())
3931-
}
39323923
}
39333924

39343925
private class PartialAccessPathNil extends PartialAccessPath, TPartialNil {
3935-
override string toString() {
3936-
exists(DataFlowType t | this = TPartialNil(t) | result = concat(": " + ppReprType(t)))
3937-
}
3926+
override string toString() { result = "" }
39383927
}
39393928

39403929
private class PartialAccessPathCons extends PartialAccessPath, TPartialCons {
39413930
override string toString() {
3942-
exists(TypedContent tc, int len | this = TPartialCons(tc, len) |
3931+
exists(Content c, int len | this = TPartialCons(c, len) |
39433932
if len = 1
3944-
then result = "[" + tc.toString() + "]"
3945-
else result = "[" + tc.toString() + ", ... (" + len.toString() + ")]"
3933+
then result = "[" + c.toString() + "]"
3934+
else result = "[" + c.toString() + ", ... (" + len.toString() + ")]"
39463935
)
39473936
}
39483937
}
@@ -4030,7 +4019,7 @@ module Impl<FullStateConfigSig Config> {
40304019
sc3 = TSummaryCtx3None() and
40314020
sc4 = TSummaryCtx4None() and
40324021
t = node.getDataFlowType() and
4033-
ap = TPartialNil(node.getDataFlowType()) and
4022+
ap = TPartialNil() and
40344023
exists(explorationLimit())
40354024
or
40364025
partialPathNodeMk0(node, state, cc, sc1, sc2, sc3, sc4, t, ap) and
@@ -4066,10 +4055,10 @@ module Impl<FullStateConfigSig Config> {
40664055
partialPathStep(_, node, state, cc, sc1, sc2, sc3, sc4, t, ap) and
40674056
not fullBarrier(node) and
40684057
not stateBarrier(node, state) and
4069-
not clearsContentEx(node, ap.getHead().getContent()) and
4058+
not clearsContentEx(node, ap.getHead()) and
40704059
(
40714060
notExpectsContent(node) or
4072-
expectsContentEx(node, ap.getHead().getContent())
4061+
expectsContentEx(node, ap.getHead())
40734062
) and
40744063
if node.asNode() instanceof CastingNode
40754064
then compatibleTypes(node.getDataFlowType(), t)
@@ -4274,7 +4263,7 @@ module Impl<FullStateConfigSig Config> {
42744263
sc4 = mid.getSummaryCtx4() and
42754264
mid.getAp() instanceof PartialAccessPathNil and
42764265
t = node.getDataFlowType() and
4277-
ap = TPartialNil(node.getDataFlowType())
4266+
ap = TPartialNil()
42784267
or
42794268
additionalLocalStateStep(mid.getNodeEx(), mid.getState(), node, state) and
42804269
cc = mid.getCallContext() and
@@ -4284,7 +4273,7 @@ module Impl<FullStateConfigSig Config> {
42844273
sc4 = mid.getSummaryCtx4() and
42854274
mid.getAp() instanceof PartialAccessPathNil and
42864275
t = node.getDataFlowType() and
4287-
ap = TPartialNil(node.getDataFlowType())
4276+
ap = TPartialNil()
42884277
)
42894278
or
42904279
jumpStepEx(mid.getNodeEx(), node) and
@@ -4306,7 +4295,7 @@ module Impl<FullStateConfigSig Config> {
43064295
sc4 = TSummaryCtx4None() and
43074296
mid.getAp() instanceof PartialAccessPathNil and
43084297
t = node.getDataFlowType() and
4309-
ap = TPartialNil(node.getDataFlowType())
4298+
ap = TPartialNil()
43104299
or
43114300
additionalJumpStateStep(mid.getNodeEx(), mid.getState(), node, state) and
43124301
cc instanceof CallContextAny and
@@ -4316,7 +4305,7 @@ module Impl<FullStateConfigSig Config> {
43164305
sc4 = TSummaryCtx4None() and
43174306
mid.getAp() instanceof PartialAccessPathNil and
43184307
t = node.getDataFlowType() and
4319-
ap = TPartialNil(node.getDataFlowType())
4308+
ap = TPartialNil()
43204309
or
43214310
partialPathStoreStep(mid, _, _, _, node, t, ap) and
43224311
state = mid.getState() and
@@ -4359,12 +4348,12 @@ module Impl<FullStateConfigSig Config> {
43594348
PartialPathNodeFwd mid, DataFlowType t1, PartialAccessPath ap1, Content c, NodeEx node,
43604349
DataFlowType t2, PartialAccessPath ap2
43614350
) {
4362-
exists(NodeEx midNode, DataFlowType contentType, TypedContent tc |
4351+
exists(NodeEx midNode, DataFlowType contentType |
43634352
midNode = mid.getNodeEx() and
43644353
t1 = mid.getType() and
43654354
ap1 = mid.getAp() and
4366-
storeEx(midNode, tc, c, node, contentType, t2) and
4367-
ap2.getHead() = tc and
4355+
storeEx(midNode, _, c, node, contentType, t2) and
4356+
ap2.getHead() = c and
43684357
ap2.len() = unbindInt(ap1.len() + 1) and
43694358
compatibleTypes(t1, contentType)
43704359
)
@@ -4384,7 +4373,7 @@ module Impl<FullStateConfigSig Config> {
43844373
t = mid.getType() and
43854374
ap = mid.getAp() and
43864375
read(midNode, c, node) and
4387-
ap.getHead().getContent() = c and
4376+
ap.getHead() = c and
43884377
cc = mid.getCallContext()
43894378
)
43904379
}

0 commit comments

Comments
 (0)