Skip to content

Commit ec99977

Browse files
committed
Swift: add test for assignment to nested arrays
1 parent 883543f commit ec99977

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ edges
292292
| test.swift:647:15:647:15 | &... [Array element, Array element] | test.swift:647:15:647:23 | ...[...] [Array element] |
293293
| test.swift:647:15:647:23 | &... [Array element] | test.swift:647:15:647:26 | ...[...] |
294294
| test.swift:647:15:647:23 | ...[...] [Array element] | test.swift:647:15:647:23 | &... [Array element] |
295-
| test.swift:658:5:658:5 | [post] &... [Array element] | test.swift:659:15:659:15 | &... [Array element] |
296-
| test.swift:658:17:658:24 | call to source() | test.swift:658:5:658:5 | [post] &... [Array element] |
297-
| test.swift:659:15:659:15 | &... [Array element] | test.swift:659:15:659:21 | ...[...] |
295+
| test.swift:662:5:662:5 | [post] &... [Array element] | test.swift:663:15:663:15 | &... [Array element] |
296+
| test.swift:662:17:662:24 | call to source() | test.swift:662:5:662:5 | [post] &... [Array element] |
297+
| test.swift:663:15:663:15 | &... [Array element] | test.swift:663:15:663:21 | ...[...] |
298298
nodes
299299
| file://:0:0:0:0 | .a [x] | semmle.label | .a [x] |
300300
| file://:0:0:0:0 | .str | semmle.label | .str |
@@ -617,10 +617,10 @@ nodes
617617
| test.swift:647:15:647:23 | &... [Array element] | semmle.label | &... [Array element] |
618618
| test.swift:647:15:647:23 | ...[...] [Array element] | semmle.label | ...[...] [Array element] |
619619
| test.swift:647:15:647:26 | ...[...] | semmle.label | ...[...] |
620-
| test.swift:658:5:658:5 | [post] &... [Array element] | semmle.label | [post] &... [Array element] |
621-
| test.swift:658:17:658:24 | call to source() | semmle.label | call to source() |
622-
| test.swift:659:15:659:15 | &... [Array element] | semmle.label | &... [Array element] |
623-
| test.swift:659:15:659:21 | ...[...] | semmle.label | ...[...] |
620+
| test.swift:662:5:662:5 | [post] &... [Array element] | semmle.label | [post] &... [Array element] |
621+
| test.swift:662:17:662:24 | call to source() | semmle.label | call to source() |
622+
| test.swift:663:15:663:15 | &... [Array element] | semmle.label | &... [Array element] |
623+
| test.swift:663:15:663:21 | ...[...] | semmle.label | ...[...] |
624624
subpaths
625625
| test.swift:75:21:75:22 | &... | test.swift:65:16:65:28 | arg1 | test.swift:65:1:70:1 | arg2[return] | test.swift:75:31:75:32 | [post] &... |
626626
| 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 ... |
@@ -740,4 +740,4 @@ subpaths
740740
| test.swift:639:15:639:21 | ...[...] | test.swift:638:15:638:22 | call to source() | test.swift:639:15:639:21 | ...[...] | result |
741741
| test.swift:643:15:643:21 | ...[...] | test.swift:642:17:642:24 | call to source() | test.swift:643:15:643:21 | ...[...] | result |
742742
| test.swift:647:15:647:26 | ...[...] | test.swift:645:20:645:27 | call to source() | test.swift:647:15:647:26 | ...[...] | result |
743-
| test.swift:659:15:659:21 | ...[...] | test.swift:658:17:658:24 | call to source() | test.swift:659:15:659:21 | ...[...] | result |
743+
| test.swift:663:15:663:21 | ...[...] | test.swift:662:17:662:24 | call to source() | test.swift:663:15:663:21 | ...[...] | result |

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

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,8 @@
700700
| test.swift:642:9:642:9 | SSA def(arr2) | test.swift:643:15:643:15 | arr2 |
701701
| test.swift:642:9:642:9 | arr2 | test.swift:642:9:642:9 | SSA def(arr2) |
702702
| test.swift:642:16:642:25 | [...] | test.swift:642:9:642:9 | arr2 |
703-
| test.swift:643:15:643:15 | &... | test.swift:650:16:650:16 | arr2 |
704-
| test.swift:643:15:643:15 | [post] &... | test.swift:650:16:650:16 | arr2 |
703+
| test.swift:643:15:643:15 | &... | test.swift:654:16:654:16 | arr2 |
704+
| test.swift:643:15:643:15 | [post] &... | test.swift:654:16:654:16 | arr2 |
705705
| test.swift:643:15:643:15 | arr2 | test.swift:643:15:643:15 | &... |
706706
| test.swift:645:9:645:9 | SSA def(matrix) | test.swift:646:15:646:15 | matrix |
707707
| test.swift:645:9:645:9 | matrix | test.swift:645:9:645:9 | SSA def(matrix) |
@@ -711,23 +711,32 @@
711711
| test.swift:646:15:646:15 | matrix | test.swift:646:15:646:15 | &... |
712712
| test.swift:647:15:647:15 | matrix | test.swift:647:15:647:15 | &... |
713713
| test.swift:647:15:647:23 | ...[...] | test.swift:647:15:647:23 | &... |
714-
| test.swift:649:9:649:9 | SSA def(arr3) | test.swift:650:23:650:23 | arr3 |
715-
| test.swift:649:9:649:9 | arr3 | test.swift:649:9:649:9 | SSA def(arr3) |
716-
| test.swift:649:16:649:18 | [...] | test.swift:649:9:649:9 | arr3 |
717-
| test.swift:650:9:650:9 | SSA def(arr4) | test.swift:652:15:652:15 | arr4 |
718-
| test.swift:650:9:650:9 | arr4 | test.swift:650:9:650:9 | SSA def(arr4) |
719-
| test.swift:650:16:650:23 | ... .+(_:_:) ... | test.swift:650:9:650:9 | arr4 |
720-
| test.swift:650:23:650:23 | arr3 | test.swift:651:15:651:15 | arr3 |
721-
| test.swift:651:15:651:15 | arr3 | test.swift:651:15:651:15 | &... |
722-
| test.swift:652:15:652:15 | arr4 | test.swift:652:15:652:15 | &... |
723-
| test.swift:654:9:654:9 | SSA def(arr5) | test.swift:655:15:655:15 | arr5 |
724-
| test.swift:654:9:654:9 | arr5 | test.swift:654:9:654:9 | SSA def(arr5) |
725-
| test.swift:654:16:654:51 | call to Array<Element>.init(repeating:count:) | test.swift:654:9:654:9 | arr5 |
726-
| test.swift:655:15:655:15 | arr5 | test.swift:655:15:655:15 | &... |
727-
| test.swift:657:9:657:9 | SSA def(arr6) | test.swift:658:5:658:5 | arr6 |
728-
| test.swift:657:9:657:9 | arr6 | test.swift:657:9:657:9 | SSA def(arr6) |
729-
| test.swift:657:16:657:22 | [...] | test.swift:657:9:657:9 | arr6 |
730-
| test.swift:658:5:658:5 | &... | test.swift:659:15:659:15 | arr6 |
731-
| test.swift:658:5:658:5 | [post] &... | test.swift:659:15:659:15 | arr6 |
732-
| test.swift:658:5:658:5 | arr6 | test.swift:658:5:658:5 | &... |
733-
| test.swift:659:15:659:15 | arr6 | test.swift:659:15:659:15 | &... |
714+
| test.swift:649:9:649:9 | SSA def(matrix2) | test.swift:650:5:650:5 | matrix2 |
715+
| test.swift:649:9:649:9 | matrix2 | test.swift:649:9:649:9 | SSA def(matrix2) |
716+
| test.swift:649:19:649:23 | [...] | test.swift:649:9:649:9 | matrix2 |
717+
| test.swift:650:5:650:5 | &... | test.swift:651:15:651:15 | matrix2 |
718+
| test.swift:650:5:650:5 | [post] &... | test.swift:651:15:651:15 | matrix2 |
719+
| test.swift:650:5:650:5 | matrix2 | test.swift:650:5:650:5 | &... |
720+
| test.swift:650:5:650:14 | ...[...] | test.swift:650:5:650:14 | &... |
721+
| test.swift:651:15:651:15 | matrix2 | test.swift:651:15:651:15 | &... |
722+
| test.swift:651:15:651:24 | ...[...] | test.swift:651:15:651:24 | &... |
723+
| test.swift:653:9:653:9 | SSA def(arr3) | test.swift:654:23:654:23 | arr3 |
724+
| test.swift:653:9:653:9 | arr3 | test.swift:653:9:653:9 | SSA def(arr3) |
725+
| test.swift:653:16:653:18 | [...] | test.swift:653:9:653:9 | arr3 |
726+
| test.swift:654:9:654:9 | SSA def(arr4) | test.swift:656:15:656:15 | arr4 |
727+
| test.swift:654:9:654:9 | arr4 | test.swift:654:9:654:9 | SSA def(arr4) |
728+
| test.swift:654:16:654:23 | ... .+(_:_:) ... | test.swift:654:9:654:9 | arr4 |
729+
| test.swift:654:23:654:23 | arr3 | test.swift:655:15:655:15 | arr3 |
730+
| test.swift:655:15:655:15 | arr3 | test.swift:655:15:655:15 | &... |
731+
| test.swift:656:15:656:15 | arr4 | test.swift:656:15:656:15 | &... |
732+
| test.swift:658:9:658:9 | SSA def(arr5) | test.swift:659:15:659:15 | arr5 |
733+
| test.swift:658:9:658:9 | arr5 | test.swift:658:9:658:9 | SSA def(arr5) |
734+
| test.swift:658:16:658:51 | call to Array<Element>.init(repeating:count:) | test.swift:658:9:658:9 | arr5 |
735+
| test.swift:659:15:659:15 | arr5 | test.swift:659:15:659:15 | &... |
736+
| test.swift:661:9:661:9 | SSA def(arr6) | test.swift:662:5:662:5 | arr6 |
737+
| test.swift:661:9:661:9 | arr6 | test.swift:661:9:661:9 | SSA def(arr6) |
738+
| test.swift:661:16:661:22 | [...] | test.swift:661:9:661:9 | arr6 |
739+
| test.swift:662:5:662:5 | &... | test.swift:663:15:663:15 | arr6 |
740+
| test.swift:662:5:662:5 | [post] &... | test.swift:663:15:663:15 | arr6 |
741+
| test.swift:662:5:662:5 | arr6 | test.swift:662:5:662:5 | &... |
742+
| test.swift:663:15:663:15 | arr6 | test.swift:663:15:663:15 | &... |

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,15 +646,19 @@ func testArray() {
646646
sink(arg: matrix[0])
647647
sink(arg: matrix[0][0]) // $ flow=645
648648

649+
var matrix2 = [[1]]
650+
matrix2[0][0] = source()
651+
sink(arg: matrix2[0][0]) // $ MISSING: flow=650
652+
649653
var arr3 = [1]
650654
var arr4 = arr2 + arr3
651655
sink(arg: arr3[0])
652656
sink(arg: arr4[0]) // $ MISSING: flow=642
653657

654658
var arr5 = Array(repeating: source(), count: 2)
655-
sink(arg: arr5[0]) // $ MISSING: flow=654
659+
sink(arg: arr5[0]) // $ MISSING: flow=658
656660

657661
var arr6 = [1,2,3]
658662
arr6.insert(source(), at: 2)
659-
sink(arg: arr6[0]) // $ flow=658
663+
sink(arg: arr6[0]) // $ flow=662
660664
}

0 commit comments

Comments
 (0)