Skip to content

Commit dc9cc20

Browse files
authored
Merge pull request #4161 from yoff/SharedDataflow_PostUpdateNodes
Approved by RasmusWL, aschackmull, hvitved, jbj
2 parents 9d6b2e7 + 750735c commit dc9cc20

File tree

18 files changed

+115
-68
lines changed

18 files changed

+115
-68
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,18 @@ module Consistency {
123123
n.getEnclosingCallable() != call.getEnclosingCallable()
124124
}
125125

126+
// This predicate helps the compiler forget that in some languages
127+
// it is impossible for a result of `getPreUpdateNode` to be an
128+
// instance of `PostUpdateNode`.
129+
private Node getPre(PostUpdateNode n) {
130+
result = n.getPreUpdateNode()
131+
or
132+
none()
133+
}
134+
126135
query predicate postIsNotPre(PostUpdateNode n, string msg) {
127-
n.getPreUpdateNode() = n and msg = "PostUpdateNode should not equal its pre-update node."
136+
getPre(n) = n and
137+
msg = "PostUpdateNode should not equal its pre-update node."
128138
}
129139

130140
query predicate postHasUniquePre(PostUpdateNode n, string msg) {
@@ -152,12 +162,6 @@ module Consistency {
152162
msg = "Origin of readStep is missing a PostUpdateNode."
153163
}
154164

155-
query predicate storeIsPostUpdate(Node n, string msg) {
156-
storeStep(_, _, n) and
157-
not n instanceof PostUpdateNode and
158-
msg = "Store targets should be PostUpdateNodes."
159-
}
160-
161165
query predicate argHasPostUpdate(ArgumentNode n, string msg) {
162166
not hasPost(n) and
163167
not isImmutableOrUnobservable(n) and

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,18 @@ module Consistency {
123123
n.getEnclosingCallable() != call.getEnclosingCallable()
124124
}
125125

126+
// This predicate helps the compiler forget that in some languages
127+
// it is impossible for a result of `getPreUpdateNode` to be an
128+
// instance of `PostUpdateNode`.
129+
private Node getPre(PostUpdateNode n) {
130+
result = n.getPreUpdateNode()
131+
or
132+
none()
133+
}
134+
126135
query predicate postIsNotPre(PostUpdateNode n, string msg) {
127-
n.getPreUpdateNode() = n and msg = "PostUpdateNode should not equal its pre-update node."
136+
getPre(n) = n and
137+
msg = "PostUpdateNode should not equal its pre-update node."
128138
}
129139

130140
query predicate postHasUniquePre(PostUpdateNode n, string msg) {
@@ -152,12 +162,6 @@ module Consistency {
152162
msg = "Origin of readStep is missing a PostUpdateNode."
153163
}
154164

155-
query predicate storeIsPostUpdate(Node n, string msg) {
156-
storeStep(_, _, n) and
157-
not n instanceof PostUpdateNode and
158-
msg = "Store targets should be PostUpdateNodes."
159-
}
160-
161165
query predicate argHasPostUpdate(ArgumentNode n, string msg) {
162166
not hasPost(n) and
163167
not isImmutableOrUnobservable(n) and

cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ postHasUniquePre
1414
uniquePostUpdate
1515
postIsInSameCallable
1616
reverseRead
17-
storeIsPostUpdate
1817
argHasPostUpdate
1918
| lambdas.cpp:18:7:18:7 | a | ArgumentNode is missing PostUpdateNode. |
2019
| lambdas.cpp:25:2:25:2 | b | ArgumentNode is missing PostUpdateNode. |

cpp/ql/test/library-tests/dataflow/dataflow-tests/dataflow-ir-consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,4 @@ postHasUniquePre
2929
uniquePostUpdate
3030
postIsInSameCallable
3131
reverseRead
32-
storeIsPostUpdate
3332
argHasPostUpdate

cpp/ql/test/library-tests/dataflow/fields/dataflow-consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ postHasUniquePre
1616
uniquePostUpdate
1717
postIsInSameCallable
1818
reverseRead
19-
storeIsPostUpdate
2019
argHasPostUpdate
2120
| A.cpp:41:15:41:21 | new | ArgumentNode is missing PostUpdateNode. |
2221
| A.cpp:55:12:55:19 | new | ArgumentNode is missing PostUpdateNode. |

cpp/ql/test/library-tests/dataflow/fields/dataflow-ir-consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ postHasUniquePre
2323
uniquePostUpdate
2424
postIsInSameCallable
2525
reverseRead
26-
storeIsPostUpdate
2726
argHasPostUpdate

cpp/ql/test/library-tests/syntax-zoo/dataflow-consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ postHasUniquePre
6060
uniquePostUpdate
6161
postIsInSameCallable
6262
reverseRead
63-
storeIsPostUpdate
6463
argHasPostUpdate
6564
| builtin.cpp:15:31:15:35 | * ... | ArgumentNode is missing PostUpdateNode. |
6665
| conditional_destructors.cpp:30:9:30:13 | call to C1 | ArgumentNode is missing PostUpdateNode. |

cpp/ql/test/library-tests/syntax-zoo/dataflow-ir-consistency.expected

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,5 +1473,4 @@ postHasUniquePre
14731473
uniquePostUpdate
14741474
postIsInSameCallable
14751475
reverseRead
1476-
storeIsPostUpdate
14771476
argHasPostUpdate

csharp/ql/src/semmle/code/csharp/dataflow/internal/DataFlowImplConsistency.qll

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,18 @@ module Consistency {
123123
n.getEnclosingCallable() != call.getEnclosingCallable()
124124
}
125125

126+
// This predicate helps the compiler forget that in some languages
127+
// it is impossible for a result of `getPreUpdateNode` to be an
128+
// instance of `PostUpdateNode`.
129+
private Node getPre(PostUpdateNode n) {
130+
result = n.getPreUpdateNode()
131+
or
132+
none()
133+
}
134+
126135
query predicate postIsNotPre(PostUpdateNode n, string msg) {
127-
n.getPreUpdateNode() = n and msg = "PostUpdateNode should not equal its pre-update node."
136+
getPre(n) = n and
137+
msg = "PostUpdateNode should not equal its pre-update node."
128138
}
129139

130140
query predicate postHasUniquePre(PostUpdateNode n, string msg) {
@@ -152,12 +162,6 @@ module Consistency {
152162
msg = "Origin of readStep is missing a PostUpdateNode."
153163
}
154164

155-
query predicate storeIsPostUpdate(Node n, string msg) {
156-
storeStep(_, _, n) and
157-
not n instanceof PostUpdateNode and
158-
msg = "Store targets should be PostUpdateNodes."
159-
}
160-
161165
query predicate argHasPostUpdate(ArgumentNode n, string msg) {
162166
not hasPost(n) and
163167
not isImmutableOrUnobservable(n) and

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,18 @@ module Consistency {
123123
n.getEnclosingCallable() != call.getEnclosingCallable()
124124
}
125125

126+
// This predicate helps the compiler forget that in some languages
127+
// it is impossible for a result of `getPreUpdateNode` to be an
128+
// instance of `PostUpdateNode`.
129+
private Node getPre(PostUpdateNode n) {
130+
result = n.getPreUpdateNode()
131+
or
132+
none()
133+
}
134+
126135
query predicate postIsNotPre(PostUpdateNode n, string msg) {
127-
n.getPreUpdateNode() = n and msg = "PostUpdateNode should not equal its pre-update node."
136+
getPre(n) = n and
137+
msg = "PostUpdateNode should not equal its pre-update node."
128138
}
129139

130140
query predicate postHasUniquePre(PostUpdateNode n, string msg) {
@@ -152,12 +162,6 @@ module Consistency {
152162
msg = "Origin of readStep is missing a PostUpdateNode."
153163
}
154164

155-
query predicate storeIsPostUpdate(Node n, string msg) {
156-
storeStep(_, _, n) and
157-
not n instanceof PostUpdateNode and
158-
msg = "Store targets should be PostUpdateNodes."
159-
}
160-
161165
query predicate argHasPostUpdate(ArgumentNode n, string msg) {
162166
not hasPost(n) and
163167
not isImmutableOrUnobservable(n) and

0 commit comments

Comments
 (0)