Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 96425a1

Browse files
committed
C++: Fix the IR dataflow configuration for the field flow tests
1 parent c87b516 commit 96425a1

5 files changed

Lines changed: 65 additions & 6 deletions

File tree

cpp/ql/test/library-tests/dataflow/fields/A.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class A
4040
cc.insert(nullptr);
4141
ct.insert(new C());
4242
sink(&cc); // no flow
43-
sink(&ct); // $ ast MISSING: ir
43+
sink(&ct); // $ ast ir=41:15
4444
}
4545
void f1()
4646
{

cpp/ql/test/library-tests/dataflow/fields/E.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void sink(char *b);
1818

1919
void handlePacket(packet *p)
2020
{
21-
sink(p->data.buffer); // $ ast MISSING: ir
21+
sink(p->data.buffer); // $ ast,ir
2222
}
2323

2424
void f(buf* b)
@@ -28,7 +28,7 @@ void f(buf* b)
2828
argument_source(raw);
2929
argument_source(b->buffer);
3030
argument_source(p.data.buffer);
31-
sink(raw); // $ ast MISSING: ir
32-
sink(b->buffer); // $ ast MISSING: ir
31+
sink(raw); // $ ast,ir
32+
sink(b->buffer); // $ ast,ir
3333
handlePacket(&p);
3434
}

