Skip to content

Commit 725194a

Browse files
authored
Merge pull request #4447 from aschackmull/dataflow/postupdate-flow-consistency
Dataflow: Introduce consistency check for flow targeting PostUpdateNodes
2 parents c8cacb9 + 091e3a2 commit 725194a

File tree

12 files changed

+521
-0
lines changed

12 files changed

+521
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,9 @@ module Consistency {
167167
not isImmutableOrUnobservable(n) and
168168
msg = "ArgumentNode is missing PostUpdateNode."
169169
}
170+
171+
query predicate postWithInFlow(PostUpdateNode n, string msg) {
172+
simpleLocalFlowStep(_, n) and
173+
msg = "PostUpdateNode should not be the target of local flow."
174+
}
170175
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,9 @@ module Consistency {
167167
not isImmutableOrUnobservable(n) and
168168
msg = "ArgumentNode is missing PostUpdateNode."
169169
}
170+
171+
query predicate postWithInFlow(PostUpdateNode n, string msg) {
172+
simpleLocalFlowStep(_, n) and
173+
msg = "PostUpdateNode should not be the target of local flow."
174+
}
170175
}

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

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,69 @@ argHasPostUpdate
2121
| lambdas.cpp:38:2:38:2 | d | ArgumentNode is missing PostUpdateNode. |
2222
| lambdas.cpp:45:2:45:2 | e | ArgumentNode is missing PostUpdateNode. |
2323
| test.cpp:67:29:67:35 | source1 | ArgumentNode is missing PostUpdateNode. |
24+
postWithInFlow
25+
| BarrierGuard.cpp:49:6:49:6 | x [post update] | PostUpdateNode should not be the target of local flow. |
26+
| BarrierGuard.cpp:60:7:60:7 | x [post update] | PostUpdateNode should not be the target of local flow. |
27+
| clang.cpp:22:9:22:20 | sourceArray1 [inner post update] | PostUpdateNode should not be the target of local flow. |
28+
| clang.cpp:28:22:28:23 | m1 [post update] | PostUpdateNode should not be the target of local flow. |
29+
| clang.cpp:50:3:50:12 | stackArray [inner post update] | PostUpdateNode should not be the target of local flow. |
30+
| clang.cpp:50:3:50:15 | access to array [post update] | PostUpdateNode should not be the target of local flow. |
31+
| dispatch.cpp:60:3:60:14 | globalBottom [post update] | PostUpdateNode should not be the target of local flow. |
32+
| dispatch.cpp:61:3:61:14 | globalMiddle [post update] | PostUpdateNode should not be the target of local flow. |
33+
| dispatch.cpp:78:24:78:37 | call to allocateBottom [inner post update] | PostUpdateNode should not be the target of local flow. |
34+
| dispatch.cpp:148:5:148:5 | f [post update] | PostUpdateNode should not be the target of local flow. |
35+
| dispatch.cpp:168:8:168:8 | f [post update] | PostUpdateNode should not be the target of local flow. |
36+
| example.c:24:9:24:9 | x [post update] | PostUpdateNode should not be the target of local flow. |
37+
| example.c:24:20:24:20 | y [post update] | PostUpdateNode should not be the target of local flow. |
38+
| example.c:26:9:26:9 | x [post update] | PostUpdateNode should not be the target of local flow. |
39+
| example.c:26:19:26:24 | coords [inner post update] | PostUpdateNode should not be the target of local flow. |
40+
| example.c:28:23:28:25 | pos [inner post update] | PostUpdateNode should not be the target of local flow. |
41+
| globals.cpp:13:5:13:19 | flowTestGlobal1 [post update] | PostUpdateNode should not be the target of local flow. |
42+
| globals.cpp:23:5:23:19 | flowTestGlobal2 [post update] | PostUpdateNode should not be the target of local flow. |
43+
| lambdas.cpp:23:3:23:14 | v [post update] | PostUpdateNode should not be the target of local flow. |
44+
| lambdas.cpp:43:3:43:3 | c [post update] | PostUpdateNode should not be the target of local flow. |
45+
| ref.cpp:11:5:11:7 | lhs [post update] | PostUpdateNode should not be the target of local flow. |
46+
| ref.cpp:11:5:11:7 | lhs [post update] | PostUpdateNode should not be the target of local flow. |
47+
| ref.cpp:20:5:20:7 | lhs [post update] | PostUpdateNode should not be the target of local flow. |
48+
| ref.cpp:22:7:22:9 | lhs [post update] | PostUpdateNode should not be the target of local flow. |
49+
| ref.cpp:24:7:24:9 | lhs [post update] | PostUpdateNode should not be the target of local flow. |
50+
| ref.cpp:29:5:29:7 | out [post update] | PostUpdateNode should not be the target of local flow. |
51+
| ref.cpp:31:7:31:9 | out [post update] | PostUpdateNode should not be the target of local flow. |
52+
| ref.cpp:39:7:39:9 | out [post update] | PostUpdateNode should not be the target of local flow. |
53+
| ref.cpp:44:5:44:7 | out [post update] | PostUpdateNode should not be the target of local flow. |
54+
| ref.cpp:46:7:46:9 | out [post update] | PostUpdateNode should not be the target of local flow. |
55+
| ref.cpp:48:7:48:9 | out [post update] | PostUpdateNode should not be the target of local flow. |
56+
| ref.cpp:75:9:75:11 | val [post update] | PostUpdateNode should not be the target of local flow. |
57+
| ref.cpp:83:9:83:11 | val [post update] | PostUpdateNode should not be the target of local flow. |
58+
| ref.cpp:87:11:87:13 | val [post update] | PostUpdateNode should not be the target of local flow. |
59+
| ref.cpp:89:11:89:13 | val [post update] | PostUpdateNode should not be the target of local flow. |
60+
| ref.cpp:94:9:94:11 | val [post update] | PostUpdateNode should not be the target of local flow. |
61+
| ref.cpp:96:11:96:13 | val [post update] | PostUpdateNode should not be the target of local flow. |
62+
| ref.cpp:104:11:104:13 | val [post update] | PostUpdateNode should not be the target of local flow. |
63+
| ref.cpp:109:9:109:11 | val [post update] | PostUpdateNode should not be the target of local flow. |
64+
| ref.cpp:113:11:113:13 | val [post update] | PostUpdateNode should not be the target of local flow. |
65+
| ref.cpp:115:11:115:13 | val [post update] | PostUpdateNode should not be the target of local flow. |
66+
| test.cpp:91:3:91:9 | source1 [post update] | PostUpdateNode should not be the target of local flow. |
67+
| test.cpp:115:3:115:6 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
68+
| test.cpp:115:4:115:6 | out [inner post update] | PostUpdateNode should not be the target of local flow. |
69+
| test.cpp:120:3:120:6 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
70+
| test.cpp:120:4:120:6 | out [inner post update] | PostUpdateNode should not be the target of local flow. |
71+
| test.cpp:125:3:125:6 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
72+
| test.cpp:125:4:125:6 | out [inner post update] | PostUpdateNode should not be the target of local flow. |
73+
| test.cpp:333:5:333:13 | globalVar [post update] | PostUpdateNode should not be the target of local flow. |
74+
| test.cpp:347:5:347:13 | globalVar [post update] | PostUpdateNode should not be the target of local flow. |
75+
| test.cpp:359:5:359:9 | field [post update] | PostUpdateNode should not be the target of local flow. |
76+
| test.cpp:373:5:373:9 | field [post update] | PostUpdateNode should not be the target of local flow. |
77+
| test.cpp:384:10:384:13 | ref arg & ... | PostUpdateNode should not be the target of local flow. |
78+
| test.cpp:384:11:384:13 | tmp [inner post update] | PostUpdateNode should not be the target of local flow. |
79+
| test.cpp:391:10:391:13 | ref arg & ... | PostUpdateNode should not be the target of local flow. |
80+
| test.cpp:391:11:391:13 | tmp [inner post update] | PostUpdateNode should not be the target of local flow. |
81+
| test.cpp:400:10:400:13 | ref arg & ... | PostUpdateNode should not be the target of local flow. |
82+
| test.cpp:400:11:400:13 | tmp [inner post update] | PostUpdateNode should not be the target of local flow. |
83+
| test.cpp:407:10:407:13 | ref arg & ... | PostUpdateNode should not be the target of local flow. |
84+
| test.cpp:407:11:407:13 | tmp [inner post update] | PostUpdateNode should not be the target of local flow. |
85+
| test.cpp:423:21:423:25 | local [inner post update] | PostUpdateNode should not be the target of local flow. |
86+
| test.cpp:436:19:436:23 | local [inner post update] | PostUpdateNode should not be the target of local flow. |
87+
| test.cpp:465:3:465:4 | * ... [post update] | PostUpdateNode should not be the target of local flow. |
88+
| test.cpp:465:4:465:4 | p [inner post update] | PostUpdateNode should not be the target of local flow. |
89+
| test.cpp:470:22:470:22 | x [inner post update] | PostUpdateNode should not be the target of local flow. |

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,56 @@ uniquePostUpdate
3030
postIsInSameCallable
3131
reverseRead
3232
argHasPostUpdate
33+
postWithInFlow
34+
| BarrierGuard.cpp:49:3:49:17 | Chi | PostUpdateNode should not be the target of local flow. |
35+
| BarrierGuard.cpp:60:3:60:18 | Chi | PostUpdateNode should not be the target of local flow. |
36+
| clang.cpp:28:3:28:34 | Chi | PostUpdateNode should not be the target of local flow. |
37+
| clang.cpp:34:22:34:27 | Chi | PostUpdateNode should not be the target of local flow. |
38+
| clang.cpp:34:32:34:37 | Chi | PostUpdateNode should not be the target of local flow. |
39+
| clang.cpp:39:32:39:37 | Chi | PostUpdateNode should not be the target of local flow. |
40+
| clang.cpp:39:42:39:47 | Chi | PostUpdateNode should not be the target of local flow. |
41+
| clang.cpp:43:35:43:40 | Chi | PostUpdateNode should not be the target of local flow. |
42+
| clang.cpp:43:51:43:51 | Chi | PostUpdateNode should not be the target of local flow. |
43+
| clang.cpp:49:25:49:30 | Chi | PostUpdateNode should not be the target of local flow. |
44+
| clang.cpp:49:35:49:40 | Chi | PostUpdateNode should not be the target of local flow. |
45+
| clang.cpp:50:3:50:26 | Chi | PostUpdateNode should not be the target of local flow. |
46+
| example.c:17:19:17:22 | Chi | PostUpdateNode should not be the target of local flow. |
47+
| example.c:17:21:17:21 | Chi | PostUpdateNode should not be the target of local flow. |
48+
| example.c:24:2:24:30 | Chi | PostUpdateNode should not be the target of local flow. |
49+
| example.c:24:13:24:30 | Chi | PostUpdateNode should not be the target of local flow. |
50+
| example.c:26:2:26:25 | Chi | PostUpdateNode should not be the target of local flow. |
51+
| file://:0:0:0:0 | Chi | PostUpdateNode should not be the target of local flow. |
52+
| file://:0:0:0:0 | Chi | PostUpdateNode should not be the target of local flow. |
53+
| file://:0:0:0:0 | Chi | PostUpdateNode should not be the target of local flow. |
54+
| lambdas.cpp:13:12:13:12 | Chi | PostUpdateNode should not be the target of local flow. |
55+
| lambdas.cpp:13:15:13:15 | Chi | PostUpdateNode should not be the target of local flow. |
56+
| lambdas.cpp:28:10:31:2 | Chi | PostUpdateNode should not be the target of local flow. |
57+
| lambdas.cpp:28:10:31:2 | Chi | PostUpdateNode should not be the target of local flow. |
58+
| lambdas.cpp:43:3:43:14 | Chi | PostUpdateNode should not be the target of local flow. |
59+
| ref.cpp:11:5:11:13 | Chi | PostUpdateNode should not be the target of local flow. |
60+
| ref.cpp:20:5:20:13 | Chi | PostUpdateNode should not be the target of local flow. |
61+
| ref.cpp:22:7:22:13 | Chi | PostUpdateNode should not be the target of local flow. |
62+
| ref.cpp:24:7:24:13 | Chi | PostUpdateNode should not be the target of local flow. |
63+
| ref.cpp:29:5:29:18 | Chi | PostUpdateNode should not be the target of local flow. |
64+
| ref.cpp:31:7:31:13 | Chi | PostUpdateNode should not be the target of local flow. |
65+
| ref.cpp:39:7:39:13 | Chi | PostUpdateNode should not be the target of local flow. |
66+
| ref.cpp:44:5:44:18 | Chi | PostUpdateNode should not be the target of local flow. |
67+
| ref.cpp:46:7:46:13 | Chi | PostUpdateNode should not be the target of local flow. |
68+
| ref.cpp:48:7:48:13 | Chi | PostUpdateNode should not be the target of local flow. |
69+
| ref.cpp:75:5:75:17 | Chi | PostUpdateNode should not be the target of local flow. |
70+
| ref.cpp:83:5:83:17 | Chi | PostUpdateNode should not be the target of local flow. |
71+
| ref.cpp:87:7:87:17 | Chi | PostUpdateNode should not be the target of local flow. |
72+
| ref.cpp:89:7:89:17 | Chi | PostUpdateNode should not be the target of local flow. |
73+
| ref.cpp:94:5:94:22 | Chi | PostUpdateNode should not be the target of local flow. |
74+
| ref.cpp:96:7:96:17 | Chi | PostUpdateNode should not be the target of local flow. |
75+
| ref.cpp:104:7:104:17 | Chi | PostUpdateNode should not be the target of local flow. |
76+
| ref.cpp:109:5:109:22 | Chi | PostUpdateNode should not be the target of local flow. |
77+
| ref.cpp:113:7:113:17 | Chi | PostUpdateNode should not be the target of local flow. |
78+
| ref.cpp:115:7:115:17 | Chi | PostUpdateNode should not be the target of local flow. |
79+
| test.cpp:91:3:91:18 | Chi | PostUpdateNode should not be the target of local flow. |
80+
| test.cpp:115:3:115:17 | Chi | PostUpdateNode should not be the target of local flow. |
81+
| test.cpp:120:3:120:10 | Chi | PostUpdateNode should not be the target of local flow. |
82+
| test.cpp:125:3:125:11 | Chi | PostUpdateNode should not be the target of local flow. |
83+
| test.cpp:359:5:359:20 | Chi | PostUpdateNode should not be the target of local flow. |
84+
| test.cpp:373:5:373:20 | Chi | PostUpdateNode should not be the target of local flow. |
85+
| test.cpp:465:3:465:15 | Chi | PostUpdateNode should not be the target of local flow. |

0 commit comments

Comments
 (0)