Skip to content

Commit c18de7d

Browse files
authored
Merge pull request github#14036 from geoffw0/quicktest
Swift: Additional dataflow test
2 parents aaaf6f8 + fc69be4 commit c18de7d

File tree

3 files changed

+126
-0
lines changed

3 files changed

+126
-0
lines changed

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

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ edges
55
| file://:0:0:0:0 | self [v2, some:0] | file://:0:0:0:0 | .v2 [some:0] |
66
| file://:0:0:0:0 | self [v2] | file://:0:0:0:0 | .v2 |
77
| file://:0:0:0:0 | self [v3] | file://:0:0:0:0 | .v3 |
8+
| file://:0:0:0:0 | self [v] | file://:0:0:0:0 | .v |
89
| file://:0:0:0:0 | self [x, some:0] | file://:0:0:0:0 | .x [some:0] |
910
| file://:0:0:0:0 | self [x] | file://:0:0:0:0 | .x |
1011
| file://:0:0:0:0 | value | file://:0:0:0:0 | [post] self [v2] |
1112
| file://:0:0:0:0 | value | file://:0:0:0:0 | [post] self [v3] |
13+
| file://:0:0:0:0 | value | file://:0:0:0:0 | [post] self [v] |
1214
| file://:0:0:0:0 | value | file://:0:0:0:0 | [post] self [x] |
1315
| file://:0:0:0:0 | value [some:0] | file://:0:0:0:0 | [post] self [v2, some:0] |
1416
| file://:0:0:0:0 | value [some:0] | file://:0:0:0:0 | [post] self [x, some:0] |
@@ -481,9 +483,34 @@ edges
481483
| test.swift:803:15:803:15 | dict4 [Collection element, Tuple element at index 1] | test.swift:803:15:803:35 | call to randomElement() [some:0, Tuple element at index 1] |
482484
| test.swift:803:15:803:35 | call to randomElement() [some:0, Tuple element at index 1] | test.swift:803:15:803:36 | ...! [Tuple element at index 1] |
483485
| test.swift:803:15:803:36 | ...! [Tuple element at index 1] | test.swift:803:15:803:38 | .1 |
486+
| test.swift:809:8:809:13 | v | test.swift:810:14:810:14 | v |
487+
| test.swift:810:5:810:5 | [post] self [v] | test.swift:809:3:811:3 | self[return] [v] |
488+
| test.swift:810:14:810:14 | v | test.swift:810:5:810:5 | [post] self [v] |
489+
| test.swift:813:8:813:8 | self [v] | test.swift:813:31:813:31 | self [v] |
490+
| test.swift:813:31:813:31 | self [v] | test.swift:813:31:813:31 | .v |
491+
| test.swift:813:31:813:31 | self [v] | test.swift:815:7:815:7 | self [v] |
492+
| test.swift:815:7:815:7 | self [v] | file://:0:0:0:0 | self [v] |
493+
| test.swift:815:7:815:7 | value | file://:0:0:0:0 | value |
494+
| test.swift:819:14:819:25 | call to S3.init(_:) [v] | test.swift:822:15:822:15 | s1 [v] |
495+
| test.swift:819:14:819:25 | call to S3.init(_:) [v] | test.swift:824:15:824:15 | s1 [v] |
496+
| test.swift:819:17:819:24 | call to source() | test.swift:809:8:809:13 | v |
497+
| test.swift:819:17:819:24 | call to source() | test.swift:819:14:819:25 | call to S3.init(_:) [v] |
498+
| test.swift:822:15:822:15 | s1 [v] | test.swift:815:7:815:7 | self [v] |
499+
| test.swift:822:15:822:15 | s1 [v] | test.swift:822:15:822:18 | .v |
500+
| test.swift:824:15:824:15 | s1 [v] | test.swift:813:8:813:8 | self [v] |
501+
| test.swift:824:15:824:15 | s1 [v] | test.swift:824:15:824:23 | call to getv() |
502+
| test.swift:828:5:828:5 | [post] s2 [v] | test.swift:831:15:831:15 | s2 [v] |
503+
| test.swift:828:5:828:5 | [post] s2 [v] | test.swift:833:15:833:15 | s2 [v] |
504+
| test.swift:828:12:828:19 | call to source() | test.swift:815:7:815:7 | value |
505+
| test.swift:828:12:828:19 | call to source() | test.swift:828:5:828:5 | [post] s2 [v] |
506+
| test.swift:831:15:831:15 | s2 [v] | test.swift:815:7:815:7 | self [v] |
507+
| test.swift:831:15:831:15 | s2 [v] | test.swift:831:15:831:18 | .v |
508+
| test.swift:833:15:833:15 | s2 [v] | test.swift:813:8:813:8 | self [v] |
509+
| test.swift:833:15:833:15 | s2 [v] | test.swift:833:15:833:23 | call to getv() |
484510
nodes
485511
| file://:0:0:0:0 | .a [x] | semmle.label | .a [x] |
486512
| file://:0:0:0:0 | .str | semmle.label | .str |
513+
| file://:0:0:0:0 | .v | semmle.label | .v |
487514
| file://:0:0:0:0 | .v2 | semmle.label | .v2 |
488515
| file://:0:0:0:0 | .v2 [some:0] | semmle.label | .v2 [some:0] |
489516
| file://:0:0:0:0 | .v3 | semmle.label | .v3 |
@@ -493,18 +520,21 @@ nodes
493520
| file://:0:0:0:0 | [post] self [v2, some:0] | semmle.label | [post] self [v2, some:0] |
494521
| file://:0:0:0:0 | [post] self [v2] | semmle.label | [post] self [v2] |
495522
| file://:0:0:0:0 | [post] self [v3] | semmle.label | [post] self [v3] |
523+
| file://:0:0:0:0 | [post] self [v] | semmle.label | [post] self [v] |
496524
| file://:0:0:0:0 | [post] self [x, some:0] | semmle.label | [post] self [x, some:0] |
497525
| file://:0:0:0:0 | [post] self [x] | semmle.label | [post] self [x] |
498526
| file://:0:0:0:0 | self [a, x] | semmle.label | self [a, x] |
499527
| file://:0:0:0:0 | self [str] | semmle.label | self [str] |
500528
| file://:0:0:0:0 | self [v2, some:0] | semmle.label | self [v2, some:0] |
501529
| file://:0:0:0:0 | self [v2] | semmle.label | self [v2] |
502530
| file://:0:0:0:0 | self [v3] | semmle.label | self [v3] |
531+
| file://:0:0:0:0 | self [v] | semmle.label | self [v] |
503532
| file://:0:0:0:0 | self [x, some:0] | semmle.label | self [x, some:0] |
504533
| file://:0:0:0:0 | self [x] | semmle.label | self [x] |
505534
| file://:0:0:0:0 | value | semmle.label | value |
506535
| file://:0:0:0:0 | value | semmle.label | value |
507536
| file://:0:0:0:0 | value | semmle.label | value |
537+
| file://:0:0:0:0 | value | semmle.label | value |
508538
| file://:0:0:0:0 | value [some:0] | semmle.label | value [some:0] |
509539
| file://:0:0:0:0 | value [some:0] | semmle.label | value [some:0] |
510540
| test.swift:6:19:6:26 | call to source() | semmle.label | call to source() |
@@ -1005,6 +1035,27 @@ nodes
10051035
| test.swift:803:15:803:35 | call to randomElement() [some:0, Tuple element at index 1] | semmle.label | call to randomElement() [some:0, Tuple element at index 1] |
10061036
| test.swift:803:15:803:36 | ...! [Tuple element at index 1] | semmle.label | ...! [Tuple element at index 1] |
10071037
| test.swift:803:15:803:38 | .1 | semmle.label | .1 |
1038+
| test.swift:809:3:811:3 | self[return] [v] | semmle.label | self[return] [v] |
1039+
| test.swift:809:8:809:13 | v | semmle.label | v |
1040+
| test.swift:810:5:810:5 | [post] self [v] | semmle.label | [post] self [v] |
1041+
| test.swift:810:14:810:14 | v | semmle.label | v |
1042+
| test.swift:813:8:813:8 | self [v] | semmle.label | self [v] |
1043+
| test.swift:813:31:813:31 | .v | semmle.label | .v |
1044+
| test.swift:813:31:813:31 | self [v] | semmle.label | self [v] |
1045+
| test.swift:815:7:815:7 | self [v] | semmle.label | self [v] |
1046+
| test.swift:815:7:815:7 | value | semmle.label | value |
1047+
| test.swift:819:14:819:25 | call to S3.init(_:) [v] | semmle.label | call to S3.init(_:) [v] |
1048+
| test.swift:819:17:819:24 | call to source() | semmle.label | call to source() |
1049+
| test.swift:822:15:822:15 | s1 [v] | semmle.label | s1 [v] |
1050+
| test.swift:822:15:822:18 | .v | semmle.label | .v |
1051+
| test.swift:824:15:824:15 | s1 [v] | semmle.label | s1 [v] |
1052+
| test.swift:824:15:824:23 | call to getv() | semmle.label | call to getv() |
1053+
| test.swift:828:5:828:5 | [post] s2 [v] | semmle.label | [post] s2 [v] |
1054+
| test.swift:828:12:828:19 | call to source() | semmle.label | call to source() |
1055+
| test.swift:831:15:831:15 | s2 [v] | semmle.label | s2 [v] |
1056+
| test.swift:831:15:831:18 | .v | semmle.label | .v |
1057+
| test.swift:833:15:833:15 | s2 [v] | semmle.label | s2 [v] |
1058+
| test.swift:833:15:833:23 | call to getv() | semmle.label | call to getv() |
10081059
subpaths
10091060
| 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 |
10101061
| 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 ... |
@@ -1059,6 +1110,13 @@ subpaths
10591110
| test.swift:764:18:764:25 | call to source() | test.swift:617:8:617:11 | x | test.swift:617:3:619:3 | self[return] [x] | test.swift:764:13:764:26 | call to S.init(x:) [x] |
10601111
| test.swift:765:29:765:29 | s [some:0, x] | test.swift:655:8:655:12 | s [some:0, x] | test.swift:655:3:657:3 | self[return] [s, some:0, x] | test.swift:765:14:765:30 | call to S2_Optional.init(s:) [s, some:0, x] |
10611112
| test.swift:767:15:767:15 | s2 [s, some:0, x] | test.swift:766:13:766:29 | enter #keyPath(...) [s, some:0, x] | test.swift:766:13:766:29 | exit #keyPath(...) | test.swift:767:15:767:28 | \\...[...] |
1113+
| test.swift:813:31:813:31 | self [v] | test.swift:815:7:815:7 | self [v] | file://:0:0:0:0 | .v | test.swift:813:31:813:31 | .v |
1114+
| test.swift:819:17:819:24 | call to source() | test.swift:809:8:809:13 | v | test.swift:809:3:811:3 | self[return] [v] | test.swift:819:14:819:25 | call to S3.init(_:) [v] |
1115+
| test.swift:822:15:822:15 | s1 [v] | test.swift:815:7:815:7 | self [v] | file://:0:0:0:0 | .v | test.swift:822:15:822:18 | .v |
1116+
| test.swift:824:15:824:15 | s1 [v] | test.swift:813:8:813:8 | self [v] | test.swift:813:31:813:31 | .v | test.swift:824:15:824:23 | call to getv() |
1117+
| test.swift:828:12:828:19 | call to source() | test.swift:815:7:815:7 | value | file://:0:0:0:0 | [post] self [v] | test.swift:828:5:828:5 | [post] s2 [v] |
1118+
| test.swift:831:15:831:15 | s2 [v] | test.swift:815:7:815:7 | self [v] | file://:0:0:0:0 | .v | test.swift:831:15:831:18 | .v |
1119+
| test.swift:833:15:833:15 | s2 [v] | test.swift:813:8:813:8 | self [v] | test.swift:813:31:813:31 | .v | test.swift:833:15:833:23 | call to getv() |
10621120
#select
10631121
| test.swift:7:15:7:15 | t1 | test.swift:6:19:6:26 | call to source() | test.swift:7:15:7:15 | t1 | result |
10641122
| test.swift:9:15:9:15 | t1 | test.swift:6:19:6:26 | call to source() | test.swift:9:15:9:15 | t1 | result |
@@ -1169,3 +1227,7 @@ subpaths
11691227
| test.swift:802:15:802:38 | .0 | test.swift:800:44:800:51 | call to source() | test.swift:802:15:802:38 | .0 | result |
11701228
| test.swift:803:15:803:38 | .1 | test.swift:799:20:799:27 | call to source() | test.swift:803:15:803:38 | .1 | result |
11711229
| test.swift:803:15:803:38 | .1 | test.swift:801:33:801:40 | call to source() | test.swift:803:15:803:38 | .1 | result |
1230+
| test.swift:822:15:822:18 | .v | test.swift:819:17:819:24 | call to source() | test.swift:822:15:822:18 | .v | result |
1231+
| test.swift:824:15:824:23 | call to getv() | test.swift:819:17:819:24 | call to source() | test.swift:824:15:824:23 | call to getv() | result |
1232+
| test.swift:831:15:831:18 | .v | test.swift:828:12:828:19 | call to source() | test.swift:831:15:831:18 | .v | result |
1233+
| test.swift:833:15:833:23 | call to getv() | test.swift:828:12:828:19 | call to source() | test.swift:833:15:833:23 | call to getv() | result |

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,3 +983,39 @@
983983
| test.swift:803:15:803:35 | call to randomElement() | test.swift:803:15:803:36 | ...! |
984984
| test.swift:804:15:804:15 | [post] dict4 | test.swift:805:15:805:15 | dict4 |
985985
| test.swift:804:15:804:15 | dict4 | test.swift:805:15:805:15 | dict4 |
986+
| test.swift:809:3:809:3 | SSA def(self) | test.swift:810:5:810:5 | self |
987+
| test.swift:809:3:809:3 | self | test.swift:809:3:809:3 | SSA def(self) |
988+
| test.swift:809:8:809:13 | SSA def(v) | test.swift:810:14:810:14 | v |
989+
| test.swift:809:8:809:13 | v | test.swift:809:8:809:13 | SSA def(v) |
990+
| test.swift:810:5:810:5 | [post] self | test.swift:809:3:811:3 | self[return] |
991+
| test.swift:810:5:810:5 | self | test.swift:809:3:811:3 | self[return] |
992+
| test.swift:813:8:813:8 | SSA def(self) | test.swift:813:31:813:31 | self |
993+
| test.swift:813:8:813:8 | self | test.swift:813:8:813:8 | SSA def(self) |
994+
| test.swift:813:31:813:31 | [post] self | test.swift:813:3:813:33 | self[return] |
995+
| test.swift:813:31:813:31 | self | test.swift:813:3:813:33 | self[return] |
996+
| test.swift:815:7:815:7 | self | test.swift:815:7:815:7 | SSA def(self) |
997+
| test.swift:815:7:815:7 | self | test.swift:815:7:815:7 | SSA def(self) |
998+
| test.swift:815:7:815:7 | self | test.swift:815:7:815:7 | SSA def(self) |
999+
| test.swift:815:7:815:7 | value | test.swift:815:7:815:7 | SSA def(value) |
1000+
| test.swift:819:9:819:9 | SSA def(s1) | test.swift:822:15:822:15 | s1 |
1001+
| test.swift:819:9:819:9 | s1 | test.swift:819:9:819:9 | SSA def(s1) |
1002+
| test.swift:819:14:819:25 | call to S3.init(_:) | test.swift:819:9:819:9 | s1 |
1003+
| test.swift:820:9:820:9 | SSA def(s2) | test.swift:823:15:823:15 | s2 |
1004+
| test.swift:820:9:820:9 | s2 | test.swift:820:9:820:9 | SSA def(s2) |
1005+
| test.swift:820:14:820:18 | call to S3.init(_:) | test.swift:820:9:820:9 | s2 |
1006+
| test.swift:822:15:822:15 | [post] s1 | test.swift:824:15:824:15 | s1 |
1007+
| test.swift:822:15:822:15 | s1 | test.swift:824:15:824:15 | s1 |
1008+
| test.swift:823:15:823:15 | [post] s2 | test.swift:825:15:825:15 | s2 |
1009+
| test.swift:823:15:823:15 | s2 | test.swift:825:15:825:15 | s2 |
1010+
| test.swift:824:15:824:15 | [post] s1 | test.swift:827:5:827:5 | s1 |
1011+
| test.swift:824:15:824:15 | s1 | test.swift:827:5:827:5 | s1 |
1012+
| test.swift:825:15:825:15 | [post] s2 | test.swift:828:5:828:5 | s2 |
1013+
| test.swift:825:15:825:15 | s2 | test.swift:828:5:828:5 | s2 |
1014+
| test.swift:827:5:827:5 | [post] s1 | test.swift:830:15:830:15 | s1 |
1015+
| test.swift:827:5:827:5 | s1 | test.swift:830:15:830:15 | s1 |
1016+
| test.swift:828:5:828:5 | [post] s2 | test.swift:831:15:831:15 | s2 |
1017+
| test.swift:828:5:828:5 | s2 | test.swift:831:15:831:15 | s2 |
1018+
| test.swift:830:15:830:15 | [post] s1 | test.swift:832:15:832:15 | s1 |
1019+
| test.swift:830:15:830:15 | s1 | test.swift:832:15:832:15 | s1 |
1020+
| test.swift:831:15:831:15 | [post] s2 | test.swift:833:15:833:15 | s2 |
1021+
| test.swift:831:15:831:15 | s2 | test.swift:833:15:833:15 | s2 |

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,3 +804,31 @@ func testDictionary() {
804804
sink(arg: dict4.keys.randomElement()) // $ MISSING: flow=800
805805
sink(arg: dict4.values.randomElement()) // $ MISSING: flow=799 flow=801
806806
}
807+
808+
struct S3 {
809+
init(_ v: Int) {
810+
self.v = v
811+
}
812+
813+
func getv() -> Int { return v }
814+
815+
var v: Int
816+
}
817+
818+
func testStruct() {
819+
var s1 = S3(source())
820+
var s2 = S3(0)
821+
822+
sink(arg: s1.v) // $ flow=819
823+
sink(arg: s2.v)
824+
sink(arg: s1.getv()) // $ flow=819
825+
sink(arg: s2.getv())
826+
827+
s1.v = 0
828+
s2.v = source()
829+
830+
sink(arg: s1.v)
831+
sink(arg: s2.v) // $ flow=828
832+
sink(arg: s1.getv())
833+
sink(arg: s2.getv()) // $ flow=828
834+
}

0 commit comments

Comments
 (0)