Skip to content

Commit d18dd5a

Browse files
committed
C++: Add testcase demonstrating the underlying problem in 6ca9c44.
1 parent 1fbb0fb commit d18dd5a

File tree

7 files changed

+25
-0
lines changed

7 files changed

+25
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ localCallNodes
2020
postIsNotPre
2121
postHasUniquePre
2222
| simple.cpp:65:5:65:22 | Store | PostUpdateNode should have one pre-update node but has 0. |
23+
| simple.cpp:92:5:92:22 | Store | PostUpdateNode should have one pre-update node but has 0. |
2324
uniquePostUpdate
2425
postIsInSameCallable
2526
reverseRead

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,6 @@
3737
| qualifiers.cpp:37:38:37:47 | call to user_input | qualifiers.cpp:38:23:38:23 | a | AST only |
3838
| qualifiers.cpp:42:29:42:38 | call to user_input | qualifiers.cpp:43:23:43:23 | a | AST only |
3939
| qualifiers.cpp:47:31:47:40 | call to user_input | qualifiers.cpp:48:23:48:23 | a | AST only |
40+
| simple.cpp:92:11:92:20 | call to user_input | simple.cpp:94:13:94:13 | i | AST only |
4041
| struct_init.c:20:20:20:29 | call to user_input | struct_init.c:33:25:33:25 | a | AST only |
4142
| struct_init.c:40:20:40:29 | call to user_input | struct_init.c:15:12:15:12 | a | AST only |

cpp/ql/test/library-tests/dataflow/fields/partial-definition-diff.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@
321321
| simple.cpp:83:9:83:10 | this | AST only |
322322
| simple.cpp:83:12:83:13 | f1 | AST only |
323323
| simple.cpp:84:14:84:20 | this | AST only |
324+
| simple.cpp:92:7:92:7 | i | AST only |
324325
| struct_init.c:15:8:15:9 | ab | AST only |
325326
| struct_init.c:15:12:15:12 | a | AST only |
326327
| struct_init.c:16:8:16:9 | ab | AST only |

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@
4242
| simple.cpp:21:24:21:25 | this |
4343
| simple.cpp:65:5:65:5 | a |
4444
| simple.cpp:83:9:83:10 | f2 |
45+
| simple.cpp:92:5:92:5 | a |

cpp/ql/test/library-tests/dataflow/fields/partial-definition.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@
365365
| simple.cpp:83:9:83:10 | this |
366366
| simple.cpp:83:12:83:13 | f1 |
367367
| simple.cpp:84:14:84:20 | this |
368+
| simple.cpp:92:5:92:5 | a |
369+
| simple.cpp:92:7:92:7 | i |
368370
| struct_init.c:15:8:15:9 | ab |
369371
| struct_init.c:15:12:15:12 | a |
370372
| struct_init.c:16:8:16:9 | ab |

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,10 @@ edges
332332
| simple.cpp:83:9:83:28 | ... = ... | simple.cpp:83:9:83:10 | f2 [post update] [f1] |
333333
| simple.cpp:83:17:83:26 | call to user_input | simple.cpp:83:9:83:28 | ... = ... |
334334
| simple.cpp:84:14:84:20 | this [f2, f1] | simple.cpp:84:14:84:20 | call to getf2f1 |
335+
| simple.cpp:92:5:92:5 | a [post update] [i] | simple.cpp:94:10:94:11 | a2 [i] |
336+
| simple.cpp:92:5:92:22 | ... = ... | simple.cpp:92:5:92:5 | a [post update] [i] |
337+
| simple.cpp:92:11:92:20 | call to user_input | simple.cpp:92:5:92:22 | ... = ... |
338+
| simple.cpp:94:10:94:11 | a2 [i] | simple.cpp:94:13:94:13 | i |
335339
| struct_init.c:14:24:14:25 | ab [a] | struct_init.c:15:8:15:9 | ab [a] |
336340
| struct_init.c:15:8:15:9 | ab [a] | struct_init.c:15:12:15:12 | a |
337341
| struct_init.c:20:17:20:36 | {...} [a] | struct_init.c:22:8:22:9 | ab [a] |
@@ -732,6 +736,11 @@ nodes
732736
| simple.cpp:83:17:83:26 | call to user_input | semmle.label | call to user_input |
733737
| simple.cpp:84:14:84:20 | call to getf2f1 | semmle.label | call to getf2f1 |
734738
| simple.cpp:84:14:84:20 | this [f2, f1] | semmle.label | this [f2, f1] |
739+
| simple.cpp:92:5:92:5 | a [post update] [i] | semmle.label | a [post update] [i] |
740+
| simple.cpp:92:5:92:22 | ... = ... | semmle.label | ... = ... |
741+
| simple.cpp:92:11:92:20 | call to user_input | semmle.label | call to user_input |
742+
| simple.cpp:94:10:94:11 | a2 [i] | semmle.label | a2 [i] |
743+
| simple.cpp:94:13:94:13 | i | semmle.label | i |
735744
| struct_init.c:14:24:14:25 | ab [a] | semmle.label | ab [a] |
736745
| struct_init.c:15:8:15:9 | ab [a] | semmle.label | ab [a] |
737746
| struct_init.c:15:12:15:12 | a | semmle.label | a |
@@ -830,6 +839,7 @@ nodes
830839
| simple.cpp:29:12:29:12 | call to b | simple.cpp:42:12:42:21 | call to user_input | simple.cpp:29:12:29:12 | call to b | call to b flows from $@ | simple.cpp:42:12:42:21 | call to user_input | call to user_input |
831840
| simple.cpp:67:13:67:13 | i | simple.cpp:65:11:65:20 | call to user_input | simple.cpp:67:13:67:13 | i | i flows from $@ | simple.cpp:65:11:65:20 | call to user_input | call to user_input |
832841
| simple.cpp:84:14:84:20 | call to getf2f1 | simple.cpp:83:17:83:26 | call to user_input | simple.cpp:84:14:84:20 | call to getf2f1 | call to getf2f1 flows from $@ | simple.cpp:83:17:83:26 | call to user_input | call to user_input |
842+
| simple.cpp:94:13:94:13 | i | simple.cpp:92:11:92:20 | call to user_input | simple.cpp:94:13:94:13 | i | i flows from $@ | simple.cpp:92:11:92:20 | call to user_input | call to user_input |
833843
| struct_init.c:15:12:15:12 | a | struct_init.c:20:20:20:29 | call to user_input | struct_init.c:15:12:15:12 | a | a flows from $@ | struct_init.c:20:20:20:29 | call to user_input | call to user_input |
834844
| struct_init.c:15:12:15:12 | a | struct_init.c:27:7:27:16 | call to user_input | struct_init.c:15:12:15:12 | a | a flows from $@ | struct_init.c:27:7:27:16 | call to user_input | call to user_input |
835845
| struct_init.c:15:12:15:12 | a | struct_init.c:40:20:40:29 | call to user_input | struct_init.c:15:12:15:12 | a | a flows from $@ | struct_init.c:40:20:40:29 | call to user_input | call to user_input |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,4 +85,13 @@ struct C2
8585
}
8686
};
8787

88+
typedef A A_typedef;
89+
90+
void single_field_test_typedef(A_typedef a)
91+
{
92+
a.i = user_input();
93+
A_typedef a2 = a;
94+
sink(a2.i); //$ast $f-:ir
95+
}
96+
8897
} // namespace Simple

0 commit comments

Comments
 (0)