Skip to content

Commit 7a74634

Browse files
committed
Java/C++/C#: Simplify.
1 parent cf84a53 commit 7a74634

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

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

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,32 +1402,13 @@ private predicate flowCandFwd(
14021402
else any()
14031403
}
14041404

1405-
/**
1406-
* A node that requires an empty access path and should have its tracked type
1407-
* (re-)computed. This is either a source or a node reached through an
1408-
* additional step.
1409-
*/
1410-
private class AccessPathFrontNilNode extends NormalNodeExt {
1411-
AccessPathFrontNilNode() {
1412-
nodeCand(this, _) and
1413-
(
1414-
any(Configuration c).isSource(this.getNode())
1415-
or
1416-
additionalJumpStepExt(_, this, _)
1417-
)
1418-
}
1419-
1420-
/** Gets the `nil` path front for this node. */
1421-
AccessPathFrontNil getApf() { result = TFrontNil(this.getErasedNodeTypeBound()) }
1422-
}
1423-
14241405
private predicate flowCandFwd0(
14251406
NodeExt node, boolean fromArg, AccessPathFront apf, Configuration config
14261407
) {
14271408
nodeCand2(node, _, false, config) and
14281409
config.isSource(node.getNode()) and
14291410
fromArg = false and
1430-
apf = node.(AccessPathFrontNilNode).getApf()
1411+
apf = TFrontNil(node.getErasedNodeTypeBound())
14311412
or
14321413
nodeCand(node, unbind(config)) and
14331414
(
@@ -1451,7 +1432,7 @@ private predicate flowCandFwd0(
14511432
flowCandFwd(mid, _, nil, config) and
14521433
additionalJumpStepExt(mid, node, config) and
14531434
fromArg = false and
1454-
apf = node.(AccessPathFrontNilNode).getApf()
1435+
apf = TFrontNil(node.getErasedNodeTypeBound())
14551436
)
14561437
or
14571438
exists(NodeExt mid, boolean allowsFieldFlow |
@@ -1814,18 +1795,6 @@ private predicate popWithFront(AccessPath ap0, Content f, AccessPathFront apf, A
18141795
/** Gets the access path obtained by pushing `f` onto `ap`. */
18151796
private AccessPath push(Content f, AccessPath ap) { ap = pop(f, result) }
18161797

1817-
/**
1818-
* A node that requires an empty access path and should have its tracked type
1819-
* (re-)computed. This is either a source or a node reached through an
1820-
* additional step.
1821-
*/
1822-
private class AccessPathNilNode extends NormalNodeExt {
1823-
AccessPathNilNode() { flowCand(this.(AccessPathFrontNilNode), _, _, _) }
1824-
1825-
/** Gets the `nil` path for this node. */
1826-
AccessPathNil getAp() { result = TNil(this.getErasedNodeTypeBound()) }
1827-
}
1828-
18291798
/**
18301799
* Holds if data can flow from a source to `node` with the given `ap`.
18311800
*/
@@ -1842,7 +1811,7 @@ private predicate flowFwd0(
18421811
flowCand(node, _, _, config) and
18431812
config.isSource(node.getNode()) and
18441813
fromArg = false and
1845-
ap = node.(AccessPathNilNode).getAp() and
1814+
ap = TNil(node.getErasedNodeTypeBound()) and
18461815
apf = ap.(AccessPathNil).getFront()
18471816
or
18481817
flowCand(node, _, _, unbind(config)) and
@@ -1868,7 +1837,7 @@ private predicate flowFwd0(
18681837
flowFwd(mid, _, _, nil, config) and
18691838
additionalJumpStepExt(mid, node, config) and
18701839
fromArg = false and
1871-
ap = node.(AccessPathNilNode).getAp() and
1840+
ap = TNil(node.getErasedNodeTypeBound()) and
18721841
apf = ap.(AccessPathNil).getFront()
18731842
)
18741843
or
@@ -2167,7 +2136,7 @@ private newtype TPathNode =
21672136
config.isSource(node) and
21682137
cc instanceof CallContextAny and
21692138
sc instanceof SummaryCtxNone and
2170-
ap = any(AccessPathNilNode nil | nil.getNode() = node).getAp()
2139+
ap = TNil(getErasedNodeTypeBound(node))
21712140
or
21722141
// ... or a step from an existing PathNode to another node.
21732142
exists(PathNodeMid mid |
@@ -2376,7 +2345,7 @@ private predicate pathStep(PathNodeMid mid, Node node, CallContext cc, SummaryCt
23762345
cc instanceof CallContextAny and
23772346
sc instanceof SummaryCtxNone and
23782347
mid.getAp() instanceof AccessPathNil and
2379-
ap = any(AccessPathNilNode nil | nil.getNode() = node).getAp()
2348+
ap = TNil(getErasedNodeTypeBound(node))
23802349
or
23812350
exists(Content f, AccessPath ap0 | pathReadStep(mid, node, ap0, f, cc) and ap = pop(f, ap0)) and
23822351
sc = mid.getSummaryCtx()

0 commit comments

Comments
 (0)