Skip to content

Commit cca9f3f

Browse files
committed
C++: Add false positive from lack of overload handling.
1 parent 1511488 commit cca9f3f

4 files changed

Lines changed: 88 additions & 0 deletions

File tree

‎cpp/ql/test/library-tests/dataflow/external-models/flow.expected‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,34 @@ edges
399399
| test.cpp:411:39:411:41 | call to get [x] | test.cpp:412:11:412:11 | *e [x] | provenance | |
400400
| test.cpp:412:11:412:11 | *e [x] | test.cpp:412:13:412:13 | x | provenance | |
401401
| test.cpp:412:13:412:13 | x | test.cpp:412:13:412:13 | x | provenance | Sink:MaD:3 |
402+
| test.cpp:417:3:417:28 | *ElementWithOverloadedArity [post update] [x] | test.cpp:417:3:417:28 | *this [Return] [x] | provenance | |
403+
| test.cpp:417:34:417:38 | first | test.cpp:417:45:417:49 | first | provenance | |
404+
| test.cpp:417:45:417:49 | first | test.cpp:417:3:417:28 | *ElementWithOverloadedArity [post update] [x] | provenance | |
405+
| test.cpp:418:3:418:28 | *ElementWithOverloadedArity [post update] [x] | test.cpp:418:3:418:28 | *this [Return] [x] | provenance | |
406+
| test.cpp:418:39:418:44 | second | test.cpp:418:51:418:56 | second | provenance | |
407+
| test.cpp:418:51:418:56 | second | test.cpp:418:3:418:28 | *ElementWithOverloadedArity [post update] [x] | provenance | |
408+
| test.cpp:422:11:422:19 | call to ymlSource | test.cpp:422:11:422:19 | call to ymlSource | provenance | Src:MaD:48 |
409+
| test.cpp:422:11:422:19 | call to ymlSource | test.cpp:425:18:425:18 | *x | provenance | |
410+
| test.cpp:422:11:422:19 | call to ymlSource | test.cpp:430:18:430:18 | *x | provenance | |
411+
| test.cpp:422:11:422:19 | call to ymlSource | test.cpp:435:21:435:21 | *x | provenance | |
412+
| test.cpp:425:5:425:5 | emplace output argument [element, x] | test.cpp:426:13:426:13 | *c [element, x] | provenance | |
413+
| test.cpp:425:18:425:18 | *x | test.cpp:417:34:417:38 | first | provenance | |
414+
| test.cpp:425:18:425:18 | *x | test.cpp:425:5:425:5 | emplace output argument [element, x] | provenance | |
415+
| test.cpp:426:13:426:13 | *c [element, x] | test.cpp:426:18:426:20 | *call to get [x] | provenance | MaD:87 |
416+
| test.cpp:426:18:426:20 | *call to get [x] | test.cpp:426:21:426:21 | x | provenance | |
417+
| test.cpp:426:21:426:21 | x | test.cpp:426:21:426:21 | x | provenance | Sink:MaD:3 |
418+
| test.cpp:430:5:430:5 | emplace output argument [element, x] | test.cpp:431:13:431:13 | *c [element, x] | provenance | |
419+
| test.cpp:430:18:430:18 | *x | test.cpp:417:34:417:38 | first | provenance | |
420+
| test.cpp:430:18:430:18 | *x | test.cpp:430:5:430:5 | emplace output argument [element, x] | provenance | |
421+
| test.cpp:431:13:431:13 | *c [element, x] | test.cpp:431:18:431:20 | *call to get [x] | provenance | MaD:87 |
422+
| test.cpp:431:18:431:20 | *call to get [x] | test.cpp:431:21:431:21 | x | provenance | |
423+
| test.cpp:431:21:431:21 | x | test.cpp:431:21:431:21 | x | provenance | Sink:MaD:3 |
424+
| test.cpp:435:5:435:5 | emplace output argument [element, x] | test.cpp:436:13:436:13 | *c [element, x] | provenance | |
425+
| test.cpp:435:21:435:21 | *x | test.cpp:418:39:418:44 | second | provenance | |
426+
| test.cpp:435:21:435:21 | *x | test.cpp:435:5:435:5 | emplace output argument [element, x] | provenance | |
427+
| test.cpp:436:13:436:13 | *c [element, x] | test.cpp:436:18:436:20 | *call to get [x] | provenance | MaD:87 |
428+
| test.cpp:436:18:436:20 | *call to get [x] | test.cpp:436:21:436:21 | x | provenance | |
429+
| test.cpp:436:21:436:21 | x | test.cpp:436:21:436:21 | x | provenance | Sink:MaD:3 |
402430
| windows.cpp:22:15:22:29 | *call to GetCommandLineA | windows.cpp:24:8:24:11 | * ... | provenance | |
403431
| windows.cpp:22:15:22:29 | *call to GetCommandLineA | windows.cpp:27:36:27:38 | *cmd | provenance | |
404432
| windows.cpp:22:15:22:29 | call to GetCommandLineA | windows.cpp:22:15:22:29 | *call to GetCommandLineA | provenance | Src:MaD:5 |
@@ -907,6 +935,34 @@ nodes
907935
| test.cpp:412:11:412:11 | *e [x] | semmle.label | *e [x] |
908936
| test.cpp:412:13:412:13 | x | semmle.label | x |
909937
| test.cpp:412:13:412:13 | x | semmle.label | x |
938+
| test.cpp:417:3:417:28 | *ElementWithOverloadedArity [post update] [x] | semmle.label | *ElementWithOverloadedArity [post update] [x] |
939+
| test.cpp:417:3:417:28 | *this [Return] [x] | semmle.label | *this [Return] [x] |
940+
| test.cpp:417:34:417:38 | first | semmle.label | first |
941+
| test.cpp:417:45:417:49 | first | semmle.label | first |
942+
| test.cpp:418:3:418:28 | *ElementWithOverloadedArity [post update] [x] | semmle.label | *ElementWithOverloadedArity [post update] [x] |
943+
| test.cpp:418:3:418:28 | *this [Return] [x] | semmle.label | *this [Return] [x] |
944+
| test.cpp:418:39:418:44 | second | semmle.label | second |
945+
| test.cpp:418:51:418:56 | second | semmle.label | second |
946+
| test.cpp:422:11:422:19 | call to ymlSource | semmle.label | call to ymlSource |
947+
| test.cpp:422:11:422:19 | call to ymlSource | semmle.label | call to ymlSource |
948+
| test.cpp:425:5:425:5 | emplace output argument [element, x] | semmle.label | emplace output argument [element, x] |
949+
| test.cpp:425:18:425:18 | *x | semmle.label | *x |
950+
| test.cpp:426:13:426:13 | *c [element, x] | semmle.label | *c [element, x] |
951+
| test.cpp:426:18:426:20 | *call to get [x] | semmle.label | *call to get [x] |
952+
| test.cpp:426:21:426:21 | x | semmle.label | x |
953+
| test.cpp:426:21:426:21 | x | semmle.label | x |
954+
| test.cpp:430:5:430:5 | emplace output argument [element, x] | semmle.label | emplace output argument [element, x] |
955+
| test.cpp:430:18:430:18 | *x | semmle.label | *x |
956+
| test.cpp:431:13:431:13 | *c [element, x] | semmle.label | *c [element, x] |
957+
| test.cpp:431:18:431:20 | *call to get [x] | semmle.label | *call to get [x] |
958+
| test.cpp:431:21:431:21 | x | semmle.label | x |
959+
| test.cpp:431:21:431:21 | x | semmle.label | x |
960+
| test.cpp:435:5:435:5 | emplace output argument [element, x] | semmle.label | emplace output argument [element, x] |
961+
| test.cpp:435:21:435:21 | *x | semmle.label | *x |
962+
| test.cpp:436:13:436:13 | *c [element, x] | semmle.label | *c [element, x] |
963+
| test.cpp:436:18:436:20 | *call to get [x] | semmle.label | *call to get [x] |
964+
| test.cpp:436:21:436:21 | x | semmle.label | x |
965+
| test.cpp:436:21:436:21 | x | semmle.label | x |
910966
| windows.cpp:22:15:22:29 | *call to GetCommandLineA | semmle.label | *call to GetCommandLineA |
911967
| windows.cpp:22:15:22:29 | call to GetCommandLineA | semmle.label | call to GetCommandLineA |
912968
| windows.cpp:24:8:24:11 | * ... | semmle.label | * ... |
@@ -1130,4 +1186,7 @@ subpaths
11301186
| test.cpp:172:51:172:51 | x | test.cpp:164:34:164:34 | x | test.cpp:164:7:164:7 | *templateFunction3 | test.cpp:172:13:172:44 | call to templateFunction3 |
11311187
| test.cpp:362:15:362:15 | *x | test.cpp:341:30:341:32 | arg | test.cpp:341:3:341:22 | *this [Return] [s] | test.cpp:362:5:362:5 | forward output argument [s] |
11321188
| test.cpp:371:15:371:16 | *ul | test.cpp:345:38:345:40 | arg | test.cpp:345:3:345:22 | *this [Return] [ul] | test.cpp:371:5:371:5 | forward output argument [ul] |
1189+
| test.cpp:425:18:425:18 | *x | test.cpp:417:34:417:38 | first | test.cpp:417:3:417:28 | *this [Return] [x] | test.cpp:425:5:425:5 | emplace output argument [element, x] |
1190+
| test.cpp:430:18:430:18 | *x | test.cpp:417:34:417:38 | first | test.cpp:417:3:417:28 | *this [Return] [x] | test.cpp:430:5:430:5 | emplace output argument [element, x] |
1191+
| test.cpp:435:21:435:21 | *x | test.cpp:418:39:418:44 | second | test.cpp:418:3:418:28 | *this [Return] [x] | test.cpp:435:5:435:5 | emplace output argument [element, x] |
11331192
testFailures

