Skip to content

Commit f02feac

Browse files
committed
C++: Add flow from github#3220
1 parent 209e084 commit f02feac

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,9 @@ private predicate simpleInstructionLocalFlowStep(Instruction iFrom, Instruction
430430
// for now.
431431
iTo.getAnOperand().(ChiTotalOperand).getDef() = iFrom
432432
or
433+
iTo.getAnOperand().(ChiPartialOperand).getDef() = iFrom.(WriteSideEffectInstruction) and
434+
not iTo.isResultConflated()
435+
or
433436
exists(ChiInstruction chi | iFrom = chi |
434437
not chi.isResultConflated() and
435438
iTo.(LoadInstruction).getSourceValueOperand().getAnyDef() = chi

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
edges
2+
| A.cpp:142:7:142:20 | Chi [c] | A.cpp:151:18:151:18 | D output argument [c] |
3+
| A.cpp:142:7:142:20 | Store | A.cpp:142:7:142:20 | Chi [c] |
4+
| A.cpp:142:14:142:20 | new | A.cpp:142:7:142:20 | Store |
5+
| A.cpp:151:18:151:18 | Chi [c] | A.cpp:154:13:154:13 | c |
6+
| A.cpp:151:18:151:18 | Chi [c] | A.cpp:154:13:154:13 | c |
7+
| A.cpp:151:18:151:18 | D output argument [c] | A.cpp:151:18:151:18 | Chi [c] |
8+
| A.cpp:154:13:154:13 | c | A.cpp:154:10:154:13 | (void *)... |
9+
| aliasing.cpp:9:3:9:22 | Chi [m1] | aliasing.cpp:25:17:25:19 | pointerSetter output argument [m1] |
10+
| aliasing.cpp:9:3:9:22 | Store | aliasing.cpp:9:3:9:22 | Chi [m1] |
11+
| aliasing.cpp:9:11:9:20 | call to user_input | aliasing.cpp:9:3:9:22 | Store |
12+
| aliasing.cpp:13:3:13:21 | Chi [m1] | aliasing.cpp:26:19:26:20 | referenceSetter output argument [m1] |
13+
| aliasing.cpp:13:3:13:21 | Store | aliasing.cpp:13:3:13:21 | Chi [m1] |
14+
| aliasing.cpp:13:10:13:19 | call to user_input | aliasing.cpp:13:3:13:21 | Store |
15+
| aliasing.cpp:25:17:25:19 | Chi [m1] | aliasing.cpp:29:11:29:12 | m1 |
16+
| aliasing.cpp:25:17:25:19 | pointerSetter output argument [m1] | aliasing.cpp:25:17:25:19 | Chi [m1] |
17+
| aliasing.cpp:26:19:26:20 | Chi [m1] | aliasing.cpp:30:11:30:12 | m1 |
18+
| aliasing.cpp:26:19:26:20 | referenceSetter output argument [m1] | aliasing.cpp:26:19:26:20 | Chi [m1] |
219
| aliasing.cpp:37:13:37:22 | call to user_input | aliasing.cpp:38:11:38:12 | m1 |
320
| aliasing.cpp:42:11:42:20 | call to user_input | aliasing.cpp:43:13:43:14 | m1 |
421
| aliasing.cpp:60:3:60:22 | Chi [m1] | aliasing.cpp:61:13:61:14 | Store [m1] |
@@ -11,6 +28,26 @@ edges
1128
| struct_init.c:20:20:20:29 | call to user_input | struct_init.c:22:11:22:11 | a |
1229
| struct_init.c:27:7:27:16 | call to user_input | struct_init.c:31:23:31:23 | a |
1330
nodes
31+
| A.cpp:142:7:142:20 | Chi [c] | semmle.label | Chi [c] |
32+
| A.cpp:142:7:142:20 | Store | semmle.label | Store |
33+
| A.cpp:142:14:142:20 | new | semmle.label | new |
34+
| A.cpp:151:18:151:18 | Chi [c] | semmle.label | Chi [c] |
35+
| A.cpp:151:18:151:18 | D output argument [c] | semmle.label | D output argument [c] |
36+
| A.cpp:154:10:154:13 | (void *)... | semmle.label | (void *)... |
37+
| A.cpp:154:13:154:13 | c | semmle.label | c |
38+
| A.cpp:154:13:154:13 | c | semmle.label | c |
39+
| aliasing.cpp:9:3:9:22 | Chi [m1] | semmle.label | Chi [m1] |
40+
| aliasing.cpp:9:3:9:22 | Store | semmle.label | Store |
41+
| aliasing.cpp:9:11:9:20 | call to user_input | semmle.label | call to user_input |
42+
| aliasing.cpp:13:3:13:21 | Chi [m1] | semmle.label | Chi [m1] |
43+
| aliasing.cpp:13:3:13:21 | Store | semmle.label | Store |
44+
| aliasing.cpp:13:10:13:19 | call to user_input | semmle.label | call to user_input |
45+
| aliasing.cpp:25:17:25:19 | Chi [m1] | semmle.label | Chi [m1] |
46+
| aliasing.cpp:25:17:25:19 | pointerSetter output argument [m1] | semmle.label | pointerSetter output argument [m1] |
47+
| aliasing.cpp:26:19:26:20 | Chi [m1] | semmle.label | Chi [m1] |
48+
| aliasing.cpp:26:19:26:20 | referenceSetter output argument [m1] | semmle.label | referenceSetter output argument [m1] |
49+
| aliasing.cpp:29:11:29:12 | m1 | semmle.label | m1 |
50+
| aliasing.cpp:30:11:30:12 | m1 | semmle.label | m1 |
1451
| aliasing.cpp:37:13:37:22 | call to user_input | semmle.label | call to user_input |
1552
| aliasing.cpp:38:11:38:12 | m1 | semmle.label | m1 |
1653
| aliasing.cpp:42:11:42:20 | call to user_input | semmle.label | call to user_input |
@@ -31,6 +68,10 @@ nodes
3168
| struct_init.c:27:7:27:16 | call to user_input | semmle.label | call to user_input |
3269
| struct_init.c:31:23:31:23 | a | semmle.label | a |
3370
#select
71+
| A.cpp:154:10:154:13 | (void *)... | A.cpp:142:14:142:20 | new | A.cpp:154:10:154:13 | (void *)... | (void *)... flows from $@ | A.cpp:142:14:142:20 | new | new |
72+
| A.cpp:154:13:154:13 | c | A.cpp:142:14:142:20 | new | A.cpp:154:13:154:13 | c | c flows from $@ | A.cpp:142:14:142:20 | new | new |
73+
| 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 |
74+
| 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 |
3475
| aliasing.cpp:38:11:38:12 | m1 | aliasing.cpp:37:13:37:22 | call to user_input | aliasing.cpp:38:11:38:12 | m1 | m1 flows from $@ | aliasing.cpp:37:13:37:22 | call to user_input | call to user_input |
3576
| aliasing.cpp:43:13:43:14 | m1 | aliasing.cpp:42:11:42:20 | call to user_input | aliasing.cpp:43:13:43:14 | m1 | m1 flows from $@ | aliasing.cpp:42:11:42:20 | call to user_input | call to user_input |
3677
| 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 |

0 commit comments

Comments
 (0)