Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c054295

Browse files
committed
Dataflow: Rename option type branches.
1 parent 7eeae49 commit c054295

1 file changed

Lines changed: 50 additions & 44 deletions

File tree

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

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,10 @@ private module Stage2 {
747747

748748
class ApOption = BooleanOption;
749749

750+
ApOption apNone() { result = TBooleanNone() }
751+
752+
ApOption apSome(Ap ap) { result = TBooleanSome(ap) }
753+
750754
class Cc = boolean;
751755

752756
/* Begin: Stage 2 logic. */
@@ -763,7 +767,7 @@ private module Stage2 {
763767
Stage1::revFlow(node, config) and
764768
config.isSource(node) and
765769
cc = false and
766-
argAp = TBooleanNone() and
770+
argAp = apNone() and
767771
ap = false
768772
or
769773
Stage1::revFlow(node, unbind(config)) and
@@ -783,14 +787,14 @@ private module Stage2 {
783787
fwdFlow(mid, _, _, ap, config) and
784788
jumpStep(mid, node, config) and
785789
cc = false and
786-
argAp = TBooleanNone()
790+
argAp = apNone()
787791
)
788792
or
789793
exists(Node mid |
790794
fwdFlow(mid, _, _, ap, config) and
791795
additionalJumpStep(mid, node, config) and
792796
cc = false and
793-
argAp = TBooleanNone() and
797+
argAp = apNone() and
794798
ap = false
795799
)
796800
or
@@ -810,9 +814,7 @@ private module Stage2 {
810814
// flow into a callable
811815
fwdFlowIn(_, node, _, _, ap, config) and
812816
cc = true and
813-
if parameterThroughFlowNodeCand1(node, config)
814-
then argAp = TBooleanSome(ap)
815-
else argAp = TBooleanNone()
817+
if parameterThroughFlowNodeCand1(node, config) then argAp = apSome(ap) else argAp = apNone()
816818
or
817819
// flow out of a callable
818820
exists(DataFlowCall call |
@@ -876,7 +878,7 @@ private module Stage2 {
876878
private predicate fwdFlowOutFromArg(
877879
DataFlowCall call, Node out, boolean argAp, Ap ap, Configuration config
878880
) {
879-
fwdFlowOut(call, out, true, TBooleanSome(argAp), ap, config)
881+
fwdFlowOut(call, out, true, apSome(argAp), ap, config)
880882
}
881883

882884
/**
@@ -905,7 +907,7 @@ private module Stage2 {
905907
fwdFlow(node, _, _, false, config) and
906908
config.isSink(node) and
907909
toReturn = false and
908-
returnAp = TBooleanNone() and
910+
returnAp = apNone() and
909911
ap = false
910912
or
911913
fwdFlow(node, _, _, unbindBool(ap), unbind(config)) and
@@ -925,14 +927,14 @@ private module Stage2 {
925927
jumpStep(node, mid, config) and
926928
revFlow(mid, _, _, ap, config) and
927929
toReturn = false and
928-
returnAp = TBooleanNone()
930+
returnAp = apNone()
929931
)
930932
or
931933
exists(Node mid |
932934
additionalJumpStep(node, mid, config) and
933935
revFlow(mid, _, _, ap, config) and
934936
toReturn = false and
935-
returnAp = TBooleanNone() and
937+
returnAp = apNone() and
936938
ap = false
937939
)
938940
or
@@ -964,9 +966,9 @@ private module Stage2 {
964966
// flow out of a callable
965967
revFlowOut(_, node, _, _, ap, config) and
966968
toReturn = true and
967-
if fwdFlow(node, true, TBooleanSome(_), unbindBool(ap), config)
968-
then returnAp = TBooleanSome(ap)
969-
else returnAp = TBooleanNone()
969+
if fwdFlow(node, true, apSome(_), unbindBool(ap), config)
970+
then returnAp = apSome(ap)
971+
else returnAp = apNone()
970972
)
971973
}
972974

@@ -1048,7 +1050,7 @@ private module Stage2 {
10481050
private predicate revFlowInToReturn(
10491051
DataFlowCall call, ArgumentNode arg, boolean returnAp, Ap ap, Configuration config
10501052
) {
1051-
revFlowIn(call, arg, true, TBooleanSome(returnAp), ap, config)
1053+
revFlowIn(call, arg, true, apSome(returnAp), ap, config)
10521054
}
10531055

10541056
/**
@@ -1060,7 +1062,7 @@ private module Stage2 {
10601062
) {
10611063
exists(ReturnNodeExt ret |
10621064
revFlowOut(call, ret, toReturn, returnAp, ap, config) and
1063-
fwdFlow(ret, true, TBooleanSome(_), ap, config)
1065+
fwdFlow(ret, true, apSome(_), ap, config)
10641066
)
10651067
}
10661068

@@ -1231,6 +1233,10 @@ private module Stage3 {
12311233

12321234
class ApOption = AccessPathFrontOption;
12331235

1236+
ApOption apNone() { result = TAccessPathFrontNone() }
1237+
1238+
ApOption apSome(Ap ap) { result = TAccessPathFrontSome(ap) }
1239+
12341240
class Cc = boolean;
12351241

12361242
/* Begin: Stage 3 logic. */
@@ -1254,7 +1260,7 @@ private module Stage3 {
12541260
Stage2::revFlow(node, _, _, false, config) and
12551261
config.isSource(node) and
12561262
cc = false and
1257-
argAp = TAccessPathFrontNone() and
1263+
argAp = apNone() and
12581264
ap = TFrontNil(getNodeType(node))
12591265
or
12601266
exists(Node mid |
@@ -1272,15 +1278,15 @@ private module Stage3 {
12721278
Stage2::revFlow(node, unbind(config)) and
12731279
jumpStep(mid, node, config) and
12741280
cc = false and
1275-
argAp = TAccessPathFrontNone()
1281+
argAp = apNone()
12761282
)
12771283
or
12781284
exists(Node mid, AccessPathFrontNil nil |
12791285
fwdFlow(mid, _, _, nil, config) and
12801286
Stage2::revFlow(node, unbind(config)) and
12811287
additionalJumpStep(mid, node, config) and
12821288
cc = false and
1283-
argAp = TAccessPathFrontNone() and
1289+
argAp = apNone() and
12841290
ap = TFrontNil(getNodeType(node))
12851291
)
12861292
or
@@ -1304,8 +1310,8 @@ private module Stage3 {
13041310
fwdFlowIn(_, node, _, _, ap, config) and
13051311
cc = true and
13061312
if Stage2::revFlow(node, true, _, unbindBool(ap.toBoolNonEmpty()), config)
1307-
then argAp = TAccessPathFrontSome(ap)
1308-
else argAp = TAccessPathFrontNone()
1313+
then argAp = apSome(ap)
1314+
else argAp = apNone()
13091315
or
13101316
// flow out of a callable
13111317
exists(DataFlowCall call |
@@ -1374,7 +1380,7 @@ private module Stage3 {
13741380
private predicate fwdFlowOutFromArg(
13751381
DataFlowCall call, Node node, Ap argAp, Ap ap, Configuration config
13761382
) {
1377-
fwdFlowOut(call, node, true, TAccessPathFrontSome(argAp), ap, config)
1383+
fwdFlowOut(call, node, true, apSome(argAp), ap, config)
13781384
}
13791385

13801386
/**
@@ -1411,7 +1417,7 @@ private module Stage3 {
14111417
fwdFlow(node, _, _, ap, config) and
14121418
config.isSink(node) and
14131419
toReturn = false and
1414-
returnAp = TAccessPathFrontNone() and
1420+
returnAp = apNone() and
14151421
ap instanceof AccessPathFrontNil
14161422
or
14171423
exists(Node mid |
@@ -1430,15 +1436,15 @@ private module Stage3 {
14301436
jumpStep(node, mid, config) and
14311437
revFlow(mid, _, _, ap, config) and
14321438
toReturn = false and
1433-
returnAp = TAccessPathFrontNone()
1439+
returnAp = apNone()
14341440
)
14351441
or
14361442
exists(Node mid, AccessPathFrontNil nil |
14371443
fwdFlow(node, _, _, ap, config) and
14381444
additionalJumpStep(node, mid, config) and
14391445
revFlow(mid, _, _, nil, config) and
14401446
toReturn = false and
1441-
returnAp = TAccessPathFrontNone() and
1447+
returnAp = apNone() and
14421448
ap instanceof AccessPathFrontNil
14431449
)
14441450
or
@@ -1468,9 +1474,7 @@ private module Stage3 {
14681474
// flow out of a callable
14691475
revFlowOut(_, node, _, _, ap, config) and
14701476
toReturn = true and
1471-
if fwdFlow(node, true, _, ap, config)
1472-
then returnAp = TAccessPathFrontSome(ap)
1473-
else returnAp = TAccessPathFrontNone()
1477+
if fwdFlow(node, true, _, ap, config) then returnAp = apSome(ap) else returnAp = apNone()
14741478
}
14751479

14761480
pragma[nomagic]
@@ -1536,7 +1540,7 @@ private module Stage3 {
15361540
private predicate revFlowInToReturn(
15371541
DataFlowCall call, ArgumentNode arg, Ap returnAp, Ap ap, Configuration config
15381542
) {
1539-
revFlowIn(call, arg, true, TAccessPathFrontSome(returnAp), ap, config)
1543+
revFlowIn(call, arg, true, apSome(returnAp), ap, config)
15401544
}
15411545

15421546
/**
@@ -1548,7 +1552,7 @@ private module Stage3 {
15481552
) {
15491553
exists(ReturnNodeExt ret |
15501554
revFlowOut(call, ret, toReturn, returnAp, ap, config) and
1551-
fwdFlow(ret, true, TAccessPathFrontSome(_), ap, config)
1555+
fwdFlow(ret, true, apSome(_), ap, config)
15521556
)
15531557
}
15541558
/* End: Stage 3 logic. */
@@ -1764,6 +1768,10 @@ private module Stage4 {
17641768

17651769
class ApOption = AccessPathApproxOption;
17661770

1771+
ApOption apNone() { result = TAccessPathApproxNone() }
1772+
1773+
ApOption apSome(Ap ap) { result = TAccessPathApproxSome(ap) }
1774+
17671775
class Cc = CallContext;
17681776

17691777
/* Begin: Stage 4 logic. */
@@ -1784,7 +1792,7 @@ private module Stage4 {
17841792
Stage3::revFlow(node, _, _, _, config) and
17851793
config.isSource(node) and
17861794
cc instanceof CallContextAny and
1787-
argAp = TAccessPathApproxNone() and
1795+
argAp = apNone() and
17881796
ap = TNil(getNodeType(node))
17891797
or
17901798
Stage3::revFlow(node, _, _, _, unbind(config)) and
@@ -1804,14 +1812,14 @@ private module Stage4 {
18041812
fwdFlow(mid, _, _, ap, config) and
18051813
jumpStep(mid, node, config) and
18061814
cc instanceof CallContextAny and
1807-
argAp = TAccessPathApproxNone()
1815+
argAp = apNone()
18081816
)
18091817
or
18101818
exists(Node mid, AccessPathApproxNil nil |
18111819
fwdFlow(mid, _, _, nil, config) and
18121820
additionalJumpStep(mid, node, config) and
18131821
cc instanceof CallContextAny and
1814-
argAp = TAccessPathApproxNone() and
1822+
argAp = apNone() and
18151823
ap = TNil(getNodeType(node))
18161824
)
18171825
)
@@ -1829,9 +1837,7 @@ private module Stage4 {
18291837
exists(ApApprox apa |
18301838
fwdFlowIn(_, node, _, cc, _, ap, config) and
18311839
apa = ap.getFront() and
1832-
if Stage3::revFlow(node, true, _, apa, config)
1833-
then argAp = TAccessPathApproxSome(ap)
1834-
else argAp = TAccessPathApproxNone()
1840+
if Stage3::revFlow(node, true, _, apa, config) then argAp = apSome(ap) else argAp = apNone()
18351841
)
18361842
or
18371843
// flow out of a callable
@@ -1961,7 +1967,7 @@ private module Stage4 {
19611967
private predicate fwdFlowOutFromArg(
19621968
DataFlowCall call, Node node, Ap argAp, Ap ap, Configuration config
19631969
) {
1964-
fwdFlowOut(call, node, any(CallContextCall ccc), _, TAccessPathApproxSome(argAp), ap, config)
1970+
fwdFlowOut(call, node, any(CallContextCall ccc), _, apSome(argAp), ap, config)
19651971
}
19661972

19671973
/**
@@ -1996,7 +2002,7 @@ private module Stage4 {
19962002
fwdFlow(node, _, _, ap, config) and
19972003
config.isSink(node) and
19982004
toReturn = false and
1999-
returnAp = TAccessPathApproxNone() and
2005+
returnAp = apNone() and
20002006
ap instanceof AccessPathApproxNil
20012007
or
20022008
exists(Node mid |
@@ -2015,15 +2021,15 @@ private module Stage4 {
20152021
jumpStep(node, mid, config) and
20162022
revFlow(mid, _, _, ap, config) and
20172023
toReturn = false and
2018-
returnAp = TAccessPathApproxNone()
2024+
returnAp = apNone()
20192025
)
20202026
or
20212027
exists(Node mid, AccessPathApproxNil nil |
20222028
fwdFlow(node, _, _, ap, config) and
20232029
additionalJumpStep(node, mid, config) and
20242030
revFlow(mid, _, _, nil, config) and
20252031
toReturn = false and
2026-
returnAp = TAccessPathApproxNone() and
2032+
returnAp = apNone() and
20272033
ap instanceof AccessPathApproxNil
20282034
)
20292035
or
@@ -2053,9 +2059,9 @@ private module Stage4 {
20532059
// flow out of a callable
20542060
revFlowOut(_, node, _, _, ap, config) and
20552061
toReturn = true and
2056-
if fwdFlow(node, any(CallContextCall ccc), TAccessPathApproxSome(_), ap, config)
2057-
then returnAp = TAccessPathApproxSome(ap)
2058-
else returnAp = TAccessPathApproxNone()
2062+
if fwdFlow(node, any(CallContextCall ccc), apSome(_), ap, config)
2063+
then returnAp = apSome(ap)
2064+
else returnAp = apNone()
20592065
}
20602066

20612067
pragma[nomagic]
@@ -2128,7 +2134,7 @@ private module Stage4 {
21282134
private predicate revFlowInToReturn(
21292135
DataFlowCall call, ArgumentNode arg, Ap returnAp, Ap ap, Configuration config
21302136
) {
2131-
revFlowIn(call, arg, true, TAccessPathApproxSome(returnAp), ap, config)
2137+
revFlowIn(call, arg, true, apSome(returnAp), ap, config)
21322138
}
21332139

21342140
/**
@@ -2140,7 +2146,7 @@ private module Stage4 {
21402146
) {
21412147
exists(ReturnNodeExt ret, CallContextCall ccc |
21422148
revFlowOut(call, ret, toReturn, returnAp, ap, config) and
2143-
fwdFlow(ret, ccc, TAccessPathApproxSome(_), ap, config) and
2149+
fwdFlow(ret, ccc, apSome(_), ap, config) and
21442150
ccc.matchesCall(call)
21452151
)
21462152
}

0 commit comments

Comments
 (0)