‎cpp/ql/test/library-tests/dataflow/external-models/sinks.expected‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@
4949
| test.cpp:375:15:375:16 | ul | test-sink |
5050
| test.cpp:398:13:398:13 | x | test-sink |
5151
| test.cpp:412:13:412:13 | x | test-sink |
52+
| test.cpp:426:21:426:21 | x | test-sink |
53+
| test.cpp:431:21:431:21 | x | test-sink |
54+
| test.cpp:436:21:436:21 | x | test-sink |

‎cpp/ql/test/library-tests/dataflow/external-models/sources.expected‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
| test.cpp:370:24:370:32 | call to ymlSource | local |
2424
| test.cpp:394:11:394:19 | call to ymlSource | local |
2525
| test.cpp:408:11:408:19 | call to ymlSource | local |
26+
| test.cpp:422:11:422:19 | call to ymlSource | local |
2627
| windows.cpp:22:15:22:29 | call to GetCommandLineA | local |
2728
| windows.cpp:34:17:34:38 | call to GetEnvironmentStringsA | local |
2829
| windows.cpp:39:36:39:38 | GetEnvironmentVariableA output argument | local |

‎cpp/ql/test/library-tests/dataflow/external-models/test.cpp‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,29 @@ void forward_test_model_with_default_argument() {
410410

411411
ElementWithDefaultArgument e = c.get();
412412
ymlSink(e.x); // $ ir
413+
}
414+
415+
struct ElementWithOverloadedArity {
416+
int x;
417+
ElementWithOverloadedArity(int first) : x(first) {}
418+
ElementWithOverloadedArity(int, int second) : x(second) {}
419+
};
420+
421+
void forward_test_constructor_arity() {
422+
int x = ymlSource();
423+
{
424+
Container<ElementWithOverloadedArity> c;
425+
c.emplace(0, x);
426+
ymlSink(c.get().x); // $ ir
427+
}
428+
{
429+
Container<ElementWithOverloadedArity> c;
430+
c.emplace(0, x, 0);
431+
ymlSink(c.get().x); // $ SPURIOUS: ir
432+
}
433+
{
434+
Container<ElementWithOverloadedArity> c;
435+
c.emplace(0, 0, x);
436+
ymlSink(c.get().x); // $ ir
437+
}
413438
}

0 commit comments

Comments
 (0)