Skip to content

Commit 14b70b8

Browse files
authored
Merge pull request github#18143 from geoffw0/swift6models3
Swift: Fix makeIterator() models
2 parents 8bcc5f4 + 23ed48e commit 14b70b8

File tree

9 files changed

+219
-5
lines changed

9 files changed

+219
-5
lines changed

swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Array.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ private class ArraySummaries extends SummaryModelCsv {
3636
";Array;true;withUnsafeMutableBytes(_:);;;Argument[-1].CollectionElement;Argument[0].Parameter[0].CollectionElement;taint",
3737
";Array;true;withUnsafeMutableBytes(_:);;;Argument[0].Parameter[0].CollectionElement;Argument[-1].CollectionElement;taint",
3838
";Array;true;withUnsafeMutableBytes(_:);;;Argument[0].ReturnValue;ReturnValue;value",
39+
";Array;true;makeIterator();;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
3940
";ContiguousArray;true;withUnsafeBufferPointer(_:);;;Argument[-1];Argument[0].Parameter[0].CollectionElement;taint",
4041
";ContiguousArray;true;withUnsafeBufferPointer(_:);;;Argument[-1].CollectionElement;Argument[0].Parameter[0].CollectionElement;value",
4142
";ContiguousArray;true;withUnsafeBufferPointer(_:);;;Argument[0].ReturnValue;ReturnValue;value",

swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Collection.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ private class CollectionSummaries extends SummaryModelCsv {
4444
";Collection;true;trimmingPrefix(_:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
4545
";Collection;true;trimmingPrefix(while:);;;Argument[-1];ReturnValue;taint",
4646
";Collection;true;trimmingPrefix(while:);;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
47+
";Collection;true;makeIterator();;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
4748
";RangeReplaceableCollection;true;init(_:);;;Argument[0];ReturnValue.CollectionElement;taint",
4849
";RangeReplaceableCollection;true;init(_:);;;Argument[0].CollectionElement;ReturnValue.CollectionElement;value",
4950
";RangeReplaceableCollection;true;init(repeating:count:);;;Argument[0];ReturnValue.CollectionElement;value",

swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Dictionary.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ private class DictionarySummaries extends SummaryModelCsv {
2121
[
2222
";Dictionary;true;updateValue(_:forKey:);;;Argument[0];Argument[-1].CollectionElement.TupleElement[1];value",
2323
";Dictionary;true;updateValue(_:forKey:);;;Argument[1];Argument[-1].CollectionElement.TupleElement[0];value",
24-
";Dictionary;true;updateValue(_:forKey:);;;Argument[-1].CollectionElement.TupleElement[1];ReturnValue.OptionalSome;value"
24+
";Dictionary;true;updateValue(_:forKey:);;;Argument[-1].CollectionElement.TupleElement[1];ReturnValue.OptionalSome;value",
25+
";Dictionary;true;makeIterator();;;Argument[-1].CollectionElement;ReturnValue.CollectionElement;value",
2526
]
2627
}
2728
}

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

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,40 @@ edges
135135
| test2.swift:69:10:69:10 | key | test2.swift:70:19:70:19 | key | provenance | |
136136
| test2.swift:69:25:69:25 | call to makeIterator() [Collection element, Tuple element at index 0] | test2.swift:69:5:69:5 | $generator [Collection element, Tuple element at index 0] | provenance | |
137137
| test2.swift:69:25:69:25 | d4 [Collection element, Tuple element at index 0] | test2.swift:69:25:69:25 | call to makeIterator() [Collection element, Tuple element at index 0] | provenance | |
138+
| test2.swift:76:14:76:47 | [...] [Collection element] | test2.swift:78:14:78:14 | a1 [Collection element] | provenance | |
139+
| test2.swift:76:14:76:47 | [...] [Collection element] | test2.swift:82:19:82:19 | a1 [Collection element] | provenance | |
140+
| test2.swift:76:14:76:47 | [...] [Collection element] | test2.swift:84:20:84:20 | a1 [Collection element] | provenance | |
141+
| test2.swift:76:30:76:46 | call to source(_:) | test2.swift:76:14:76:47 | [...] [Collection element] | provenance | |
142+
| test2.swift:78:5:78:5 | $v$generator [Collection element] | test2.swift:78:5:78:5 | call to next() [some:0] | provenance | |
143+
| test2.swift:78:5:78:5 | call to next() [some:0] | test2.swift:78:9:78:9 | v | provenance | |
144+
| test2.swift:78:9:78:9 | v | test2.swift:79:19:79:19 | v | provenance | |
145+
| test2.swift:78:14:78:14 | a1 [Collection element] | test2.swift:78:14:78:14 | call to makeIterator() [Collection element] | provenance | |
146+
| test2.swift:78:14:78:14 | call to makeIterator() [Collection element] | test2.swift:78:5:78:5 | $v$generator [Collection element] | provenance | |
147+
| test2.swift:82:19:82:19 | a1 [Collection element] | test2.swift:82:19:82:24 | ...[...] | provenance | |
148+
| test2.swift:84:5:84:5 | $generator [Collection element, Tuple element at index 1] | test2.swift:84:5:84:5 | call to next() [some:0, Tuple element at index 1] | provenance | |
149+
| test2.swift:84:5:84:5 | call to next() [some:0, Tuple element at index 1] | test2.swift:84:9:84:15 | (...) [Tuple element at index 1] | provenance | |
150+
| test2.swift:84:9:84:15 | (...) [Tuple element at index 1] | test2.swift:84:14:84:14 | v | provenance | |
151+
| test2.swift:84:14:84:14 | v | test2.swift:86:19:86:19 | v | provenance | |
152+
| test2.swift:84:20:84:20 | a1 [Collection element] | test2.swift:84:20:84:34 | call to enumerated() [Collection element, Tuple element at index 1] | provenance | |
153+
| test2.swift:84:20:84:34 | call to enumerated() [Collection element, Tuple element at index 1] | test2.swift:84:20:84:34 | call to makeIterator() [Collection element, Tuple element at index 1] | provenance | |
154+
| test2.swift:84:20:84:34 | call to makeIterator() [Collection element, Tuple element at index 1] | test2.swift:84:5:84:5 | $generator [Collection element, Tuple element at index 1] | provenance | |
155+
| test2.swift:93:5:93:5 | [post] a2 [Collection element] | test2.swift:95:14:95:14 | a2 [Collection element] | provenance | |
156+
| test2.swift:93:5:93:5 | [post] a2 [Collection element] | test2.swift:99:19:99:19 | a2 [Collection element] | provenance | |
157+
| test2.swift:93:5:93:5 | [post] a2 [Collection element] | test2.swift:101:20:101:20 | a2 [Collection element] | provenance | |
158+
| test2.swift:93:13:93:29 | call to source(_:) | test2.swift:93:5:93:5 | [post] a2 [Collection element] | provenance | |
159+
| test2.swift:95:5:95:5 | $v$generator [Collection element] | test2.swift:95:5:95:5 | call to next() [some:0] | provenance | |
160+
| test2.swift:95:5:95:5 | call to next() [some:0] | test2.swift:95:9:95:9 | v | provenance | |
161+
| test2.swift:95:9:95:9 | v | test2.swift:96:19:96:19 | v | provenance | |
162+
| test2.swift:95:14:95:14 | a2 [Collection element] | test2.swift:95:14:95:14 | call to makeIterator() [Collection element] | provenance | |
163+
| test2.swift:95:14:95:14 | call to makeIterator() [Collection element] | test2.swift:95:5:95:5 | $v$generator [Collection element] | provenance | |
164+
| test2.swift:99:19:99:19 | a2 [Collection element] | test2.swift:99:19:99:24 | ...[...] | provenance | |
165+
| test2.swift:101:5:101:5 | $generator [Collection element, Tuple element at index 1] | test2.swift:101:5:101:5 | call to next() [some:0, Tuple element at index 1] | provenance | |
166+
| test2.swift:101:5:101:5 | call to next() [some:0, Tuple element at index 1] | test2.swift:101:9:101:15 | (...) [Tuple element at index 1] | provenance | |
167+
| test2.swift:101:9:101:15 | (...) [Tuple element at index 1] | test2.swift:101:14:101:14 | v | provenance | |
168+
| test2.swift:101:14:101:14 | v | test2.swift:103:19:103:19 | v | provenance | |
169+
| test2.swift:101:20:101:20 | a2 [Collection element] | test2.swift:101:20:101:34 | call to enumerated() [Collection element, Tuple element at index 1] | provenance | |
170+
| test2.swift:101:20:101:34 | call to enumerated() [Collection element, Tuple element at index 1] | test2.swift:101:20:101:34 | call to makeIterator() [Collection element, Tuple element at index 1] | provenance | |
171+
| test2.swift:101:20:101:34 | call to makeIterator() [Collection element, Tuple element at index 1] | test2.swift:101:5:101:5 | $generator [Collection element, Tuple element at index 1] | provenance | |
138172
| test.swift:6:19:6:26 | call to source() | test.swift:7:15:7:15 | t1 | provenance | |
139173
| test.swift:6:19:6:26 | call to source() | test.swift:9:15:9:15 | t1 | provenance | |
140174
| test.swift:6:19:6:26 | call to source() | test.swift:10:15:10:15 | t2 | provenance | |
@@ -690,9 +724,15 @@ edges
690724
| test.swift:849:19:849:24 | v | test.swift:850:15:850:15 | v | provenance | |
691725
| test.swift:856:29:856:40 | args [Collection element] | test.swift:859:15:859:15 | args [Collection element] | provenance | |
692726
| test.swift:856:29:856:40 | args [Collection element] | test.swift:860:15:860:15 | args [Collection element] | provenance | |
727+
| test.swift:856:29:856:40 | args [Collection element] | test.swift:862:16:862:16 | args [Collection element] | provenance | |
693728
| test.swift:856:29:856:40 | args [Collection element] | test.swift:867:15:867:15 | args [Collection element] | provenance | |
694729
| test.swift:859:15:859:15 | args [Collection element] | test.swift:859:15:859:21 | ...[...] | provenance | |
695730
| test.swift:860:15:860:15 | args [Collection element] | test.swift:860:15:860:21 | ...[...] | provenance | |
731+
| test.swift:862:5:862:5 | $arg$generator [Collection element] | test.swift:862:5:862:5 | call to next() [some:0] | provenance | |
732+
| test.swift:862:5:862:5 | call to next() [some:0] | test.swift:862:9:862:9 | arg | provenance | |
733+
| test.swift:862:9:862:9 | arg | test.swift:863:19:863:19 | arg | provenance | |
734+
| test.swift:862:16:862:16 | args [Collection element] | test.swift:862:16:862:16 | call to makeIterator() [Collection element] | provenance | |
735+
| test.swift:862:16:862:16 | call to makeIterator() [Collection element] | test.swift:862:5:862:5 | $arg$generator [Collection element] | provenance | |
696736
| test.swift:866:21:866:29 | enter #keyPath(...) [Collection element] | test.swift:866:27:866:29 | KeyPathComponent | provenance | |
697737
| test.swift:866:27:866:29 | KeyPathComponent | test.swift:866:21:866:29 | exit #keyPath(...) | provenance | |
698738
| test.swift:867:15:867:15 | args [Collection element] | test.swift:866:21:866:29 | enter #keyPath(...) [Collection element] | provenance | |
@@ -884,6 +924,42 @@ nodes
884924
| test2.swift:69:25:69:25 | call to makeIterator() [Collection element, Tuple element at index 0] | semmle.label | call to makeIterator() [Collection element, Tuple element at index 0] |
885925
| test2.swift:69:25:69:25 | d4 [Collection element, Tuple element at index 0] | semmle.label | d4 [Collection element, Tuple element at index 0] |
886926
| test2.swift:70:19:70:19 | key | semmle.label | key |
927+
| test2.swift:76:14:76:47 | [...] [Collection element] | semmle.label | [...] [Collection element] |
928+
| test2.swift:76:30:76:46 | call to source(_:) | semmle.label | call to source(_:) |
929+
| test2.swift:78:5:78:5 | $v$generator [Collection element] | semmle.label | $v$generator [Collection element] |
930+
| test2.swift:78:5:78:5 | call to next() [some:0] | semmle.label | call to next() [some:0] |
931+
| test2.swift:78:9:78:9 | v | semmle.label | v |
932+
| test2.swift:78:14:78:14 | a1 [Collection element] | semmle.label | a1 [Collection element] |
933+
| test2.swift:78:14:78:14 | call to makeIterator() [Collection element] | semmle.label | call to makeIterator() [Collection element] |
934+
| test2.swift:79:19:79:19 | v | semmle.label | v |
935+
| test2.swift:82:19:82:19 | a1 [Collection element] | semmle.label | a1 [Collection element] |
936+
| test2.swift:82:19:82:24 | ...[...] | semmle.label | ...[...] |
937+
| test2.swift:84:5:84:5 | $generator [Collection element, Tuple element at index 1] | semmle.label | $generator [Collection element, Tuple element at index 1] |
938+
| test2.swift:84:5:84:5 | call to next() [some:0, Tuple element at index 1] | semmle.label | call to next() [some:0, Tuple element at index 1] |
939+
| test2.swift:84:9:84:15 | (...) [Tuple element at index 1] | semmle.label | (...) [Tuple element at index 1] |
940+
| test2.swift:84:14:84:14 | v | semmle.label | v |
941+
| test2.swift:84:20:84:20 | a1 [Collection element] | semmle.label | a1 [Collection element] |
942+
| test2.swift:84:20:84:34 | call to enumerated() [Collection element, Tuple element at index 1] | semmle.label | call to enumerated() [Collection element, Tuple element at index 1] |
943+
| test2.swift:84:20:84:34 | call to makeIterator() [Collection element, Tuple element at index 1] | semmle.label | call to makeIterator() [Collection element, Tuple element at index 1] |
944+
| test2.swift:86:19:86:19 | v | semmle.label | v |
945+
| test2.swift:93:5:93:5 | [post] a2 [Collection element] | semmle.label | [post] a2 [Collection element] |
946+
| test2.swift:93:13:93:29 | call to source(_:) | semmle.label | call to source(_:) |
947+
| test2.swift:95:5:95:5 | $v$generator [Collection element] | semmle.label | $v$generator [Collection element] |
948+
| test2.swift:95:5:95:5 | call to next() [some:0] | semmle.label | call to next() [some:0] |
949+
| test2.swift:95:9:95:9 | v | semmle.label | v |
950+
| test2.swift:95:14:95:14 | a2 [Collection element] | semmle.label | a2 [Collection element] |
951+
| test2.swift:95:14:95:14 | call to makeIterator() [Collection element] | semmle.label | call to makeIterator() [Collection element] |
952+
| test2.swift:96:19:96:19 | v | semmle.label | v |
953+
| test2.swift:99:19:99:19 | a2 [Collection element] | semmle.label | a2 [Collection element] |
954+
| test2.swift:99:19:99:24 | ...[...] | semmle.label | ...[...] |
955+
| test2.swift:101:5:101:5 | $generator [Collection element, Tuple element at index 1] | semmle.label | $generator [Collection element, Tuple element at index 1] |
956+
| test2.swift:101:5:101:5 | call to next() [some:0, Tuple element at index 1] | semmle.label | call to next() [some:0, Tuple element at index 1] |
957+
| test2.swift:101:9:101:15 | (...) [Tuple element at index 1] | semmle.label | (...) [Tuple element at index 1] |
958+
| test2.swift:101:14:101:14 | v | semmle.label | v |
959+
| test2.swift:101:20:101:20 | a2 [Collection element] | semmle.label | a2 [Collection element] |
960+
| test2.swift:101:20:101:34 | call to enumerated() [Collection element, Tuple element at index 1] | semmle.label | call to enumerated() [Collection element, Tuple element at index 1] |
961+
| test2.swift:101:20:101:34 | call to makeIterator() [Collection element, Tuple element at index 1] | semmle.label | call to makeIterator() [Collection element, Tuple element at index 1] |
962+
| test2.swift:103:19:103:19 | v | semmle.label | v |
887963
| test.swift:6:19:6:26 | call to source() | semmle.label | call to source() |
888964
| test.swift:7:15:7:15 | t1 | semmle.label | t1 |
889965
| test.swift:9:15:9:15 | t1 | semmle.label | t1 |
@@ -1472,6 +1548,12 @@ nodes
14721548
| test.swift:859:15:859:21 | ...[...] | semmle.label | ...[...] |
14731549
| test.swift:860:15:860:15 | args [Collection element] | semmle.label | args [Collection element] |
14741550
| test.swift:860:15:860:21 | ...[...] | semmle.label | ...[...] |
1551+
| test.swift:862:5:862:5 | $arg$generator [Collection element] | semmle.label | $arg$generator [Collection element] |
1552+
| test.swift:862:5:862:5 | call to next() [some:0] | semmle.label | call to next() [some:0] |
1553+
| test.swift:862:9:862:9 | arg | semmle.label | arg |
1554+
| test.swift:862:16:862:16 | args [Collection element] | semmle.label | args [Collection element] |
1555+
| test.swift:862:16:862:16 | call to makeIterator() [Collection element] | semmle.label | call to makeIterator() [Collection element] |
1556+
| test.swift:863:19:863:19 | arg | semmle.label | arg |
14751557
| test.swift:866:21:866:29 | enter #keyPath(...) [Collection element] | semmle.label | enter #keyPath(...) [Collection element] |
14761558
| test.swift:866:21:866:29 | exit #keyPath(...) | semmle.label | exit #keyPath(...) |
14771559
| test.swift:866:27:866:29 | KeyPathComponent | semmle.label | KeyPathComponent |
@@ -1615,6 +1697,12 @@ subpaths
16151697
| test2.swift:53:15:53:28 | ... ??(_:_:) ... | test2.swift:46:17:46:33 | call to source(_:) | test2.swift:53:15:53:28 | ... ??(_:_:) ... | result |
16161698
| test2.swift:54:15:54:24 | ...! | test2.swift:46:17:46:33 | call to source(_:) | test2.swift:54:15:54:24 | ...! | result |
16171699
| test2.swift:70:19:70:19 | key | test2.swift:60:8:60:24 | call to source(_:) | test2.swift:70:19:70:19 | key | result |
1700+
| test2.swift:79:19:79:19 | v | test2.swift:76:30:76:46 | call to source(_:) | test2.swift:79:19:79:19 | v | result |
1701+
| test2.swift:82:19:82:24 | ...[...] | test2.swift:76:30:76:46 | call to source(_:) | test2.swift:82:19:82:24 | ...[...] | result |
1702+
| test2.swift:86:19:86:19 | v | test2.swift:76:30:76:46 | call to source(_:) | test2.swift:86:19:86:19 | v | result |
1703+
| test2.swift:96:19:96:19 | v | test2.swift:93:13:93:29 | call to source(_:) | test2.swift:96:19:96:19 | v | result |
1704+
| test2.swift:99:19:99:24 | ...[...] | test2.swift:93:13:93:29 | call to source(_:) | test2.swift:99:19:99:24 | ...[...] | result |
1705+
| test2.swift:103:19:103:19 | v | test2.swift:93:13:93:29 | call to source(_:) | test2.swift:103:19:103:19 | v | result |
16181706
| test.swift:7:15:7:15 | t1 | test.swift:6:19:6:26 | call to source() | test.swift:7:15:7:15 | t1 | result |
16191707
| test.swift:9:15:9:15 | t1 | test.swift:6:19:6:26 | call to source() | test.swift:9:15:9:15 | t1 | result |
16201708
| test.swift:10:15:10:15 | t2 | test.swift:6:19:6:26 | call to source() | test.swift:10:15:10:15 | t2 | result |
@@ -1739,6 +1827,7 @@ subpaths
17391827
| test.swift:850:15:850:15 | v | test.swift:872:18:872:25 | call to source() | test.swift:850:15:850:15 | v | result |
17401828
| test.swift:859:15:859:21 | ...[...] | test.swift:873:24:873:31 | call to source() | test.swift:859:15:859:21 | ...[...] | result |
17411829
| test.swift:860:15:860:21 | ...[...] | test.swift:873:24:873:31 | call to source() | test.swift:860:15:860:21 | ...[...] | result |
1830+
| test.swift:863:19:863:19 | arg | test.swift:873:24:873:31 | call to source() | test.swift:863:19:863:19 | arg | result |
17421831
| test.swift:867:15:867:38 | \\...[...] | test.swift:873:24:873:31 | call to source() | test.swift:867:15:867:38 | \\...[...] | result |
17431832
| test.swift:880:19:880:19 | elem | test.swift:877:21:877:28 | call to source() | test.swift:880:19:880:19 | elem | result |
17441833
| test.swift:884:15:884:31 | ...! | test.swift:877:21:877:28 | call to source() | test.swift:884:15:884:31 | ...! | result |
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
testFailures
2-
| test.swift:863:24:864:1 | // $ flow=873\n | Missing result: flow=873 |
32
failures

0 commit comments

Comments
 (0)