Skip to content

Commit c7fb8de

Browse files
committed
Swift: Test ForceValueExpr content reads.
1 parent e011480 commit c7fb8de

File tree

3 files changed

+184
-0
lines changed

3 files changed

+184
-0
lines changed

swift/ql/test/library-tests/dataflow/dataflow/DataFlow.expected

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
edges
22
| file://:0:0:0:0 | self [a, x] | file://:0:0:0:0 | .a [x] |
33
| file://:0:0:0:0 | self [str] | file://:0:0:0:0 | .str |
4+
| file://:0:0:0:0 | self [v2, some:0] | file://:0:0:0:0 | .v2 [some:0] |
5+
| file://:0:0:0:0 | self [v2] | file://:0:0:0:0 | .v2 |
6+
| file://:0:0:0:0 | self [v3] | file://:0:0:0:0 | .v3 |
47
| file://:0:0:0:0 | self [x, some:0] | file://:0:0:0:0 | .x [some:0] |
58
| file://:0:0:0:0 | self [x] | file://:0:0:0:0 | .x |
9+
| file://:0:0:0:0 | value | file://:0:0:0:0 | [post] self [v2] |
10+
| file://:0:0:0:0 | value | file://:0:0:0:0 | [post] self [v3] |
611
| file://:0:0:0:0 | value | file://:0:0:0:0 | [post] self [x] |
12+
| file://:0:0:0:0 | value [some:0] | file://:0:0:0:0 | [post] self [v2, some:0] |
713
| file://:0:0:0:0 | value [some:0] | file://:0:0:0:0 | [post] self [x, some:0] |
814
| test.swift:6:19:6:26 | call to source() | test.swift:7:15:7:15 | t1 |
915
| test.swift:6:19:6:26 | call to source() | test.swift:9:15:9:15 | t1 |
@@ -336,18 +342,61 @@ edges
336342
| test.swift:693:5:693:5 | [post] arr6 [Array element] | test.swift:694:15:694:15 | arr6 [Array element] |
337343
| test.swift:693:17:693:24 | call to source() | test.swift:693:5:693:5 | [post] arr6 [Array element] |
338344
| test.swift:694:15:694:15 | arr6 [Array element] | test.swift:694:15:694:21 | ...[...] |
345+
| test.swift:699:9:699:9 | self [v2, some:0] | file://:0:0:0:0 | self [v2, some:0] |
346+
| test.swift:699:9:699:9 | self [v2] | file://:0:0:0:0 | self [v2] |
347+
| test.swift:699:9:699:9 | value | file://:0:0:0:0 | value |
348+
| test.swift:699:9:699:9 | value [some:0] | file://:0:0:0:0 | value [some:0] |
349+
| test.swift:700:9:700:9 | self [v3] | file://:0:0:0:0 | self [v3] |
350+
| test.swift:700:9:700:9 | value | file://:0:0:0:0 | value |
351+
| test.swift:711:10:711:17 | call to source() | test.swift:711:10:711:17 | call to source() [some:0] |
352+
| test.swift:711:10:711:17 | call to source() | test.swift:721:15:721:17 | ...! |
353+
| test.swift:711:10:711:17 | call to source() [some:0] | test.swift:721:15:721:15 | v2 [some:0] |
354+
| test.swift:712:10:712:17 | call to source() | test.swift:722:15:722:15 | v3 |
355+
| test.swift:714:5:714:5 | [post] mo1 [v2, some:0] | test.swift:715:5:715:5 | mo1 [v2, some:0] |
356+
| test.swift:714:5:714:5 | [post] mo1 [v2] | test.swift:715:5:715:5 | mo1 [v2] |
357+
| test.swift:714:14:714:21 | call to source() | test.swift:699:9:699:9 | value |
358+
| test.swift:714:14:714:21 | call to source() | test.swift:714:5:714:5 | [post] mo1 [v2] |
359+
| test.swift:714:14:714:21 | call to source() | test.swift:714:14:714:21 | call to source() [some:0] |
360+
| test.swift:714:14:714:21 | call to source() [some:0] | test.swift:699:9:699:9 | value [some:0] |
361+
| test.swift:714:14:714:21 | call to source() [some:0] | test.swift:714:5:714:5 | [post] mo1 [v2, some:0] |
362+
| test.swift:715:5:715:5 | [post] mo1 [v3] | test.swift:725:15:725:15 | mo1 [v3] |
363+
| test.swift:715:5:715:5 | mo1 [v2, some:0] | test.swift:724:15:724:15 | mo1 [v2, some:0] |
364+
| test.swift:715:5:715:5 | mo1 [v2] | test.swift:724:15:724:15 | mo1 [v2] |
365+
| test.swift:715:14:715:21 | call to source() | test.swift:700:9:700:9 | value |
366+
| test.swift:715:14:715:21 | call to source() | test.swift:715:5:715:5 | [post] mo1 [v3] |
367+
| test.swift:721:15:721:15 | v2 [some:0] | test.swift:721:15:721:17 | ...! |
368+
| test.swift:724:15:724:15 | mo1 [v2, some:0] | test.swift:699:9:699:9 | self [v2, some:0] |
369+
| test.swift:724:15:724:15 | mo1 [v2, some:0] | test.swift:724:15:724:19 | .v2 [some:0] |
370+
| test.swift:724:15:724:15 | mo1 [v2] | test.swift:699:9:699:9 | self [v2] |
371+
| test.swift:724:15:724:15 | mo1 [v2] | test.swift:724:15:724:19 | .v2 |
372+
| test.swift:724:15:724:19 | .v2 | test.swift:724:15:724:21 | ...! |
373+
| test.swift:724:15:724:19 | .v2 [some:0] | test.swift:724:15:724:21 | ...! |
374+
| test.swift:725:15:725:15 | mo1 [v3] | test.swift:700:9:700:9 | self [v3] |
375+
| test.swift:725:15:725:15 | mo1 [v3] | test.swift:725:15:725:19 | .v3 |
339376
nodes
340377
| file://:0:0:0:0 | .a [x] | semmle.label | .a [x] |
341378
| file://:0:0:0:0 | .str | semmle.label | .str |
379+
| file://:0:0:0:0 | .v2 | semmle.label | .v2 |
380+
| file://:0:0:0:0 | .v2 [some:0] | semmle.label | .v2 [some:0] |
381+
| file://:0:0:0:0 | .v3 | semmle.label | .v3 |
342382
| file://:0:0:0:0 | .x | semmle.label | .x |
343383
| file://:0:0:0:0 | .x [some:0] | semmle.label | .x [some:0] |
384+
| file://:0:0:0:0 | [post] self [v2, some:0] | semmle.label | [post] self [v2, some:0] |
385+
| file://:0:0:0:0 | [post] self [v2] | semmle.label | [post] self [v2] |
386+
| file://:0:0:0:0 | [post] self [v3] | semmle.label | [post] self [v3] |
344387
| file://:0:0:0:0 | [post] self [x, some:0] | semmle.label | [post] self [x, some:0] |
345388
| file://:0:0:0:0 | [post] self [x] | semmle.label | [post] self [x] |
346389
| file://:0:0:0:0 | self [a, x] | semmle.label | self [a, x] |
347390
| file://:0:0:0:0 | self [str] | semmle.label | self [str] |
391+
| file://:0:0:0:0 | self [v2, some:0] | semmle.label | self [v2, some:0] |
392+
| file://:0:0:0:0 | self [v2] | semmle.label | self [v2] |
393+
| file://:0:0:0:0 | self [v3] | semmle.label | self [v3] |
348394
| file://:0:0:0:0 | self [x, some:0] | semmle.label | self [x, some:0] |
349395
| file://:0:0:0:0 | self [x] | semmle.label | self [x] |
350396
| file://:0:0:0:0 | value | semmle.label | value |
397+
| file://:0:0:0:0 | value | semmle.label | value |
398+
| file://:0:0:0:0 | value | semmle.label | value |
399+
| file://:0:0:0:0 | value [some:0] | semmle.label | value [some:0] |
351400
| file://:0:0:0:0 | value [some:0] | semmle.label | value [some:0] |
352401
| test.swift:6:19:6:26 | call to source() | semmle.label | call to source() |
353402
| test.swift:7:15:7:15 | t1 | semmle.label | t1 |
@@ -706,6 +755,33 @@ nodes
706755
| test.swift:693:17:693:24 | call to source() | semmle.label | call to source() |
707756
| test.swift:694:15:694:15 | arr6 [Array element] | semmle.label | arr6 [Array element] |
708757
| test.swift:694:15:694:21 | ...[...] | semmle.label | ...[...] |
758+
| test.swift:699:9:699:9 | self [v2, some:0] | semmle.label | self [v2, some:0] |
759+
| test.swift:699:9:699:9 | self [v2] | semmle.label | self [v2] |
760+
| test.swift:699:9:699:9 | value | semmle.label | value |
761+
| test.swift:699:9:699:9 | value [some:0] | semmle.label | value [some:0] |
762+
| test.swift:700:9:700:9 | self [v3] | semmle.label | self [v3] |
763+
| test.swift:700:9:700:9 | value | semmle.label | value |
764+
| test.swift:711:10:711:17 | call to source() | semmle.label | call to source() |
765+
| test.swift:711:10:711:17 | call to source() [some:0] | semmle.label | call to source() [some:0] |
766+
| test.swift:712:10:712:17 | call to source() | semmle.label | call to source() |
767+
| test.swift:714:5:714:5 | [post] mo1 [v2, some:0] | semmle.label | [post] mo1 [v2, some:0] |
768+
| test.swift:714:5:714:5 | [post] mo1 [v2] | semmle.label | [post] mo1 [v2] |
769+
| test.swift:714:14:714:21 | call to source() | semmle.label | call to source() |
770+
| test.swift:714:14:714:21 | call to source() [some:0] | semmle.label | call to source() [some:0] |
771+
| test.swift:715:5:715:5 | [post] mo1 [v3] | semmle.label | [post] mo1 [v3] |
772+
| test.swift:715:5:715:5 | mo1 [v2, some:0] | semmle.label | mo1 [v2, some:0] |
773+
| test.swift:715:5:715:5 | mo1 [v2] | semmle.label | mo1 [v2] |
774+
| test.swift:715:14:715:21 | call to source() | semmle.label | call to source() |
775+
| test.swift:721:15:721:15 | v2 [some:0] | semmle.label | v2 [some:0] |
776+
| test.swift:721:15:721:17 | ...! | semmle.label | ...! |
777+
| test.swift:722:15:722:15 | v3 | semmle.label | v3 |
778+
| test.swift:724:15:724:15 | mo1 [v2, some:0] | semmle.label | mo1 [v2, some:0] |
779+
| test.swift:724:15:724:15 | mo1 [v2] | semmle.label | mo1 [v2] |
780+
| test.swift:724:15:724:19 | .v2 | semmle.label | .v2 |
781+
| test.swift:724:15:724:19 | .v2 [some:0] | semmle.label | .v2 [some:0] |
782+
| test.swift:724:15:724:21 | ...! | semmle.label | ...! |
783+
| test.swift:725:15:725:15 | mo1 [v3] | semmle.label | mo1 [v3] |
784+
| test.swift:725:15:725:19 | .v3 | semmle.label | .v3 |
709785
subpaths
710786
| test.swift:75:22:75:22 | x | test.swift:65:16:65:28 | arg1 | test.swift:65:1:70:1 | arg2[return] | test.swift:75:32:75:32 | [post] y |
711787
| test.swift:114:19:114:19 | arg | test.swift:109:9:109:14 | arg | test.swift:110:12:110:12 | arg | test.swift:114:12:114:22 | call to ... |
@@ -747,6 +823,12 @@ subpaths
747823
| test.swift:622:18:622:18 | s [x] | test.swift:615:8:615:11 | s [x] | test.swift:615:3:617:3 | self[return] [s, x] | test.swift:622:12:622:19 | call to S2.init(s:) [s, x] |
748824
| test.swift:624:13:624:13 | s2 [s, x] | test.swift:623:11:623:17 | enter #keyPath(...) [s, x] | test.swift:623:11:623:17 | exit #keyPath(...) | test.swift:624:13:624:26 | \\...[...] |
749825
| test.swift:630:15:630:15 | array [Array element] | test.swift:629:13:629:22 | enter #keyPath(...) [Array element] | test.swift:629:13:629:22 | exit #keyPath(...) | test.swift:630:15:630:31 | \\...[...] |
826+
| test.swift:714:14:714:21 | call to source() | test.swift:699:9:699:9 | value | file://:0:0:0:0 | [post] self [v2] | test.swift:714:5:714:5 | [post] mo1 [v2] |
827+
| test.swift:714:14:714:21 | call to source() [some:0] | test.swift:699:9:699:9 | value [some:0] | file://:0:0:0:0 | [post] self [v2, some:0] | test.swift:714:5:714:5 | [post] mo1 [v2, some:0] |
828+
| test.swift:715:14:715:21 | call to source() | test.swift:700:9:700:9 | value | file://:0:0:0:0 | [post] self [v3] | test.swift:715:5:715:5 | [post] mo1 [v3] |
829+
| test.swift:724:15:724:15 | mo1 [v2, some:0] | test.swift:699:9:699:9 | self [v2, some:0] | file://:0:0:0:0 | .v2 [some:0] | test.swift:724:15:724:19 | .v2 [some:0] |
830+
| test.swift:724:15:724:15 | mo1 [v2] | test.swift:699:9:699:9 | self [v2] | file://:0:0:0:0 | .v2 | test.swift:724:15:724:19 | .v2 |
831+
| test.swift:725:15:725:15 | mo1 [v3] | test.swift:700:9:700:9 | self [v3] | file://:0:0:0:0 | .v3 | test.swift:725:15:725:19 | .v3 |
750832
#select
751833
| test.swift:7:15:7:15 | t1 | test.swift:6:19:6:26 | call to source() | test.swift:7:15:7:15 | t1 | result |
752834
| test.swift:9:15:9:15 | t1 | test.swift:6:19:6:26 | call to source() | test.swift:9:15:9:15 | t1 | result |
@@ -835,3 +917,7 @@ subpaths
835917
| test.swift:678:15:678:26 | ...[...] | test.swift:676:20:676:27 | call to source() | test.swift:678:15:678:26 | ...[...] | result |
836918
| test.swift:682:15:682:27 | ...[...] | test.swift:681:21:681:28 | call to source() | test.swift:682:15:682:27 | ...[...] | result |
837919
| test.swift:694:15:694:21 | ...[...] | test.swift:693:17:693:24 | call to source() | test.swift:694:15:694:21 | ...[...] | result |
920+
| test.swift:721:15:721:17 | ...! | test.swift:711:10:711:17 | call to source() | test.swift:721:15:721:17 | ...! | result |
921+
| test.swift:722:15:722:15 | v3 | test.swift:712:10:712:17 | call to source() | test.swift:722:15:722:15 | v3 | result |
922+
| test.swift:724:15:724:21 | ...! | test.swift:714:14:714:21 | call to source() | test.swift:724:15:724:21 | ...! | result |
923+
| test.swift:725:15:725:19 | .v3 | test.swift:715:14:715:21 | call to source() | test.swift:725:15:725:19 | .v3 | result |