cpp/ql/test/library-tests/dataflow/fields/IRConfiguration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class IRConf extends Configuration {
1818
override predicate isSink(Node sink) {
1919
exists(Call c |
2020
c.getTarget().hasName("sink") and
21-
c.getAnArgument() = [sink.asExpr(), sink.asConvertedExpr()]
21+
c.getAnArgument() = [sink.asExpr(), sink.asIndirectExpr(), sink.asConvertedExpr()]
2222
)
2323
}
2424

cpp/ql/test/library-tests/dataflow/fields/conflated.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void sink(void*);
1717
void pointer_without_allocation_2() {
1818
char *raw;
1919
argument_source(raw);
20-
sink(raw); // $ ast MISSING: ir
20+
sink(raw); // $ ast,ir
2121
}
2222

2323
A* makeA() {

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ edges
1111
| A.cpp:31:14:31:21 | call to B [c] | A.cpp:29:15:29:18 | VariableAddress indirection [c] |
1212
| A.cpp:31:20:31:20 | c | A.cpp:23:10:23:10 | c |
1313
| A.cpp:31:20:31:20 | c | A.cpp:31:14:31:21 | call to B [c] |
14+
| A.cpp:41:15:41:21 | new | A.cpp:43:10:43:12 | & ... indirection |
15+
| A.cpp:41:15:41:21 | new | A.cpp:43:10:43:12 | & ... indirection |
16+
| A.cpp:41:15:41:21 | new | A.cpp:43:10:43:12 | & ... indirection |
17+
| A.cpp:41:15:41:21 | new | A.cpp:43:10:43:12 | & ... indirection |
1418
| A.cpp:47:12:47:18 | new | A.cpp:48:20:48:20 | c |
1519
| A.cpp:48:12:48:18 | call to make indirection [c] | A.cpp:49:10:49:10 | b indirection [c] |
1620
| A.cpp:48:20:48:20 | c | A.cpp:29:23:29:23 | c |
@@ -259,6 +263,22 @@ edges
259263
| D.cpp:64:20:64:22 | box indirection [elem] | D.cpp:64:25:64:28 | elem |
260264
| D.cpp:64:20:64:22 | box indirection [elem] | D.cpp:64:25:64:28 | elem |
261265
| D.cpp:64:25:64:28 | elem | D.cpp:64:10:64:28 | elem |
266+
| E.cpp:19:27:19:27 | p indirection [data, buffer indirection] | E.cpp:21:10:21:10 | p indirection [data, buffer indirection] |
267+
| E.cpp:21:10:21:10 | p indirection [data, buffer indirection] | E.cpp:21:13:21:16 | data indirection [buffer indirection] |
268+
| E.cpp:21:13:21:16 | data indirection [buffer indirection] | E.cpp:21:18:21:23 | FieldAddress indirection |
269+
| E.cpp:21:13:21:16 | data indirection [buffer indirection] | E.cpp:21:18:21:23 | buffer indirection |
270+
| E.cpp:21:18:21:23 | FieldAddress indirection | E.cpp:21:18:21:23 | buffer indirection |
271+
| E.cpp:28:21:28:23 | argument_source output argument | E.cpp:31:10:31:12 | raw indirection |
272+
| E.cpp:28:21:28:23 | argument_source output argument | E.cpp:31:10:31:12 | raw indirection |
273+
| E.cpp:29:21:29:29 | argument_source output argument | E.cpp:29:24:29:29 | b indirection [post update] [buffer indirection] |
274+
| E.cpp:29:24:29:29 | b indirection [post update] [buffer indirection] | E.cpp:32:10:32:10 | b indirection [buffer indirection] |
275+
| E.cpp:30:21:30:33 | argument_source output argument | E.cpp:30:28:30:33 | data indirection [post update] [buffer indirection] |
276+
| E.cpp:30:23:30:26 | p indirection [post update] [data, buffer indirection] | E.cpp:33:18:33:19 | & ... indirection [data, buffer indirection] |
277+
| E.cpp:30:28:30:33 | data indirection [post update] [buffer indirection] | E.cpp:30:23:30:26 | p indirection [post update] [data, buffer indirection] |
278+
| E.cpp:32:10:32:10 | b indirection [buffer indirection] | E.cpp:32:13:32:18 | FieldAddress indirection |
279+
| E.cpp:32:10:32:10 | b indirection [buffer indirection] | E.cpp:32:13:32:18 | buffer indirection |
280+
| E.cpp:32:13:32:18 | FieldAddress indirection | E.cpp:32:13:32:18 | buffer indirection |
281+
| E.cpp:33:18:33:19 | & ... indirection [data, buffer indirection] | E.cpp:19:27:19:27 | p indirection [data, buffer indirection] |
262282
| aliasing.cpp:9:3:9:22 | Store | aliasing.cpp:9:6:9:7 | s indirection [post update] [m1] |
263283
| aliasing.cpp:9:6:9:7 | s indirection [post update] [m1] | aliasing.cpp:25:17:25:19 | pointerSetter output argument [m1] |
264284
| aliasing.cpp:9:11:9:20 | call to user_input | aliasing.cpp:9:3:9:22 | Store |
@@ -619,6 +639,9 @@ edges
619639
| conflated.cpp:11:9:11:10 | ra indirection [p indirection] | conflated.cpp:11:12:11:12 | p indirection |
620640
| conflated.cpp:11:12:11:12 | FieldAddress indirection | conflated.cpp:11:8:11:12 | * ... |
621641
| conflated.cpp:11:12:11:12 | p indirection | conflated.cpp:11:8:11:12 | * ... |
642+
| conflated.cpp:19:19:19:21 | argument_source output argument | conflated.cpp:20:8:20:10 | raw indirection |
643+
| conflated.cpp:19:19:19:21 | argument_source output argument | conflated.cpp:20:8:20:10 | raw indirection |
644+
| conflated.cpp:19:19:19:21 | argument_source output argument | conflated.cpp:20:8:20:10 | raw indirection |
622645
| conflated.cpp:29:3:29:22 | Store | conflated.cpp:29:7:29:7 | pa indirection [post update] [x] |
623646
| conflated.cpp:29:7:29:7 | pa indirection [post update] [x] | conflated.cpp:30:8:30:9 | pa indirection [x] |
624647
| conflated.cpp:29:11:29:20 | call to user_input | conflated.cpp:29:3:29:22 | Store |
@@ -883,6 +906,10 @@ nodes
883906
| A.cpp:29:23:29:23 | c | semmle.label | c |
884907
| A.cpp:31:14:31:21 | call to B [c] | semmle.label | call to B [c] |
885908
| A.cpp:31:20:31:20 | c | semmle.label | c |
909+
| A.cpp:41:15:41:21 | new | semmle.label | new |
910+
| A.cpp:41:15:41:21 | new | semmle.label | new |
911+
| A.cpp:43:10:43:12 | & ... indirection | semmle.label | & ... indirection |
912+
| A.cpp:43:10:43:12 | & ... indirection | semmle.label | & ... indirection |
886913
| A.cpp:47:12:47:18 | new | semmle.label | new |
887914
| A.cpp:48:12:48:18 | call to make indirection [c] | semmle.label | call to make indirection [c] |
888915
| A.cpp:48:20:48:20 | c | semmle.label | c |
@@ -1110,6 +1137,23 @@ nodes
11101137
| D.cpp:64:20:64:22 | box indirection [elem] | semmle.label | box indirection [elem] |
11111138
| D.cpp:64:25:64:28 | elem | semmle.label | elem |
11121139
| D.cpp:64:25:64:28 | elem | semmle.label | elem |
1140+
| E.cpp:19:27:19:27 | p indirection [data, buffer indirection] | semmle.label | p indirection [data, buffer indirection] |
1141+
| E.cpp:21:10:21:10 | p indirection [data, buffer indirection] | semmle.label | p indirection [data, buffer indirection] |
1142+
| E.cpp:21:13:21:16 | data indirection [buffer indirection] | semmle.label | data indirection [buffer indirection] |
1143+
| E.cpp:21:18:21:23 | FieldAddress indirection | semmle.label | FieldAddress indirection |
1144+
| E.cpp:21:18:21:23 | buffer indirection | semmle.label | buffer indirection |
1145+
| E.cpp:28:21:28:23 | argument_source output argument | semmle.label | argument_source output argument |
1146+
| E.cpp:29:21:29:29 | argument_source output argument | semmle.label | argument_source output argument |
1147+
| E.cpp:29:24:29:29 | b indirection [post update] [buffer indirection] | semmle.label | b indirection [post update] [buffer indirection] |
1148+
| E.cpp:30:21:30:33 | argument_source output argument | semmle.label | argument_source output argument |
1149+
| E.cpp:30:23:30:26 | p indirection [post update] [data, buffer indirection] | semmle.label | p indirection [post update] [data, buffer indirection] |
1150+
| E.cpp:30:28:30:33 | data indirection [post update] [buffer indirection] | semmle.label | data indirection [post update] [buffer indirection] |
1151+
| E.cpp:31:10:31:12 | raw indirection | semmle.label | raw indirection |
1152+
| E.cpp:31:10:31:12 | raw indirection | semmle.label | raw indirection |
1153+
| E.cpp:32:10:32:10 | b indirection [buffer indirection] | semmle.label | b indirection [buffer indirection] |
1154+
| E.cpp:32:13:32:18 | FieldAddress indirection | semmle.label | FieldAddress indirection |
1155+
| E.cpp:32:13:32:18 | buffer indirection | semmle.label | buffer indirection |
1156+
| E.cpp:33:18:33:19 | & ... indirection [data, buffer indirection] | semmle.label | & ... indirection [data, buffer indirection] |
11131157
| aliasing.cpp:9:3:9:22 | Store | semmle.label | Store |
11141158
| aliasing.cpp:9:6:9:7 | s indirection [post update] [m1] | semmle.label | s indirection [post update] [m1] |
11151159
| aliasing.cpp:9:11:9:20 | call to user_input | semmle.label | call to user_input |
@@ -1433,6 +1477,10 @@ nodes
14331477
| conflated.cpp:11:9:11:10 | ra indirection [p indirection] | semmle.label | ra indirection [p indirection] |
14341478
| conflated.cpp:11:12:11:12 | FieldAddress indirection | semmle.label | FieldAddress indirection |
14351479
| conflated.cpp:11:12:11:12 | p indirection | semmle.label | p indirection |
1480+
| conflated.cpp:19:19:19:21 | argument_source output argument | semmle.label | argument_source output argument |
1481+
| conflated.cpp:20:8:20:10 | raw indirection | semmle.label | raw indirection |
1482+
| conflated.cpp:20:8:20:10 | raw indirection | semmle.label | raw indirection |
1483+
| conflated.cpp:20:8:20:10 | raw indirection | semmle.label | raw indirection |
14361484
| conflated.cpp:29:3:29:22 | Store | semmle.label | Store |
14371485
| conflated.cpp:29:7:29:7 | pa indirection [post update] [x] | semmle.label | pa indirection [post update] [x] |
14381486
| conflated.cpp:29:11:29:20 | call to user_input | semmle.label | call to user_input |
@@ -1719,6 +1767,10 @@ subpaths
17191767
| simple.cpp:42:12:42:21 | call to user_input | simple.cpp:21:19:21:19 | b | simple.cpp:21:24:21:25 | this indirection [post update] [b_] | simple.cpp:42:5:42:5 | setB output argument [b_] |
17201768
| simple.cpp:84:14:84:20 | this indirection [f2, f1] | simple.cpp:78:9:78:15 | this indirection [f2, f1] | simple.cpp:78:9:78:15 | VariableAddress indirection | simple.cpp:84:14:84:20 | call to getf2f1 |
17211769
#select
1770+
| A.cpp:43:10:43:12 | & ... indirection | A.cpp:41:15:41:21 | new | A.cpp:43:10:43:12 | & ... indirection | & ... indirection flows from $@ | A.cpp:41:15:41:21 | new | new |
1771+
| A.cpp:43:10:43:12 | & ... indirection | A.cpp:41:15:41:21 | new | A.cpp:43:10:43:12 | & ... indirection | & ... indirection flows from $@ | A.cpp:41:15:41:21 | new | new |
1772+
| A.cpp:43:10:43:12 | & ... indirection | A.cpp:41:15:41:21 | new | A.cpp:43:10:43:12 | & ... indirection | & ... indirection flows from $@ | A.cpp:41:15:41:21 | new | new |
1773+
| A.cpp:43:10:43:12 | & ... indirection | A.cpp:41:15:41:21 | new | A.cpp:43:10:43:12 | & ... indirection | & ... indirection flows from $@ | A.cpp:41:15:41:21 | new | new |
17221774
| A.cpp:49:10:49:13 | c | A.cpp:47:12:47:18 | new | A.cpp:49:10:49:13 | c | c flows from $@ | A.cpp:47:12:47:18 | new | new |
17231775
| A.cpp:49:13:49:13 | c | A.cpp:47:12:47:18 | new | A.cpp:49:13:49:13 | c | c flows from $@ | A.cpp:47:12:47:18 | new | new |
17241776
| A.cpp:56:10:56:17 | call to get | A.cpp:55:12:55:19 | new | A.cpp:56:10:56:17 | call to get | call to get flows from $@ | A.cpp:55:12:55:19 | new | new |
@@ -1765,6 +1817,10 @@ subpaths
17651817
| D.cpp:22:10:22:33 | call to getElem | D.cpp:49:15:49:24 | new | D.cpp:22:10:22:33 | call to getElem | call to getElem flows from $@ | D.cpp:49:15:49:24 | new | new |
17661818
| D.cpp:64:10:64:28 | elem | D.cpp:56:15:56:24 | new | D.cpp:64:10:64:28 | elem | elem flows from $@ | D.cpp:56:15:56:24 | new | new |
17671819
| D.cpp:64:25:64:28 | elem | D.cpp:56:15:56:24 | new | D.cpp:64:25:64:28 | elem | elem flows from $@ | D.cpp:56:15:56:24 | new | new |
1820+
| E.cpp:21:18:21:23 | buffer indirection | E.cpp:30:21:30:33 | argument_source output argument | E.cpp:21:18:21:23 | buffer indirection | buffer indirection flows from $@ | E.cpp:30:21:30:33 | argument_source output argument | argument_source output argument |
1821+
| E.cpp:31:10:31:12 | raw indirection | E.cpp:28:21:28:23 | argument_source output argument | E.cpp:31:10:31:12 | raw indirection | raw indirection flows from $@ | E.cpp:28:21:28:23 | argument_source output argument | argument_source output argument |
1822+
| E.cpp:31:10:31:12 | raw indirection | E.cpp:28:21:28:23 | argument_source output argument | E.cpp:31:10:31:12 | raw indirection | raw indirection flows from $@ | E.cpp:28:21:28:23 | argument_source output argument | argument_source output argument |
1823+
| E.cpp:32:13:32:18 | buffer indirection | E.cpp:29:21:29:29 | argument_source output argument | E.cpp:32:13:32:18 | buffer indirection | buffer indirection flows from $@ | E.cpp:29:21:29:29 | argument_source output argument | argument_source output argument |
17681824
| aliasing.cpp:29:11:29:12 | m1 | aliasing.cpp:9:11:9:20 | call to user_input | aliasing.cpp:29:11:29:12 | m1 | m1 flows from $@ | aliasing.cpp:9:11:9:20 | call to user_input | call to user_input |
17691825
| aliasing.cpp:30:11:30:12 | m1 | aliasing.cpp:13:10:13:19 | call to user_input | aliasing.cpp:30:11:30:12 | m1 | m1 flows from $@ | aliasing.cpp:13:10:13:19 | call to user_input | call to user_input |
17701826
| aliasing.cpp:62:14:62:15 | m1 | aliasing.cpp:60:11:60:20 | call to user_input | aliasing.cpp:62:14:62:15 | m1 | m1 flows from $@ | aliasing.cpp:60:11:60:20 | call to user_input | call to user_input |
@@ -1813,6 +1869,9 @@ subpaths
18131869
| complex.cpp:43:18:43:18 | call to b | complex.cpp:54:19:54:28 | call to user_input | complex.cpp:43:18:43:18 | call to b | call to b flows from $@ | complex.cpp:54:19:54:28 | call to user_input | call to user_input |
18141870
| complex.cpp:43:18:43:18 | call to b | complex.cpp:56:19:56:28 | call to user_input | complex.cpp:43:18:43:18 | call to b | call to b flows from $@ | complex.cpp:56:19:56:28 | call to user_input | call to user_input |
18151871
| conflated.cpp:11:8:11:12 | * ... | conflated.cpp:10:11:10:20 | call to user_input | conflated.cpp:11:8:11:12 | * ... | * ... flows from $@ | conflated.cpp:10:11:10:20 | call to user_input | call to user_input |
1872+
| conflated.cpp:20:8:20:10 | raw indirection | conflated.cpp:19:19:19:21 | argument_source output argument | conflated.cpp:20:8:20:10 | raw indirection | raw indirection flows from $@ | conflated.cpp:19:19:19:21 | argument_source output argument | argument_source output argument |
1873+
| conflated.cpp:20:8:20:10 | raw indirection | conflated.cpp:19:19:19:21 | argument_source output argument | conflated.cpp:20:8:20:10 | raw indirection | raw indirection flows from $@ | conflated.cpp:19:19:19:21 | argument_source output argument | argument_source output argument |
1874+
| conflated.cpp:20:8:20:10 | raw indirection | conflated.cpp:19:19:19:21 | argument_source output argument | conflated.cpp:20:8:20:10 | raw indirection | raw indirection flows from $@ | conflated.cpp:19:19:19:21 | argument_source output argument | argument_source output argument |
18161875
| conflated.cpp:30:12:30:12 | x | conflated.cpp:29:11:29:20 | call to user_input | conflated.cpp:30:12:30:12 | x | x flows from $@ | conflated.cpp:29:11:29:20 | call to user_input | call to user_input |
18171876
| conflated.cpp:37:12:37:12 | x | conflated.cpp:36:11:36:20 | call to user_input | conflated.cpp:37:12:37:12 | x | x flows from $@ | conflated.cpp:36:11:36:20 | call to user_input | call to user_input |
18181877
| conflated.cpp:55:18:55:18 | y | conflated.cpp:54:17:54:26 | call to user_input | conflated.cpp:55:18:55:18 | y | y flows from $@ | conflated.cpp:54:17:54:26 | call to user_input | call to user_input |

0 commit comments

Comments
 (0)