Skip to content

Commit 4662e71

Browse files
authored
Merge pull request github#1738 from aschackmull/java/dataflow-joinorder-fix
Java: Dataflow joinorder fix
2 parents 09b87d8 + 1938ac4 commit 4662e71

File tree

18 files changed

+468
-162
lines changed

18 files changed

+468
-162
lines changed

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ private predicate localFlowExit(Node node, Configuration config) {
834834
* This is the transitive closure of `[additional]localFlowStep` beginning
835835
* at `localFlowEntry`.
836836
*/
837+
pragma[nomagic]
837838
private predicate localFlowStepPlus(
838839
Node node1, Node node2, boolean preservesValue, Configuration config
839840
) {
@@ -1094,28 +1095,44 @@ private predicate flowCand0(Node node, boolean toReturn, AccessPathFront apf, Co
10941095
flowCandFwd(node, _, apf, config)
10951096
)
10961097
or
1097-
exists(Node mid, Content f, AccessPathFront apf0 |
1098-
store(node, f, mid) and
1099-
flowCand(mid, toReturn, apf0, config) and
1098+
exists(Content f, AccessPathFront apf0 |
1099+
flowCandStore(node, f, toReturn, apf0, config) and
11001100
apf0.headUsesContent(f) and
11011101
consCand(f, apf, unbind(config))
11021102
)
11031103
or
1104-
exists(Node mid, Content f, AccessPathFront apf0 |
1105-
read(node, f, mid) and
1106-
flowCand(mid, toReturn, apf0, config) and
1104+
exists(Content f, AccessPathFront apf0 |
1105+
flowCandRead(node, f, toReturn, apf0, config) and
11071106
consCandFwd(f, apf0, unbind(config)) and
11081107
apf.headUsesContent(f)
11091108
)
11101109
}
11111110

1111+
pragma[nomagic]
1112+
private predicate flowCandRead(
1113+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1114+
) {
1115+
exists(Node mid |
1116+
read(node, f, mid) and
1117+
flowCand(mid, toReturn, apf0, config)
1118+
)
1119+
}
1120+
1121+
private predicate flowCandStore(
1122+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1123+
) {
1124+
exists(Node mid |
1125+
store(node, f, mid) and
1126+
flowCand(mid, toReturn, apf0, config)
1127+
)
1128+
}
1129+
11121130
private predicate consCand(Content f, AccessPathFront apf, Configuration config) {
11131131
consCandFwd(f, apf, config) and
1114-
exists(Node mid, Node n, AccessPathFront apf0 |
1132+
exists(Node n, AccessPathFront apf0 |
11151133
flowCandFwd(n, _, apf0, config) and
11161134
apf0.headUsesContent(f) and
1117-
read(n, f, mid) and
1118-
flowCand(mid, _, apf, config)
1135+
flowCandRead(n, f, _, apf, config)
11191136
)
11201137
}
11211138

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ private predicate localFlowExit(Node node, Configuration config) {
834834
* This is the transitive closure of `[additional]localFlowStep` beginning
835835
* at `localFlowEntry`.
836836
*/
837+
pragma[nomagic]
837838
private predicate localFlowStepPlus(
838839
Node node1, Node node2, boolean preservesValue, Configuration config
839840
) {
@@ -1094,28 +1095,44 @@ private predicate flowCand0(Node node, boolean toReturn, AccessPathFront apf, Co
10941095
flowCandFwd(node, _, apf, config)
10951096
)
10961097
or
1097-
exists(Node mid, Content f, AccessPathFront apf0 |
1098-
store(node, f, mid) and
1099-
flowCand(mid, toReturn, apf0, config) and
1098+
exists(Content f, AccessPathFront apf0 |
1099+
flowCandStore(node, f, toReturn, apf0, config) and
11001100
apf0.headUsesContent(f) and
11011101
consCand(f, apf, unbind(config))
11021102
)
11031103
or
1104-
exists(Node mid, Content f, AccessPathFront apf0 |
1105-
read(node, f, mid) and
1106-
flowCand(mid, toReturn, apf0, config) and
1104+
exists(Content f, AccessPathFront apf0 |
1105+
flowCandRead(node, f, toReturn, apf0, config) and
11071106
consCandFwd(f, apf0, unbind(config)) and
11081107
apf.headUsesContent(f)
11091108
)
11101109
}
11111110

1111+
pragma[nomagic]
1112+
private predicate flowCandRead(
1113+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1114+
) {
1115+
exists(Node mid |
1116+
read(node, f, mid) and
1117+
flowCand(mid, toReturn, apf0, config)
1118+
)
1119+
}
1120+
1121+
private predicate flowCandStore(
1122+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1123+
) {
1124+
exists(Node mid |
1125+
store(node, f, mid) and
1126+
flowCand(mid, toReturn, apf0, config)
1127+
)
1128+
}
1129+
11121130
private predicate consCand(Content f, AccessPathFront apf, Configuration config) {
11131131
consCandFwd(f, apf, config) and
1114-
exists(Node mid, Node n, AccessPathFront apf0 |
1132+
exists(Node n, AccessPathFront apf0 |
11151133
flowCandFwd(n, _, apf0, config) and
11161134
apf0.headUsesContent(f) and
1117-
read(n, f, mid) and
1118-
flowCand(mid, _, apf, config)
1135+
flowCandRead(n, f, _, apf, config)
11191136
)
11201137
}
11211138

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ private predicate localFlowExit(Node node, Configuration config) {
834834
* This is the transitive closure of `[additional]localFlowStep` beginning
835835
* at `localFlowEntry`.
836836
*/
837+
pragma[nomagic]
837838
private predicate localFlowStepPlus(
838839
Node node1, Node node2, boolean preservesValue, Configuration config
839840
) {
@@ -1094,28 +1095,44 @@ private predicate flowCand0(Node node, boolean toReturn, AccessPathFront apf, Co
10941095
flowCandFwd(node, _, apf, config)
10951096
)
10961097
or
1097-
exists(Node mid, Content f, AccessPathFront apf0 |
1098-
store(node, f, mid) and
1099-
flowCand(mid, toReturn, apf0, config) and
1098+
exists(Content f, AccessPathFront apf0 |
1099+
flowCandStore(node, f, toReturn, apf0, config) and
11001100
apf0.headUsesContent(f) and
11011101
consCand(f, apf, unbind(config))
11021102
)
11031103
or
1104-
exists(Node mid, Content f, AccessPathFront apf0 |
1105-
read(node, f, mid) and
1106-
flowCand(mid, toReturn, apf0, config) and
1104+
exists(Content f, AccessPathFront apf0 |
1105+
flowCandRead(node, f, toReturn, apf0, config) and
11071106
consCandFwd(f, apf0, unbind(config)) and
11081107
apf.headUsesContent(f)
11091108
)
11101109
}
11111110

1111+
pragma[nomagic]
1112+
private predicate flowCandRead(
1113+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1114+
) {
1115+
exists(Node mid |
1116+
read(node, f, mid) and
1117+
flowCand(mid, toReturn, apf0, config)
1118+
)
1119+
}
1120+
1121+
private predicate flowCandStore(
1122+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1123+
) {
1124+
exists(Node mid |
1125+
store(node, f, mid) and
1126+
flowCand(mid, toReturn, apf0, config)
1127+
)
1128+
}
1129+
11121130
private predicate consCand(Content f, AccessPathFront apf, Configuration config) {
11131131
consCandFwd(f, apf, config) and
1114-
exists(Node mid, Node n, AccessPathFront apf0 |
1132+
exists(Node n, AccessPathFront apf0 |
11151133
flowCandFwd(n, _, apf0, config) and
11161134
apf0.headUsesContent(f) and
1117-
read(n, f, mid) and
1118-
flowCand(mid, _, apf, config)
1135+
flowCandRead(n, f, _, apf, config)
11191136
)
11201137
}
11211138

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ private predicate localFlowExit(Node node, Configuration config) {
834834
* This is the transitive closure of `[additional]localFlowStep` beginning
835835
* at `localFlowEntry`.
836836
*/
837+
pragma[nomagic]
837838
private predicate localFlowStepPlus(
838839
Node node1, Node node2, boolean preservesValue, Configuration config
839840
) {
@@ -1094,28 +1095,44 @@ private predicate flowCand0(Node node, boolean toReturn, AccessPathFront apf, Co
10941095
flowCandFwd(node, _, apf, config)
10951096
)
10961097
or
1097-
exists(Node mid, Content f, AccessPathFront apf0 |
1098-
store(node, f, mid) and
1099-
flowCand(mid, toReturn, apf0, config) and
1098+
exists(Content f, AccessPathFront apf0 |
1099+
flowCandStore(node, f, toReturn, apf0, config) and
11001100
apf0.headUsesContent(f) and
11011101
consCand(f, apf, unbind(config))
11021102
)
11031103
or
1104-
exists(Node mid, Content f, AccessPathFront apf0 |
1105-
read(node, f, mid) and
1106-
flowCand(mid, toReturn, apf0, config) and
1104+
exists(Content f, AccessPathFront apf0 |
1105+
flowCandRead(node, f, toReturn, apf0, config) and
11071106
consCandFwd(f, apf0, unbind(config)) and
11081107
apf.headUsesContent(f)
11091108
)
11101109
}
11111110

1111+
pragma[nomagic]
1112+
private predicate flowCandRead(
1113+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1114+
) {
1115+
exists(Node mid |
1116+
read(node, f, mid) and
1117+
flowCand(mid, toReturn, apf0, config)
1118+
)
1119+
}
1120+
1121+
private predicate flowCandStore(
1122+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1123+
) {
1124+
exists(Node mid |
1125+
store(node, f, mid) and
1126+
flowCand(mid, toReturn, apf0, config)
1127+
)
1128+
}
1129+
11121130
private predicate consCand(Content f, AccessPathFront apf, Configuration config) {
11131131
consCandFwd(f, apf, config) and
1114-
exists(Node mid, Node n, AccessPathFront apf0 |
1132+
exists(Node n, AccessPathFront apf0 |
11151133
flowCandFwd(n, _, apf0, config) and
11161134
apf0.headUsesContent(f) and
1117-
read(n, f, mid) and
1118-
flowCand(mid, _, apf, config)
1135+
flowCandRead(n, f, _, apf, config)
11191136
)
11201137
}
11211138

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ private predicate localFlowExit(Node node, Configuration config) {
834834
* This is the transitive closure of `[additional]localFlowStep` beginning
835835
* at `localFlowEntry`.
836836
*/
837+
pragma[nomagic]
837838
private predicate localFlowStepPlus(
838839
Node node1, Node node2, boolean preservesValue, Configuration config
839840
) {
@@ -1094,28 +1095,44 @@ private predicate flowCand0(Node node, boolean toReturn, AccessPathFront apf, Co
10941095
flowCandFwd(node, _, apf, config)
10951096
)
10961097
or
1097-
exists(Node mid, Content f, AccessPathFront apf0 |
1098-
store(node, f, mid) and
1099-
flowCand(mid, toReturn, apf0, config) and
1098+
exists(Content f, AccessPathFront apf0 |
1099+
flowCandStore(node, f, toReturn, apf0, config) and
11001100
apf0.headUsesContent(f) and
11011101
consCand(f, apf, unbind(config))
11021102
)
11031103
or
1104-
exists(Node mid, Content f, AccessPathFront apf0 |
1105-
read(node, f, mid) and
1106-
flowCand(mid, toReturn, apf0, config) and
1104+
exists(Content f, AccessPathFront apf0 |
1105+
flowCandRead(node, f, toReturn, apf0, config) and
11071106
consCandFwd(f, apf0, unbind(config)) and
11081107
apf.headUsesContent(f)
11091108
)
11101109
}
11111110

1111+
pragma[nomagic]
1112+
private predicate flowCandRead(
1113+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1114+
) {
1115+
exists(Node mid |
1116+
read(node, f, mid) and
1117+
flowCand(mid, toReturn, apf0, config)
1118+
)
1119+
}
1120+
1121+
private predicate flowCandStore(
1122+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1123+
) {
1124+
exists(Node mid |
1125+
store(node, f, mid) and
1126+
flowCand(mid, toReturn, apf0, config)
1127+
)
1128+
}
1129+
11121130
private predicate consCand(Content f, AccessPathFront apf, Configuration config) {
11131131
consCandFwd(f, apf, config) and
1114-
exists(Node mid, Node n, AccessPathFront apf0 |
1132+
exists(Node n, AccessPathFront apf0 |
11151133
flowCandFwd(n, _, apf0, config) and
11161134
apf0.headUsesContent(f) and
1117-
read(n, f, mid) and
1118-
flowCand(mid, _, apf, config)
1135+
flowCandRead(n, f, _, apf, config)
11191136
)
11201137
}
11211138

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,7 @@ private predicate localFlowExit(Node node, Configuration config) {
834834
* This is the transitive closure of `[additional]localFlowStep` beginning
835835
* at `localFlowEntry`.
836836
*/
837+
pragma[nomagic]
837838
private predicate localFlowStepPlus(
838839
Node node1, Node node2, boolean preservesValue, Configuration config
839840
) {
@@ -1094,28 +1095,44 @@ private predicate flowCand0(Node node, boolean toReturn, AccessPathFront apf, Co
10941095
flowCandFwd(node, _, apf, config)
10951096
)
10961097
or
1097-
exists(Node mid, Content f, AccessPathFront apf0 |
1098-
store(node, f, mid) and
1099-
flowCand(mid, toReturn, apf0, config) and
1098+
exists(Content f, AccessPathFront apf0 |
1099+
flowCandStore(node, f, toReturn, apf0, config) and
11001100
apf0.headUsesContent(f) and
11011101
consCand(f, apf, unbind(config))
11021102
)
11031103
or
1104-
exists(Node mid, Content f, AccessPathFront apf0 |
1105-
read(node, f, mid) and
1106-
flowCand(mid, toReturn, apf0, config) and
1104+
exists(Content f, AccessPathFront apf0 |
1105+
flowCandRead(node, f, toReturn, apf0, config) and
11071106
consCandFwd(f, apf0, unbind(config)) and
11081107
apf.headUsesContent(f)
11091108
)
11101109
}
11111110

1111+
pragma[nomagic]
1112+
private predicate flowCandRead(
1113+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1114+
) {
1115+
exists(Node mid |
1116+
read(node, f, mid) and
1117+
flowCand(mid, toReturn, apf0, config)
1118+
)
1119+
}
1120+
1121+
private predicate flowCandStore(
1122+
Node node, Content f, boolean toReturn, AccessPathFront apf0, Configuration config
1123+
) {
1124+
exists(Node mid |
1125+
store(node, f, mid) and
1126+
flowCand(mid, toReturn, apf0, config)
1127+
)
1128+
}
1129+
11121130
private predicate consCand(Content f, AccessPathFront apf, Configuration config) {
11131131
consCandFwd(f, apf, config) and
1114-
exists(Node mid, Node n, AccessPathFront apf0 |
1132+
exists(Node n, AccessPathFront apf0 |
11151133
flowCandFwd(n, _, apf0, config) and
11161134
apf0.headUsesContent(f) and
1117-
read(n, f, mid) and
1118-
flowCand(mid, _, apf, config)
1135+
flowCandRead(n, f, _, apf, config)
11191136
)
11201137
}
11211138

0 commit comments

Comments
 (0)