swift/ql/test/library-tests/dataflow/dataflow/LocalFlow.expected

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,3 +811,67 @@
811811
| test.swift:693:5:693:5 | arr6 | test.swift:693:5:693:5 | &... |
812812
| test.swift:694:15:694:15 | [post] arr6 | test.swift:694:15:694:15 | &... |
813813
| test.swift:694:15:694:15 | arr6 | test.swift:694:15:694:15 | &... |
814+
| test.swift:697:8:697:8 | SSA def(self) | test.swift:697:8:697:8 | self[return] |
815+
| test.swift:697:8:697:8 | self | test.swift:697:8:697:8 | SSA def(self) |
816+
| test.swift:698:9:698:9 | self | test.swift:698:9:698:9 | SSA def(self) |
817+
| test.swift:698:9:698:9 | self | test.swift:698:9:698:9 | SSA def(self) |
818+
| test.swift:698:9:698:9 | self | test.swift:698:9:698:9 | SSA def(self) |
819+
| test.swift:698:9:698:9 | value | test.swift:698:9:698:9 | SSA def(value) |
820+
| test.swift:699:9:699:9 | self | test.swift:699:9:699:9 | SSA def(self) |
821+
| test.swift:699:9:699:9 | self | test.swift:699:9:699:9 | SSA def(self) |
822+
| test.swift:699:9:699:9 | self | test.swift:699:9:699:9 | SSA def(self) |
823+
| test.swift:699:9:699:9 | value | test.swift:699:9:699:9 | SSA def(value) |
824+
| test.swift:700:9:700:9 | self | test.swift:700:9:700:9 | SSA def(self) |
825+
| test.swift:700:9:700:9 | self | test.swift:700:9:700:9 | SSA def(self) |
826+
| test.swift:700:9:700:9 | self | test.swift:700:9:700:9 | SSA def(self) |
827+
| test.swift:700:9:700:9 | value | test.swift:700:9:700:9 | SSA def(value) |
828+
| test.swift:704:9:704:9 | SSA def(v1) | test.swift:710:5:710:5 | v1 |
829+
| test.swift:704:9:704:9 | v1 | test.swift:704:9:704:9 | SSA def(v1) |
830+
| test.swift:704:9:704:17 | ... as ... | test.swift:704:9:704:9 | v1 |
831+
| test.swift:704:21:704:21 | 0 | test.swift:704:9:704:17 | ... as ... |
832+
| test.swift:705:9:705:17 | ... as ... | test.swift:705:9:705:9 | v2 |
833+
| test.swift:705:21:705:21 | 0 | test.swift:705:9:705:17 | ... as ... |
834+
| test.swift:706:9:706:17 | ... as ... | test.swift:706:9:706:9 | v3 |
835+
| test.swift:706:21:706:21 | 0 | test.swift:706:9:706:17 | ... as ... |
836+
| test.swift:707:9:707:9 | SSA def(mo1) | test.swift:713:5:713:5 | mo1 |
837+
| test.swift:707:9:707:9 | mo1 | test.swift:707:9:707:9 | SSA def(mo1) |
838+
| test.swift:707:15:707:27 | call to MyOptionals.init() | test.swift:707:9:707:9 | mo1 |
839+
| test.swift:708:9:708:9 | SSA def(mo2) | test.swift:716:5:716:5 | mo2 |
840+
| test.swift:708:9:708:9 | mo2 | test.swift:708:9:708:9 | SSA def(mo2) |
841+
| test.swift:708:9:708:26 | ... as ... | test.swift:708:9:708:9 | mo2 |
842+
| test.swift:708:30:708:42 | call to MyOptionals.init() | test.swift:708:9:708:26 | ... as ... |
843+
| test.swift:710:5:710:5 | v1 | test.swift:710:5:710:7 | ...! |
844+
| test.swift:710:5:710:5 | v1 | test.swift:720:15:720:15 | v1 |
845+
| test.swift:711:5:711:17 | SSA def(v2) | test.swift:721:15:721:15 | v2 |
846+
| test.swift:711:10:711:17 | call to source() | test.swift:711:5:711:17 | SSA def(v2) |
847+
| test.swift:712:5:712:17 | SSA def(v3) | test.swift:722:15:722:15 | v3 |
848+
| test.swift:712:10:712:17 | call to source() | test.swift:712:5:712:17 | SSA def(v3) |
849+
| test.swift:713:5:713:5 | [post] mo1 | test.swift:714:5:714:5 | mo1 |
850+
| test.swift:713:5:713:5 | mo1 | test.swift:714:5:714:5 | mo1 |
851+
| test.swift:713:5:713:9 | .v1 | test.swift:713:5:713:11 | ...! |
852+
| test.swift:714:5:714:5 | [post] mo1 | test.swift:715:5:715:5 | mo1 |
853+
| test.swift:714:5:714:5 | mo1 | test.swift:715:5:715:5 | mo1 |
854+
| test.swift:715:5:715:5 | [post] mo1 | test.swift:723:15:723:15 | mo1 |
855+
| test.swift:715:5:715:5 | mo1 | test.swift:723:15:723:15 | mo1 |
856+
| test.swift:716:5:716:5 | mo2 | test.swift:716:5:716:8 | ...! |
857+
| test.swift:716:5:716:5 | mo2 | test.swift:717:5:717:5 | mo2 |
858+
| test.swift:716:5:716:10 | .v1 | test.swift:716:5:716:12 | ...! |
859+
| test.swift:717:5:717:5 | mo2 | test.swift:717:5:717:8 | ...! |
860+
| test.swift:717:5:717:5 | mo2 | test.swift:718:5:718:5 | mo2 |
861+
| test.swift:718:5:718:5 | mo2 | test.swift:718:5:718:8 | ...! |
862+
| test.swift:718:5:718:5 | mo2 | test.swift:726:15:726:15 | mo2 |
863+
| test.swift:720:15:720:15 | v1 | test.swift:720:15:720:17 | ...! |
864+
| test.swift:721:15:721:15 | v2 | test.swift:721:15:721:17 | ...! |
865+
| test.swift:723:15:723:15 | [post] mo1 | test.swift:724:15:724:15 | mo1 |
866+
| test.swift:723:15:723:15 | mo1 | test.swift:724:15:724:15 | mo1 |
867+
| test.swift:723:15:723:19 | .v1 | test.swift:723:15:723:21 | ...! |
868+
| test.swift:724:15:724:15 | [post] mo1 | test.swift:725:15:725:15 | mo1 |
869+
| test.swift:724:15:724:15 | mo1 | test.swift:725:15:725:15 | mo1 |
870+
| test.swift:724:15:724:19 | .v2 | test.swift:724:15:724:21 | ...! |
871+
| test.swift:726:15:726:15 | mo2 | test.swift:726:15:726:18 | ...! |
872+
| test.swift:726:15:726:15 | mo2 | test.swift:727:15:727:15 | mo2 |
873+
| test.swift:726:15:726:20 | .v1 | test.swift:726:15:726:22 | ...! |
874+
| test.swift:727:15:727:15 | mo2 | test.swift:727:15:727:18 | ...! |
875+
| test.swift:727:15:727:15 | mo2 | test.swift:728:15:728:15 | mo2 |
876+
| test.swift:727:15:727:20 | .v2 | test.swift:727:15:727:22 | ...! |
877+
| test.swift:728:15:728:15 | mo2 | test.swift:728:15:728:18 | ...! |

