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

Skip to content

Commit b6f1ab6

Browse files
committed
Dataflow: Refactor step relation in revFlowStore.
1 parent 12fe38b commit b6f1ab6

1 file changed

Lines changed: 32 additions & 18 deletions

File tree

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

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,15 @@ private module Stage2 {
955955
)
956956
}
957957

958+
pragma[nomagic]
959+
private predicate storeStepFwd(
960+
Node node1, Ap ap1, TypedContent tc, Node node2, Ap ap2, Configuration config
961+
) {
962+
fwdFlowStore(node1, ap1, tc, node2, _, _, config) and
963+
ap2 = apCons(tc, ap1) and
964+
fwdFlowRead(ap2, tc.getContent(), _, _, _, _, config)
965+
}
966+
958967
private predicate readStepFwd(Node n1, Ap ap1, Content c, Node n2, Ap ap2, Configuration config) {
959968
fwdFlowRead(ap1, c, n1, n2, _, _, config) and
960969
fwdFlowConsCand(ap1, c, ap2, config)
@@ -1049,10 +1058,8 @@ private module Stage2 {
10491058
ApOption returnAp, Configuration config
10501059
) {
10511060
revFlow(mid, toReturn, returnAp, ap0, config) and
1052-
storeCand1(node, tc, mid, config) and
1053-
tc.getContent() = c and
1054-
ap0 = true and
1055-
fwdFlow(node, _, _, ap, unbind(config))
1061+
storeStepFwd(node, ap, tc, mid, ap0, config) and
1062+
tc.getContent() = c
10561063
}
10571064

10581065
/**
@@ -1518,6 +1525,15 @@ private module Stage3 {
15181525
)
15191526
}
15201527

1528+
pragma[nomagic]
1529+
private predicate storeStepFwd(
1530+
Node node1, Ap ap1, TypedContent tc, Node node2, Ap ap2, Configuration config
1531+
) {
1532+
fwdFlowStore(node1, ap1, tc, node2, _, _, config) and
1533+
ap2 = apCons(tc, ap1) and
1534+
fwdFlowRead(ap2, tc.getContent(), _, _, _, _, config)
1535+
}
1536+
15211537
private predicate readStepFwd(Node n1, Ap ap1, Content c, Node n2, Ap ap2, Configuration config) {
15221538
fwdFlowRead(ap1, c, n1, n2, _, _, config) and
15231539
fwdFlowConsCand(ap1, c, ap2, config)
@@ -1616,10 +1632,8 @@ private module Stage3 {
16161632
Ap ap0, Content c, Ap ap, Node node, TypedContent tc, Node mid, boolean toReturn,
16171633
ApOption returnAp, Configuration config
16181634
) {
1619-
revFlow(mid, toReturn, returnAp, ap0, unbind(config)) and
1620-
fwdFlow(node, _, _, ap, config) and
1621-
storeCand2(node, tc, mid, _, unbind(config)) and
1622-
ap0 = TFrontHead(tc) and
1635+
revFlow(mid, toReturn, returnAp, ap0, config) and
1636+
storeStepFwd(node, ap, tc, mid, ap0, config) and
16231637
tc.getContent() = c
16241638
}
16251639

@@ -2140,6 +2154,15 @@ private module Stage4 {
21402154
)
21412155
}
21422156

2157+
pragma[nomagic]
2158+
private predicate storeStepFwd(
2159+
Node node1, Ap ap1, TypedContent tc, Node node2, Ap ap2, Configuration config
2160+
) {
2161+
fwdFlowStore(node1, ap1, tc, node2, _, _, config) and
2162+
ap2 = apCons(tc, ap1) and
2163+
fwdFlowRead(ap2, tc.getContent(), _, _, _, _, config)
2164+
}
2165+
21432166
private predicate readStepFwd(Node n1, Ap ap1, Content c, Node n2, Ap ap2, Configuration config) {
21442167
fwdFlowRead(ap1, c, n1, n2, _, _, config) and
21452168
fwdFlowConsCand(ap1, c, ap2, config)
@@ -2228,22 +2251,13 @@ private module Stage4 {
22282251
else returnAp = apNone()
22292252
}
22302253

2231-
pragma[nomagic]
2232-
private predicate storeFlowFwd(
2233-
Node node1, TypedContent tc, Node node2, Ap ap, Ap ap0, Configuration config
2234-
) {
2235-
storeCand2(node1, tc, node2, _, config) and
2236-
fwdFlowStore(_, ap, tc, node2, _, _, config) and
2237-
ap0 = push(tc, ap)
2238-
}
2239-
22402254
pragma[nomagic]
22412255
private predicate revFlowStore(
22422256
Ap ap0, Content c, Ap ap, Node node, TypedContent tc, Node mid, boolean toReturn,
22432257
ApOption returnAp, Configuration config
22442258
) {
22452259
revFlow(mid, toReturn, returnAp, ap0, config) and
2246-
storeFlowFwd(node, tc, mid, ap, ap0, config) and
2260+
storeStepFwd(node, ap, tc, mid, ap0, config) and
22472261
tc.getContent() = c
22482262
}
22492263

0 commit comments

Comments
 (0)