Skip to content

Commit eabfa31

Browse files
hvitvedaschackmull
authored andcommitted
Synchronize data flow files
1 parent 46933ef commit eabfa31

File tree

21 files changed

+687
-339
lines changed

21 files changed

+687
-339
lines changed

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

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -905,31 +905,35 @@ private predicate localFlowExit(Node node, Configuration config) {
905905
*/
906906
pragma[nomagic]
907907
private predicate localFlowStepPlus(
908-
Node node1, Node node2, boolean preservesValue, Configuration config
908+
Node node1, Node node2, boolean preservesValue, Configuration config, LocalCallContext cc
909909
) {
910+
not isUnreachableInCall(node2, cc.(LocalCallContextSpecificCall).getCall()) and
911+
(
910912
localFlowEntry(node1, config) and
911913
(
912914
localFlowStep(node1, node2, config) and preservesValue = true
913915
or
914916
additionalLocalFlowStep(node1, node2, config) and preservesValue = false
915917
) and
916918
node1 != node2 and
919+
cc.validFor(node1) and
917920
nodeCand(node2, unbind(config))
918921
or
919922
exists(Node mid |
920-
localFlowStepPlus(node1, mid, preservesValue, config) and
923+
localFlowStepPlus(node1, mid, preservesValue, config, cc) and
921924
localFlowStep(mid, node2, config) and
922925
not mid instanceof CastNode and
923926
nodeCand(node2, unbind(config))
924927
)
925928
or
926929
exists(Node mid |
927-
localFlowStepPlus(node1, mid, _, config) and
930+
localFlowStepPlus(node1, mid, _, config, cc) and
928931
additionalLocalFlowStep(mid, node2, config) and
929932
not mid instanceof CastNode and
930933
preservesValue = false and
931934
nodeCand(node2, unbind(config))
932935
)
936+
)
933937
}
934938

935939
/**
@@ -938,9 +942,9 @@ private predicate localFlowStepPlus(
938942
*/
939943
pragma[noinline]
940944
private predicate localFlowBigStep(
941-
Node node1, Node node2, boolean preservesValue, Configuration config
945+
Node node1, Node node2, boolean preservesValue, Configuration config, LocalCallContext callContext
942946
) {
943-
localFlowStepPlus(node1, node2, preservesValue, config) and
947+
localFlowStepPlus(node1, node2, preservesValue, config, callContext) and
944948
localFlowExit(node2, config)
945949
}
946950

@@ -1000,7 +1004,7 @@ private class AccessPathFrontNilNode extends Node {
10001004
(
10011005
any(Configuration c).isSource(this)
10021006
or
1003-
localFlowBigStep(_, this, false, _)
1007+
localFlowBigStep(_, this, false, _, _)
10041008
or
10051009
additionalJumpStep(_, this, _)
10061010
)
@@ -1023,12 +1027,12 @@ private predicate flowCandFwd0(Node node, boolean fromArg, AccessPathFront apf,
10231027
(
10241028
exists(Node mid |
10251029
flowCandFwd(mid, fromArg, apf, config) and
1026-
localFlowBigStep(mid, node, true, config)
1030+
localFlowBigStep(mid, node, true, config, _)
10271031
)
10281032
or
10291033
exists(Node mid, AccessPathFrontNil nil |
10301034
flowCandFwd(mid, fromArg, nil, config) and
1031-
localFlowBigStep(mid, node, false, config) and
1035+
localFlowBigStep(mid, node, false, config, _) and
10321036
apf = node.(AccessPathFrontNilNode).getApf()
10331037
)
10341038
or
@@ -1122,13 +1126,13 @@ private predicate flowCand0(Node node, boolean toReturn, AccessPathFront apf, Co
11221126
apf instanceof AccessPathFrontNil
11231127
or
11241128
exists(Node mid |
1125-
localFlowBigStep(node, mid, true, config) and
1129+
localFlowBigStep(node, mid, true, config, _) and
11261130
flowCand(mid, toReturn, apf, config)
11271131
)
11281132
or
11291133
exists(Node mid, AccessPathFrontNil nil |
11301134
flowCandFwd(node, _, apf, config) and
1131-
localFlowBigStep(node, mid, false, config) and
1135+
localFlowBigStep(node, mid, false, config, _) and
11321136
flowCand(mid, toReturn, nil, config) and
11331137
apf instanceof AccessPathFrontNil
11341138
)
@@ -1363,12 +1367,12 @@ private predicate flowFwd0(
13631367
(
13641368
exists(Node mid |
13651369
flowFwd(mid, fromArg, apf, ap, config) and
1366-
localFlowBigStep(mid, node, true, config)
1370+
localFlowBigStep(mid, node, true, config, _)
13671371
)
13681372
or
13691373
exists(Node mid, AccessPathNil nil |
13701374
flowFwd(mid, fromArg, _, nil, config) and
1371-
localFlowBigStep(mid, node, false, config) and
1375+
localFlowBigStep(mid, node, false, config, _) and
13721376
ap = node.(AccessPathNilNode).getAp() and
13731377
apf = ap.(AccessPathNil).getFront()
13741378
)
@@ -1472,13 +1476,13 @@ private predicate flow0(Node node, boolean toReturn, AccessPath ap, Configuratio
14721476
ap instanceof AccessPathNil
14731477
or
14741478
exists(Node mid |
1475-
localFlowBigStep(node, mid, true, config) and
1479+
localFlowBigStep(node, mid, true, config, _) and
14761480
flow(mid, toReturn, ap, config)
14771481
)
14781482
or
14791483
exists(Node mid, AccessPathNil nil |
14801484
flowFwd(node, _, _, ap, config) and
1481-
localFlowBigStep(node, mid, false, config) and
1485+
localFlowBigStep(node, mid, false, config, _) and
14821486
flow(mid, toReturn, nil, config) and
14831487
ap instanceof AccessPathNil
14841488
)
@@ -1729,15 +1733,19 @@ private class PathNodeSink extends PathNode, TPathNodeSink {
17291733
* a callable is recorded by `cc`.
17301734
*/
17311735
private predicate pathStep(PathNodeMid mid, Node node, CallContext cc, AccessPath ap) {
1732-
localFlowBigStep(mid.getNode(), node, true, mid.getConfiguration()) and
1736+
exists(LocalCallContext localCC | localCC.matchesCallContext(cc) |
1737+
localFlowBigStep(mid.getNode(), node, true, mid.getConfiguration(), localCC) and
17331738
cc = mid.getCallContext() and
17341739
ap = mid.getAp()
17351740
or
1736-
localFlowBigStep(mid.getNode(), node, false, mid.getConfiguration()) and
1741+
localFlowBigStep(mid.getNode(), node, false, mid.getConfiguration(), localCC) and
17371742
cc = mid.getCallContext() and
17381743
mid.getAp() instanceof AccessPathNil and
17391744
ap = node.(AccessPathNilNode).getAp()
1745+
)
17401746
or
1747+
not isUnreachableInCall(node, cc.(CallContextSpecificCall).getCall()) and
1748+
(
17411749
jumpStep(mid.getNode(), node, mid.getConfiguration()) and
17421750
cc instanceof CallContextAny and
17431751
ap = mid.getAp()
@@ -1760,6 +1768,7 @@ private predicate pathStep(PathNodeMid mid, Node node, CallContext cc, AccessPat
17601768
pathThroughCallable(mid, node, cc, ap)
17611769
or
17621770
valuePathThroughCallable(mid, node, cc) and ap = mid.getAp()
1771+
)
17631772
}
17641773

17651774
pragma[noinline]
@@ -1880,7 +1889,7 @@ private predicate pathIntoCallable(
18801889
pathIntoCallable0(mid, callable, i, outercc, call, emptyAp) and
18811890
p.isParameterOf(callable, i)
18821891
|
1883-
if reducedViableImplInCallContext(_, callable, call)
1892+
if recordDataFlowCallSite(call, callable)
18841893
then innercc = TSpecificCall(call, i, emptyAp)
18851894
else innercc = TSomeCall(p, emptyAp)
18861895
)
@@ -2378,7 +2387,7 @@ private module FlowExploration {
23782387
partialPathIntoCallable0(mid, callable, i, outercc, call, emptyAp, ap, config) and
23792388
p.isParameterOf(callable, i)
23802389
|
2381-
if reducedViableImplInCallContext(_, callable, call)
2390+
if recordDataFlowCallSite(call, callable)
23822391
then innercc = TSpecificCall(call, i, emptyAp)
23832392
else innercc = TSomeCall(p, emptyAp)
23842393
)

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -905,31 +905,35 @@ private predicate localFlowExit(Node node, Configuration config) {
905905
*/
906906
pragma[nomagic]
907907
private predicate localFlowStepPlus(
908-
Node node1, Node node2, boolean preservesValue, Configuration config
908+
Node node1, Node node2, boolean preservesValue, Configuration config, LocalCallContext cc
909909
) {
910+
not isUnreachableInCall(node2, cc.(LocalCallContextSpecificCall).getCall()) and
911+
(
910912
localFlowEntry(node1, config) and
911913
(
912914
localFlowStep(node1, node2, config) and preservesValue = true
913915
or
914916
additionalLocalFlowStep(node1, node2, config) and preservesValue = false
915917
) and
916918
node1 != node2 and
919+
cc.validFor(node1) and
917920
nodeCand(node2, unbind(config))
918921
or
919922
exists(Node mid |
920-
localFlowStepPlus(node1, mid, preservesValue, config) and
923+
localFlowStepPlus(node1, mid, preservesValue, config, cc) and
921924
localFlowStep(mid, node2, config) and
922925
not mid instanceof CastNode and
923926
nodeCand(node2, unbind(config))
924927
)
925928
or
926929
exists(Node mid |
927-
localFlowStepPlus(node1, mid, _, config) and
930+
localFlowStepPlus(node1, mid, _, config, cc) and
928931
additionalLocalFlowStep(mid, node2, config) and
929932
not mid instanceof CastNode and
930933
preservesValue = false and
931934
nodeCand(node2, unbind(config))
932935
)
936+
)
933937
}
934938

935939
/**
@@ -938,9 +942,9 @@ private predicate localFlowStepPlus(
938942
*/
939943
pragma[noinline]
940944
private predicate localFlowBigStep(
941-
Node node1, Node node2, boolean preservesValue, Configuration config
945+
Node node1, Node node2, boolean preservesValue, Configuration config, LocalCallContext callContext
942946
) {
943-
localFlowStepPlus(node1, node2, preservesValue, config) and
947+
localFlowStepPlus(node1, node2, preservesValue, config, callContext) and
944948
localFlowExit(node2, config)
945949
}
946950

@@ -1000,7 +1004,7 @@ private class AccessPathFrontNilNode extends Node {
10001004
(
10011005
any(Configuration c).isSource(this)
10021006
or
1003-
localFlowBigStep(_, this, false, _)
1007+
localFlowBigStep(_, this, false, _, _)
10041008
or
10051009
additionalJumpStep(_, this, _)
10061010
)
@@ -1023,12 +1027,12 @@ private predicate flowCandFwd0(Node node, boolean fromArg, AccessPathFront apf,
10231027
(
10241028
exists(Node mid |
10251029
flowCandFwd(mid, fromArg, apf, config) and
1026-
localFlowBigStep(mid, node, true, config)
1030+
localFlowBigStep(mid, node, true, config, _)
10271031
)
10281032
or
10291033
exists(Node mid, AccessPathFrontNil nil |
10301034
flowCandFwd(mid, fromArg, nil, config) and
1031-
localFlowBigStep(mid, node, false, config) and
1035+
localFlowBigStep(mid, node, false, config, _) and
10321036
apf = node.(AccessPathFrontNilNode).getApf()
10331037
)
10341038
or
@@ -1122,13 +1126,13 @@ private predicate flowCand0(Node node, boolean toReturn, AccessPathFront apf, Co
11221126
apf instanceof AccessPathFrontNil
11231127
or
11241128
exists(Node mid |
1125-
localFlowBigStep(node, mid, true, config) and
1129+
localFlowBigStep(node, mid, true, config, _) and
11261130
flowCand(mid, toReturn, apf, config)
11271131
)
11281132
or
11291133
exists(Node mid, AccessPathFrontNil nil |
11301134
flowCandFwd(node, _, apf, config) and
1131-
localFlowBigStep(node, mid, false, config) and
1135+
localFlowBigStep(node, mid, false, config, _) and
11321136
flowCand(mid, toReturn, nil, config) and
11331137
apf instanceof AccessPathFrontNil
11341138
)
@@ -1363,12 +1367,12 @@ private predicate flowFwd0(
13631367
(
13641368
exists(Node mid |
13651369
flowFwd(mid, fromArg, apf, ap, config) and
1366-
localFlowBigStep(mid, node, true, config)
1370+
localFlowBigStep(mid, node, true, config, _)
13671371
)
13681372
or
13691373
exists(Node mid, AccessPathNil nil |
13701374
flowFwd(mid, fromArg, _, nil, config) and
1371-
localFlowBigStep(mid, node, false, config) and
1375+
localFlowBigStep(mid, node, false, config, _) and
13721376
ap = node.(AccessPathNilNode).getAp() and
13731377
apf = ap.(AccessPathNil).getFront()
13741378
)
@@ -1472,13 +1476,13 @@ private predicate flow0(Node node, boolean toReturn, AccessPath ap, Configuratio
14721476
ap instanceof AccessPathNil
14731477
or
14741478
exists(Node mid |
1475-
localFlowBigStep(node, mid, true, config) and
1479+
localFlowBigStep(node, mid, true, config, _) and
14761480
flow(mid, toReturn, ap, config)
14771481
)
14781482
or
14791483
exists(Node mid, AccessPathNil nil |
14801484
flowFwd(node, _, _, ap, config) and
1481-
localFlowBigStep(node, mid, false, config) and
1485+
localFlowBigStep(node, mid, false, config, _) and
14821486
flow(mid, toReturn, nil, config) and
14831487
ap instanceof AccessPathNil
14841488
)
@@ -1729,15 +1733,19 @@ private class PathNodeSink extends PathNode, TPathNodeSink {
17291733
* a callable is recorded by `cc`.
17301734
*/
17311735
private predicate pathStep(PathNodeMid mid, Node node, CallContext cc, AccessPath ap) {
1732-
localFlowBigStep(mid.getNode(), node, true, mid.getConfiguration()) and
1736+
exists(LocalCallContext localCC | localCC.matchesCallContext(cc) |
1737+
localFlowBigStep(mid.getNode(), node, true, mid.getConfiguration(), localCC) and
17331738
cc = mid.getCallContext() and
17341739
ap = mid.getAp()
17351740
or
1736-
localFlowBigStep(mid.getNode(), node, false, mid.getConfiguration()) and
1741+
localFlowBigStep(mid.getNode(), node, false, mid.getConfiguration(), localCC) and
17371742
cc = mid.getCallContext() and
17381743
mid.getAp() instanceof AccessPathNil and
17391744
ap = node.(AccessPathNilNode).getAp()
1745+
)
17401746
or
1747+
not isUnreachableInCall(node, cc.(CallContextSpecificCall).getCall()) and
1748+
(
17411749
jumpStep(mid.getNode(), node, mid.getConfiguration()) and
17421750
cc instanceof CallContextAny and
17431751
ap = mid.getAp()
@@ -1760,6 +1768,7 @@ private predicate pathStep(PathNodeMid mid, Node node, CallContext cc, AccessPat
17601768
pathThroughCallable(mid, node, cc, ap)
17611769
or
17621770
valuePathThroughCallable(mid, node, cc) and ap = mid.getAp()
1771+
)
17631772
}
17641773

17651774
pragma[noinline]
@@ -1880,7 +1889,7 @@ private predicate pathIntoCallable(
18801889
pathIntoCallable0(mid, callable, i, outercc, call, emptyAp) and
18811890
p.isParameterOf(callable, i)
18821891
|
1883-
if reducedViableImplInCallContext(_, callable, call)
1892+
if recordDataFlowCallSite(call, callable)
18841893
then innercc = TSpecificCall(call, i, emptyAp)
18851894
else innercc = TSomeCall(p, emptyAp)
18861895
)
@@ -2378,7 +2387,7 @@ private module FlowExploration {
23782387
partialPathIntoCallable0(mid, callable, i, outercc, call, emptyAp, ap, config) and
23792388
p.isParameterOf(callable, i)
23802389
|
2381-
if reducedViableImplInCallContext(_, callable, call)
2390+
if recordDataFlowCallSite(call, callable)
23822391
then innercc = TSpecificCall(call, i, emptyAp)
23832392
else innercc = TSomeCall(p, emptyAp)
23842393
)

0 commit comments

Comments
 (0)