swift/ql/test/library-tests/dataflow/dataflow/test.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,3 +693,37 @@ func testArray() {
693693
arr6.insert(source(), at: 2)
694694
sink(arg: arr6[0]) // $ flow=693
695695
}
696+
697+
struct MyOptionals {
698+
var v1 : Int? = 0
699+
var v2 : Int? = 0
700+
var v3 : Int! = 0
701+
}
702+
703+
func testWriteOptional() {
704+
var v1 : Int? = 0
705+
var v2 : Int? = 0
706+
var v3 : Int! = 0
707+
var mo1 = MyOptionals()
708+
var mo2 : MyOptionals! = MyOptionals()
709+
710+
v1! = source()
711+
v2 = source()
712+
v3 = source()
713+
mo1.v1! = source()
714+
mo1.v2 = source()
715+
mo1.v3 = source()
716+
mo2!.v1! = source()
717+
mo2!.v2 = source()
718+
mo2!.v3 = source()
719+
720+
sink(arg: v1!) // $ MISSING:flow=710
721+
sink(arg: v2!) // $ flow=711
722+
sink(arg: v3) // $ flow=712
723+
sink(arg: mo1.v1!) // $ MISSING:flow=713
724+
sink(arg: mo1.v2!) // $ flow=714
725+
sink(arg: mo1.v3) // $ flow=715
726+
sink(arg: mo2!.v1!) // $ MISSING:flow=716
727+
sink(arg: mo2!.v2!) // $ MISSING:flow=717
728+
sink(arg: mo2!.v3) // $ MISSING:flow=718
729+
}

0 commit comments

Comments
 (0)