Skip to content

Commit 0febf5a

Browse files
authored
Merge pull request github#6094 from hvitved/dataflow/consistency-compiler-too-smart
Data flow: Workaround for too clever compiler in consistency queries
2 parents bcafe53 + cc383e0 commit 0febf5a

File tree

5 files changed

+35
-5
lines changed

5 files changed

+35
-5
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ module Consistency {
168168
msg = "ArgumentNode is missing PostUpdateNode."
169169
}
170170

171-
query predicate postWithInFlow(PostUpdateNode n, string msg) {
171+
// This predicate helps the compiler forget that in some languages
172+
// it is impossible for a `PostUpdateNode` to be the target of
173+
// `simpleLocalFlowStep`.
174+
private predicate isPostUpdateNode(Node n) { n instanceof PostUpdateNode or none() }
175+
176+
query predicate postWithInFlow(Node n, string msg) {
177+
isPostUpdateNode(n) and
172178
simpleLocalFlowStep(_, n) and
173179
msg = "PostUpdateNode should not be the target of local flow."
174180
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ module Consistency {
168168
msg = "ArgumentNode is missing PostUpdateNode."
169169
}
170170

171-
query predicate postWithInFlow(PostUpdateNode n, string msg) {
171+
// This predicate helps the compiler forget that in some languages
172+
// it is impossible for a `PostUpdateNode` to be the target of
173+
// `simpleLocalFlowStep`.
174+
private predicate isPostUpdateNode(Node n) { n instanceof PostUpdateNode or none() }
175+
176+
query predicate postWithInFlow(Node n, string msg) {
177+
isPostUpdateNode(n) and
172178
simpleLocalFlowStep(_, n) and
173179
msg = "PostUpdateNode should not be the target of local flow."
174180
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ module Consistency {
168168
msg = "ArgumentNode is missing PostUpdateNode."
169169
}
170170

171-
query predicate postWithInFlow(PostUpdateNode n, string msg) {
171+
// This predicate helps the compiler forget that in some languages
172+
// it is impossible for a `PostUpdateNode` to be the target of
173+
// `simpleLocalFlowStep`.
174+
private predicate isPostUpdateNode(Node n) { n instanceof PostUpdateNode or none() }
175+
176+
query predicate postWithInFlow(Node n, string msg) {
177+
isPostUpdateNode(n) and
172178
simpleLocalFlowStep(_, n) and
173179
msg = "PostUpdateNode should not be the target of local flow."
174180
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ module Consistency {
168168
msg = "ArgumentNode is missing PostUpdateNode."
169169
}
170170

171-
query predicate postWithInFlow(PostUpdateNode n, string msg) {
171+
// This predicate helps the compiler forget that in some languages
172+
// it is impossible for a `PostUpdateNode` to be the target of
173+
// `simpleLocalFlowStep`.
174+
private predicate isPostUpdateNode(Node n) { n instanceof PostUpdateNode or none() }
175+
176+
query predicate postWithInFlow(Node n, string msg) {
177+
isPostUpdateNode(n) and
172178
simpleLocalFlowStep(_, n) and
173179
msg = "PostUpdateNode should not be the target of local flow."
174180
}

python/ql/src/semmle/python/dataflow/new/internal/DataFlowImplConsistency.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ module Consistency {
168168
msg = "ArgumentNode is missing PostUpdateNode."
169169
}
170170

171-
query predicate postWithInFlow(PostUpdateNode n, string msg) {
171+
// This predicate helps the compiler forget that in some languages
172+
// it is impossible for a `PostUpdateNode` to be the target of
173+
// `simpleLocalFlowStep`.
174+
private predicate isPostUpdateNode(Node n) { n instanceof PostUpdateNode or none() }
175+
176+
query predicate postWithInFlow(Node n, string msg) {
177+
isPostUpdateNode(n) and
172178
simpleLocalFlowStep(_, n) and
173179
msg = "PostUpdateNode should not be the target of local flow."
174180
}

0 commit comments

Comments
 (0)