Skip to content

Commit a2248cb

Browse files
committed
C++: Use getAUse in getIRRepresentationOfOperand
1 parent fadd23a commit a2248cb

File tree

9 files changed

+226
-14
lines changed

9 files changed

+226
-14
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/SsaInternalsCommon.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ private module Cached {
751751
*/
752752
cached
753753
Instruction getIRRepresentationOfOperand(Operand operand) {
754-
operand = unique( | | result.getAUse())
754+
operand = unique( | | getAUse(result))
755755
}
756756

757757
/**

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-119/OverrunWriteProductFlow.expected

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ edges
66
| test.cpp:18:10:18:15 | str indirection [post update] [string] | test.cpp:16:11:16:21 | mk_string_t indirection [string] |
77
| test.cpp:18:19:18:24 | call to malloc | test.cpp:18:5:18:30 | ... = ... |
88
| test.cpp:24:21:24:31 | call to mk_string_t indirection [string] | test.cpp:26:13:26:15 | str indirection [string] |
9+
| test.cpp:26:13:26:15 | str indirection [string] | test.cpp:26:18:26:23 | string |
910
| test.cpp:26:13:26:15 | str indirection [string] | test.cpp:26:18:26:23 | string indirection |
1011
| test.cpp:26:18:26:23 | string indirection | test.cpp:26:18:26:23 | string |
1112
| test.cpp:29:32:29:34 | str indirection [string] | test.cpp:30:13:30:15 | str indirection [string] |
13+
| test.cpp:30:13:30:15 | str indirection [string] | test.cpp:30:18:30:23 | string |
1214
| test.cpp:30:13:30:15 | str indirection [string] | test.cpp:30:18:30:23 | string indirection |
1315
| test.cpp:30:18:30:23 | string indirection | test.cpp:30:18:30:23 | string |
1416
| test.cpp:34:21:34:31 | call to mk_string_t indirection [string] | test.cpp:35:21:35:23 | str indirection [string] |
@@ -27,32 +29,46 @@ edges
2729
| test.cpp:39:21:39:31 | call to mk_string_t indirection [string] | test.cpp:76:17:76:19 | str indirection [string] |
2830
| test.cpp:39:21:39:31 | call to mk_string_t indirection [string] | test.cpp:80:17:80:19 | str indirection [string] |
2931
| test.cpp:39:21:39:31 | call to mk_string_t indirection [string] | test.cpp:84:17:84:19 | str indirection [string] |
32+
| test.cpp:41:13:41:15 | str indirection [string] | test.cpp:41:18:41:23 | string |
3033
| test.cpp:41:13:41:15 | str indirection [string] | test.cpp:41:18:41:23 | string indirection |
3134
| test.cpp:41:18:41:23 | string indirection | test.cpp:41:18:41:23 | string |
35+
| test.cpp:42:13:42:15 | str indirection [string] | test.cpp:42:18:42:23 | string |
3236
| test.cpp:42:13:42:15 | str indirection [string] | test.cpp:42:18:42:23 | string indirection |
3337
| test.cpp:42:18:42:23 | string indirection | test.cpp:42:18:42:23 | string |
38+
| test.cpp:44:13:44:15 | str indirection [string] | test.cpp:44:18:44:23 | string |
3439
| test.cpp:44:13:44:15 | str indirection [string] | test.cpp:44:18:44:23 | string indirection |
3540
| test.cpp:44:18:44:23 | string indirection | test.cpp:44:18:44:23 | string |
41+
| test.cpp:45:13:45:15 | str indirection [string] | test.cpp:45:18:45:23 | string |
3642
| test.cpp:45:13:45:15 | str indirection [string] | test.cpp:45:18:45:23 | string indirection |
3743
| test.cpp:45:18:45:23 | string indirection | test.cpp:45:18:45:23 | string |
44+
| test.cpp:48:17:48:19 | str indirection [string] | test.cpp:48:22:48:27 | string |
3845
| test.cpp:48:17:48:19 | str indirection [string] | test.cpp:48:22:48:27 | string indirection |
3946
| test.cpp:48:22:48:27 | string indirection | test.cpp:48:22:48:27 | string |
47+
| test.cpp:52:17:52:19 | str indirection [string] | test.cpp:52:22:52:27 | string |
4048
| test.cpp:52:17:52:19 | str indirection [string] | test.cpp:52:22:52:27 | string indirection |
4149
| test.cpp:52:22:52:27 | string indirection | test.cpp:52:22:52:27 | string |
50+
| test.cpp:56:17:56:19 | str indirection [string] | test.cpp:56:22:56:27 | string |
4251
| test.cpp:56:17:56:19 | str indirection [string] | test.cpp:56:22:56:27 | string indirection |
4352
| test.cpp:56:22:56:27 | string indirection | test.cpp:56:22:56:27 | string |
53+
| test.cpp:60:17:60:19 | str indirection [string] | test.cpp:60:22:60:27 | string |
4454
| test.cpp:60:17:60:19 | str indirection [string] | test.cpp:60:22:60:27 | string indirection |
4555
| test.cpp:60:22:60:27 | string indirection | test.cpp:60:22:60:27 | string |
56+
| test.cpp:64:17:64:19 | str indirection [string] | test.cpp:64:22:64:27 | string |
4657
| test.cpp:64:17:64:19 | str indirection [string] | test.cpp:64:22:64:27 | string indirection |
4758
| test.cpp:64:22:64:27 | string indirection | test.cpp:64:22:64:27 | string |
59+
| test.cpp:68:17:68:19 | str indirection [string] | test.cpp:68:22:68:27 | string |
4860
| test.cpp:68:17:68:19 | str indirection [string] | test.cpp:68:22:68:27 | string indirection |
4961
| test.cpp:68:22:68:27 | string indirection | test.cpp:68:22:68:27 | string |
62+
| test.cpp:72:17:72:19 | str indirection [string] | test.cpp:72:22:72:27 | string |
5063
| test.cpp:72:17:72:19 | str indirection [string] | test.cpp:72:22:72:27 | string indirection |
5164
| test.cpp:72:22:72:27 | string indirection | test.cpp:72:22:72:27 | string |
65+
| test.cpp:76:17:76:19 | str indirection [string] | test.cpp:76:22:76:27 | string |
5266
| test.cpp:76:17:76:19 | str indirection [string] | test.cpp:76:22:76:27 | string indirection |
5367
| test.cpp:76:22:76:27 | string indirection | test.cpp:76:22:76:27 | string |
68+
| test.cpp:80:17:80:19 | str indirection [string] | test.cpp:80:22:80:27 | string |
5469
| test.cpp:80:17:80:19 | str indirection [string] | test.cpp:80:22:80:27 | string indirection |
5570
| test.cpp:80:22:80:27 | string indirection | test.cpp:80:22:80:27 | string |
71+
| test.cpp:84:17:84:19 | str indirection [string] | test.cpp:84:22:84:27 | string |
5672
| test.cpp:84:17:84:19 | str indirection [string] | test.cpp:84:22:84:27 | string indirection |
5773
| test.cpp:84:22:84:27 | string indirection | test.cpp:84:22:84:27 | string |
5874
| test.cpp:88:11:88:30 | mk_string_t_plus_one indirection [string] | test.cpp:96:21:96:40 | call to mk_string_t_plus_one indirection [string] |
@@ -73,32 +89,46 @@ edges
7389
| test.cpp:96:21:96:40 | call to mk_string_t_plus_one indirection [string] | test.cpp:133:17:133:19 | str indirection [string] |
7490
| test.cpp:96:21:96:40 | call to mk_string_t_plus_one indirection [string] | test.cpp:137:17:137:19 | str indirection [string] |
7591
| test.cpp:96:21:96:40 | call to mk_string_t_plus_one indirection [string] | test.cpp:141:17:141:19 | str indirection [string] |
92+
| test.cpp:98:13:98:15 | str indirection [string] | test.cpp:98:18:98:23 | string |
7693
| test.cpp:98:13:98:15 | str indirection [string] | test.cpp:98:18:98:23 | string indirection |
7794
| test.cpp:98:18:98:23 | string indirection | test.cpp:98:18:98:23 | string |
95+
| test.cpp:99:13:99:15 | str indirection [string] | test.cpp:99:18:99:23 | string |
7896
| test.cpp:99:13:99:15 | str indirection [string] | test.cpp:99:18:99:23 | string indirection |
7997
| test.cpp:99:18:99:23 | string indirection | test.cpp:99:18:99:23 | string |
98+
| test.cpp:101:13:101:15 | str indirection [string] | test.cpp:101:18:101:23 | string |
8099
| test.cpp:101:13:101:15 | str indirection [string] | test.cpp:101:18:101:23 | string indirection |
81100
| test.cpp:101:18:101:23 | string indirection | test.cpp:101:18:101:23 | string |
101+
| test.cpp:102:13:102:15 | str indirection [string] | test.cpp:102:18:102:23 | string |
82102
| test.cpp:102:13:102:15 | str indirection [string] | test.cpp:102:18:102:23 | string indirection |
83103
| test.cpp:102:18:102:23 | string indirection | test.cpp:102:18:102:23 | string |
104+
| test.cpp:105:17:105:19 | str indirection [string] | test.cpp:105:22:105:27 | string |
84105
| test.cpp:105:17:105:19 | str indirection [string] | test.cpp:105:22:105:27 | string indirection |
85106
| test.cpp:105:22:105:27 | string indirection | test.cpp:105:22:105:27 | string |
107+
| test.cpp:109:17:109:19 | str indirection [string] | test.cpp:109:22:109:27 | string |
86108
| test.cpp:109:17:109:19 | str indirection [string] | test.cpp:109:22:109:27 | string indirection |
87109
| test.cpp:109:22:109:27 | string indirection | test.cpp:109:22:109:27 | string |
110+
| test.cpp:113:17:113:19 | str indirection [string] | test.cpp:113:22:113:27 | string |
88111
| test.cpp:113:17:113:19 | str indirection [string] | test.cpp:113:22:113:27 | string indirection |
89112
| test.cpp:113:22:113:27 | string indirection | test.cpp:113:22:113:27 | string |
113+
| test.cpp:117:17:117:19 | str indirection [string] | test.cpp:117:22:117:27 | string |
90114
| test.cpp:117:17:117:19 | str indirection [string] | test.cpp:117:22:117:27 | string indirection |
91115
| test.cpp:117:22:117:27 | string indirection | test.cpp:117:22:117:27 | string |
116+
| test.cpp:121:17:121:19 | str indirection [string] | test.cpp:121:22:121:27 | string |
92117
| test.cpp:121:17:121:19 | str indirection [string] | test.cpp:121:22:121:27 | string indirection |
93118
| test.cpp:121:22:121:27 | string indirection | test.cpp:121:22:121:27 | string |
119+
| test.cpp:125:17:125:19 | str indirection [string] | test.cpp:125:22:125:27 | string |
94120
| test.cpp:125:17:125:19 | str indirection [string] | test.cpp:125:22:125:27 | string indirection |
95121
| test.cpp:125:22:125:27 | string indirection | test.cpp:125:22:125:27 | string |
122+
| test.cpp:129:17:129:19 | str indirection [string] | test.cpp:129:22:129:27 | string |
96123
| test.cpp:129:17:129:19 | str indirection [string] | test.cpp:129:22:129:27 | string indirection |
97124
| test.cpp:129:22:129:27 | string indirection | test.cpp:129:22:129:27 | string |
125+
| test.cpp:133:17:133:19 | str indirection [string] | test.cpp:133:22:133:27 | string |
98126
| test.cpp:133:17:133:19 | str indirection [string] | test.cpp:133:22:133:27 | string indirection |
99127
| test.cpp:133:22:133:27 | string indirection | test.cpp:133:22:133:27 | string |
128+
| test.cpp:137:17:137:19 | str indirection [string] | test.cpp:137:22:137:27 | string |
100129
| test.cpp:137:17:137:19 | str indirection [string] | test.cpp:137:22:137:27 | string indirection |
101130
| test.cpp:137:22:137:27 | string indirection | test.cpp:137:22:137:27 | string |
131+
| test.cpp:141:17:141:19 | str indirection [string] | test.cpp:141:22:141:27 | string |
102132
| test.cpp:141:17:141:19 | str indirection [string] | test.cpp:141:22:141:27 | string indirection |
103133
| test.cpp:141:22:141:27 | string indirection | test.cpp:141:22:141:27 | string |
104134
| test.cpp:147:5:147:34 | ... = ... | test.cpp:147:10:147:15 | str indirection [post update] [string] |
@@ -122,42 +152,61 @@ edges
122152
| test.cpp:147:10:147:15 | str indirection [post update] [string] | test.cpp:203:17:203:19 | str indirection [string] |
123153
| test.cpp:147:10:147:15 | str indirection [post update] [string] | test.cpp:207:17:207:19 | str indirection [string] |
124154
| test.cpp:147:19:147:24 | call to malloc | test.cpp:147:5:147:34 | ... = ... |
155+
| test.cpp:150:13:150:15 | str indirection [string] | test.cpp:150:18:150:23 | string |
125156
| test.cpp:150:13:150:15 | str indirection [string] | test.cpp:150:18:150:23 | string indirection |
126157
| test.cpp:150:18:150:23 | string indirection | test.cpp:150:18:150:23 | string |
158+
| test.cpp:151:13:151:15 | str indirection [string] | test.cpp:151:18:151:23 | string |
127159
| test.cpp:151:13:151:15 | str indirection [string] | test.cpp:151:18:151:23 | string indirection |
128160
| test.cpp:151:18:151:23 | string indirection | test.cpp:151:18:151:23 | string |
161+
| test.cpp:152:13:152:15 | str indirection [string] | test.cpp:152:18:152:23 | string |
129162
| test.cpp:152:13:152:15 | str indirection [string] | test.cpp:152:18:152:23 | string indirection |
130163
| test.cpp:152:18:152:23 | string indirection | test.cpp:152:18:152:23 | string |
164+
| test.cpp:154:13:154:15 | str indirection [string] | test.cpp:154:18:154:23 | string |
131165
| test.cpp:154:13:154:15 | str indirection [string] | test.cpp:154:18:154:23 | string indirection |
132166
| test.cpp:154:18:154:23 | string indirection | test.cpp:154:18:154:23 | string |
167+
| test.cpp:155:13:155:15 | str indirection [string] | test.cpp:155:18:155:23 | string |
133168
| test.cpp:155:13:155:15 | str indirection [string] | test.cpp:155:18:155:23 | string indirection |
134169
| test.cpp:155:18:155:23 | string indirection | test.cpp:155:18:155:23 | string |
170+
| test.cpp:156:13:156:15 | str indirection [string] | test.cpp:156:18:156:23 | string |
135171
| test.cpp:156:13:156:15 | str indirection [string] | test.cpp:156:18:156:23 | string indirection |
136172
| test.cpp:156:18:156:23 | string indirection | test.cpp:156:18:156:23 | string |
173+
| test.cpp:159:17:159:19 | str indirection [string] | test.cpp:159:22:159:27 | string |
137174
| test.cpp:159:17:159:19 | str indirection [string] | test.cpp:159:22:159:27 | string indirection |
138175
| test.cpp:159:22:159:27 | string indirection | test.cpp:159:22:159:27 | string |
176+
| test.cpp:163:17:163:19 | str indirection [string] | test.cpp:163:22:163:27 | string |
139177
| test.cpp:163:17:163:19 | str indirection [string] | test.cpp:163:22:163:27 | string indirection |
140178
| test.cpp:163:22:163:27 | string indirection | test.cpp:163:22:163:27 | string |
179+
| test.cpp:167:17:167:19 | str indirection [string] | test.cpp:167:22:167:27 | string |
141180
| test.cpp:167:17:167:19 | str indirection [string] | test.cpp:167:22:167:27 | string indirection |
142181
| test.cpp:167:22:167:27 | string indirection | test.cpp:167:22:167:27 | string |
182+
| test.cpp:171:17:171:19 | str indirection [string] | test.cpp:171:22:171:27 | string |
143183
| test.cpp:171:17:171:19 | str indirection [string] | test.cpp:171:22:171:27 | string indirection |
144184
| test.cpp:171:22:171:27 | string indirection | test.cpp:171:22:171:27 | string |
185+
| test.cpp:175:17:175:19 | str indirection [string] | test.cpp:175:22:175:27 | string |
145186
| test.cpp:175:17:175:19 | str indirection [string] | test.cpp:175:22:175:27 | string indirection |
146187
| test.cpp:175:22:175:27 | string indirection | test.cpp:175:22:175:27 | string |
188+
| test.cpp:179:17:179:19 | str indirection [string] | test.cpp:179:22:179:27 | string |
147189
| test.cpp:179:17:179:19 | str indirection [string] | test.cpp:179:22:179:27 | string indirection |
148190
| test.cpp:179:22:179:27 | string indirection | test.cpp:179:22:179:27 | string |
191+
| test.cpp:183:17:183:19 | str indirection [string] | test.cpp:183:22:183:27 | string |
149192
| test.cpp:183:17:183:19 | str indirection [string] | test.cpp:183:22:183:27 | string indirection |
150193
| test.cpp:183:22:183:27 | string indirection | test.cpp:183:22:183:27 | string |
194+
| test.cpp:187:17:187:19 | str indirection [string] | test.cpp:187:22:187:27 | string |
151195
| test.cpp:187:17:187:19 | str indirection [string] | test.cpp:187:22:187:27 | string indirection |
152196
| test.cpp:187:22:187:27 | string indirection | test.cpp:187:22:187:27 | string |
197+
| test.cpp:191:17:191:19 | str indirection [string] | test.cpp:191:22:191:27 | string |
153198
| test.cpp:191:17:191:19 | str indirection [string] | test.cpp:191:22:191:27 | string indirection |
154199
| test.cpp:191:22:191:27 | string indirection | test.cpp:191:22:191:27 | string |
200+
| test.cpp:195:17:195:19 | str indirection [string] | test.cpp:195:22:195:27 | string |
155201
| test.cpp:195:17:195:19 | str indirection [string] | test.cpp:195:22:195:27 | string indirection |
156202
| test.cpp:195:22:195:27 | string indirection | test.cpp:195:22:195:27 | string |
203+
| test.cpp:199:17:199:19 | str indirection [string] | test.cpp:199:22:199:27 | string |
157204
| test.cpp:199:17:199:19 | str indirection [string] | test.cpp:199:22:199:27 | string indirection |
158205
| test.cpp:199:22:199:27 | string indirection | test.cpp:199:22:199:27 | string |
206+
| test.cpp:203:17:203:19 | str indirection [string] | test.cpp:203:22:203:27 | string |
159207
| test.cpp:203:17:203:19 | str indirection [string] | test.cpp:203:22:203:27 | string indirection |
160208
| test.cpp:203:22:203:27 | string indirection | test.cpp:203:22:203:27 | string |
209+
| test.cpp:207:17:207:19 | str indirection [string] | test.cpp:207:22:207:27 | string |
161210
| test.cpp:207:17:207:19 | str indirection [string] | test.cpp:207:22:207:27 | string indirection |
162211
| test.cpp:207:22:207:27 | string indirection | test.cpp:207:22:207:27 | string |
163212
nodes

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@ uniqueType
33
uniqueNodeLocation
44
missingLocation
55
uniqueNodeToString
6+
| dispatch.cpp:15:8:15:8 | Middle | Node should have one toString but has 2. |
7+
| dispatch.cpp:15:8:15:8 | Middle indirection | Node should have one toString but has 2. |
8+
| dispatch.cpp:15:8:15:8 | Middle indirection | Node should have one toString but has 2. |
9+
| dispatch.cpp:15:8:15:8 | this | Node should have one toString but has 2. |
10+
| dispatch.cpp:15:8:15:8 | this indirection | Node should have one toString but has 2. |
11+
| dispatch.cpp:15:8:15:8 | this indirection | Node should have one toString but has 2. |
12+
| dispatch.cpp:21:8:21:8 | Bottom | Node should have one toString but has 2. |
13+
| dispatch.cpp:21:8:21:8 | Bottom indirection | Node should have one toString but has 2. |
14+
| dispatch.cpp:21:8:21:8 | Bottom indirection | Node should have one toString but has 2. |
15+
| dispatch.cpp:21:8:21:8 | this | Node should have one toString but has 2. |
16+
| dispatch.cpp:21:8:21:8 | this indirection | Node should have one toString but has 2. |
17+
| dispatch.cpp:21:8:21:8 | this indirection | Node should have one toString but has 2. |
618
missingToString
719
parameterCallable
820
localFlowIsLocal

cpp/ql/test/library-tests/dataflow/dataflow-tests/dispatch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void DispatchThroughGlobal() {
5555
sink(globalBottom->isSource1()); // $ ir MISSING: ast
5656
sink(globalMiddle->isSource1()); // no flow
5757

58-
sink(readGlobalBottom()->isSource1()); // $ MISSING: ast,ir
58+
sink(readGlobalBottom()->isSource1()); // $ ir MISSING: ast
5959

6060
globalBottom = new Bottom();
6161
globalMiddle = new Middle();

0 commit comments

Comments
 (0)