Skip to content

Commit ceccc92

Browse files
committed
C++: Add a testcase that failed during development.
1 parent a9af28e commit ceccc92

File tree

7 files changed

+36
-0
lines changed

7 files changed

+36
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ postWithInFlow
184184
| simple.cpp:65:7:65:7 | i [post update] | PostUpdateNode should not be the target of local flow. |
185185
| simple.cpp:83:12:83:13 | f1 [post update] | PostUpdateNode should not be the target of local flow. |
186186
| simple.cpp:92:7:92:7 | i [post update] | PostUpdateNode should not be the target of local flow. |
187+
| simple.cpp:118:7:118:7 | i [post update] | PostUpdateNode should not be the target of local flow. |
187188
| struct_init.c:24:11:24:12 | ab [inner post update] | PostUpdateNode should not be the target of local flow. |
188189
| struct_init.c:36:17:36:24 | nestedAB [inner post update] | PostUpdateNode should not be the target of local flow. |
189190
viableImplInCallContextTooLarge

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,10 @@ edges
842842
| simple.cpp:108:17:108:26 | call to user_input | simple.cpp:108:17:108:26 | call to user_input | provenance | |
843843
| simple.cpp:108:17:108:26 | call to user_input | simple.cpp:109:43:109:43 | x | provenance | |
844844
| simple.cpp:109:43:109:43 | x | simple.cpp:103:24:103:24 | x | provenance | |
845+
| simple.cpp:118:5:118:5 | *a [post update] [i] | simple.cpp:120:8:120:8 | *a [i] | provenance | |
846+
| simple.cpp:118:5:118:22 | ... = ... | simple.cpp:118:5:118:5 | *a [post update] [i] | provenance | |
847+
| simple.cpp:118:11:118:20 | call to user_input | simple.cpp:118:5:118:22 | ... = ... | provenance | |
848+
| simple.cpp:120:8:120:8 | *a [i] | simple.cpp:120:10:120:10 | i | provenance | |
845849
| struct_init.c:14:24:14:25 | *ab [a] | struct_init.c:14:24:14:25 | *ab [a] | provenance | |
846850
| struct_init.c:14:24:14:25 | *ab [a] | struct_init.c:15:8:15:9 | *ab [a] | provenance | |
847851
| struct_init.c:15:8:15:9 | *ab [a] | struct_init.c:15:12:15:12 | a | provenance | |
@@ -1747,6 +1751,11 @@ nodes
17471751
| simple.cpp:108:17:108:26 | call to user_input | semmle.label | call to user_input |
17481752
| simple.cpp:108:17:108:26 | call to user_input | semmle.label | call to user_input |
17491753
| simple.cpp:109:43:109:43 | x | semmle.label | x |
1754+
| simple.cpp:118:5:118:5 | *a [post update] [i] | semmle.label | *a [post update] [i] |
1755+
| simple.cpp:118:5:118:22 | ... = ... | semmle.label | ... = ... |
1756+
| simple.cpp:118:11:118:20 | call to user_input | semmle.label | call to user_input |
1757+
| simple.cpp:120:8:120:8 | *a [i] | semmle.label | *a [i] |
1758+
| simple.cpp:120:10:120:10 | i | semmle.label | i |
17501759
| struct_init.c:14:24:14:25 | *ab [a] | semmle.label | *ab [a] |
17511760
| struct_init.c:14:24:14:25 | *ab [a] | semmle.label | *ab [a] |
17521761
| struct_init.c:15:8:15:9 | *ab [a] | semmle.label | *ab [a] |
@@ -1957,6 +1966,7 @@ subpaths
19571966
| 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 |
19581967
| 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 |
19591968
| simple.cpp:104:14:104:14 | x | simple.cpp:108:17:108:26 | call to user_input | simple.cpp:104:14:104:14 | x | x flows from $@ | simple.cpp:108:17:108:26 | call to user_input | call to user_input |
1969+
| simple.cpp:120:10:120:10 | i | simple.cpp:118:11:118:20 | call to user_input | simple.cpp:120:10:120:10 | i | i flows from $@ | simple.cpp:118:11:118:20 | call to user_input | call to user_input |
19601970
| 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 |
19611971
| 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 |
19621972
| 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/partial-definition-diff.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,5 @@ WARNING: Module DataFlow has been deprecated and may be removed in future (parti
289289
| simple.cpp:83:12:83:13 | f1 | AST only |
290290
| simple.cpp:92:7:92:7 | i | AST only |
291291
| simple.cpp:94:10:94:11 | a2 | IR only |
292+
| simple.cpp:118:7:118:7 | i | AST only |
293+
| simple.cpp:120:8:120:8 | a | IR only |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,8 @@
649649
| simple.cpp:84:14:84:20 | this |
650650
| simple.cpp:92:5:92:5 | a |
651651
| simple.cpp:94:10:94:11 | a2 |
652+
| simple.cpp:118:5:118:5 | a |
653+
| simple.cpp:120:8:120:8 | a |
652654
| struct_init.c:15:8:15:9 | ab |
653655
| struct_init.c:15:12:15:12 | a |
654656
| struct_init.c:16:8:16:9 | ab |

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,8 @@ WARNING: Module DataFlow has been deprecated and may be removed in future (parti
579579
| simple.cpp:84:14:84:20 | this |
580580
| simple.cpp:92:5:92:5 | a |
581581
| simple.cpp:92:7:92:7 | i |
582+
| simple.cpp:118:5:118:5 | a |
583+
| simple.cpp:118:7:118:7 | i |
582584
| struct_init.c:15:8:15:9 | ab |
583585
| struct_init.c:15:12:15:12 | a |
584586
| 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
@@ -731,6 +731,10 @@ edges
731731
| simple.cpp:92:5:92:22 | ... = ... | simple.cpp:92:5:92:5 | a [post update] [i] | provenance | |
732732
| simple.cpp:92:11:92:20 | call to user_input | simple.cpp:92:5:92:22 | ... = ... | provenance | |
733733
| simple.cpp:94:10:94:11 | a2 [i] | simple.cpp:94:13:94:13 | i | provenance | |
734+
| simple.cpp:118:5:118:5 | a [post update] [i] | simple.cpp:120:8:120:8 | a [i] | provenance | |
735+
| simple.cpp:118:5:118:22 | ... = ... | simple.cpp:118:5:118:5 | a [post update] [i] | provenance | |
736+
| simple.cpp:118:11:118:20 | call to user_input | simple.cpp:118:5:118:22 | ... = ... | provenance | |
737+
| simple.cpp:120:8:120:8 | a [i] | simple.cpp:120:10:120:10 | i | provenance | |
734738
| struct_init.c:14:24:14:25 | ab [a] | struct_init.c:14:24:14:25 | ab [a] | provenance | |
735739
| struct_init.c:14:24:14:25 | ab [a] | struct_init.c:15:8:15:9 | ab [a] | provenance | |
736740
| struct_init.c:15:8:15:9 | ab [a] | struct_init.c:15:12:15:12 | a | provenance | |
@@ -1538,6 +1542,11 @@ nodes
15381542
| simple.cpp:92:11:92:20 | call to user_input | semmle.label | call to user_input |
15391543
| simple.cpp:94:10:94:11 | a2 [i] | semmle.label | a2 [i] |
15401544
| simple.cpp:94:13:94:13 | i | semmle.label | i |
1545+
| simple.cpp:118:5:118:5 | a [post update] [i] | semmle.label | a [post update] [i] |
1546+
| simple.cpp:118:5:118:22 | ... = ... | semmle.label | ... = ... |
1547+
| simple.cpp:118:11:118:20 | call to user_input | semmle.label | call to user_input |
1548+
| simple.cpp:120:8:120:8 | a [i] | semmle.label | a [i] |
1549+
| simple.cpp:120:10:120:10 | i | semmle.label | i |
15411550
| struct_init.c:14:24:14:25 | ab [a] | semmle.label | ab [a] |
15421551
| struct_init.c:14:24:14:25 | ab [a] | semmle.label | ab [a] |
15431552
| struct_init.c:15:8:15:9 | ab [a] | semmle.label | ab [a] |
@@ -1751,6 +1760,7 @@ subpaths
17511760
| 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 |
17521761
| 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 |
17531762
| 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 |
1763+
| simple.cpp:120:10:120:10 | i | simple.cpp:118:11:118:20 | call to user_input | simple.cpp:120:10:120:10 | i | i flows from $@ | simple.cpp:118:11:118:20 | call to user_input | call to user_input |
17541764
| 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 |
17551765
| 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 |
17561766
| 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
@@ -111,4 +111,13 @@ namespace TestAdditionalCallTargets {
111111

112112
}
113113

114+
void post_update_to_phi_input(bool b)
115+
{
116+
A a;
117+
if(b) {
118+
a.i = user_input();
119+
}
120+
sink(a.i); // $ ast,ir
121+
}
122+
114123
} // namespace Simple

0 commit comments

Comments
 (0)