Skip to content

Commit bb50a99

Browse files
committed
Swift: Additional test cases.
1 parent b5dd815 commit bb50a99

File tree

4 files changed

+72
-11
lines changed

4 files changed

+72
-11
lines changed

swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ private module Cached {
157157
exists(ConditionElement ce, ConcreteVarDecl v |
158158
ce.getInitializer() = nodeFrom.asExpr() and
159159
ce.getPattern() = v.getParentPattern() and
160-
//.(OptionalSomePattern).getSubPattern().(BindingPattern).getSubPattern().(NamedPattern) ?
161160
nodeTo.asDefinition().getSourceVariable() = v
162161
)
163162
or

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ edges
100100
| test.swift:225:14:225:21 | call to source() : | test.swift:235:13:235:15 | .source_value |
101101
| test.swift:225:14:225:21 | call to source() : | test.swift:238:13:238:15 | .source_value |
102102
| test.swift:259:12:259:19 | call to source() : | test.swift:263:13:263:28 | call to optionalSource() : |
103+
| test.swift:259:12:259:19 | call to source() : | test.swift:437:13:437:28 | call to optionalSource() : |
103104
| test.swift:263:13:263:28 | call to optionalSource() : | test.swift:265:15:265:15 | x |
104105
| test.swift:263:13:263:28 | call to optionalSource() : | test.swift:267:15:267:16 | ...! |
105106
| test.swift:263:13:263:28 | call to optionalSource() : | test.swift:271:15:271:16 | ...? : |
@@ -140,6 +141,7 @@ edges
140141
| test.swift:357:15:357:15 | t1 [Tuple element at index 1] : | test.swift:357:15:357:18 | .1 |
141142
| test.swift:360:15:360:15 | t2 [Tuple element at index 0] : | test.swift:360:15:360:18 | .0 |
142143
| test.swift:361:15:361:15 | t2 [Tuple element at index 1] : | test.swift:361:15:361:18 | .1 |
144+
| test.swift:437:13:437:28 | call to optionalSource() : | test.swift:440:19:440:19 | a |
143145
nodes
144146
| file://:0:0:0:0 | .a [x] : | semmle.label | .a [x] : |
145147
| file://:0:0:0:0 | .x : | semmle.label | .x : |
@@ -296,6 +298,8 @@ nodes
296298
| test.swift:360:15:360:18 | .0 | semmle.label | .0 |
297299
| test.swift:361:15:361:15 | t2 [Tuple element at index 1] : | semmle.label | t2 [Tuple element at index 1] : |
298300
| test.swift:361:15:361:18 | .1 | semmle.label | .1 |
301+
| test.swift:437:13:437:28 | call to optionalSource() : | semmle.label | call to optionalSource() : |
302+
| test.swift:440:19:440:19 | a | semmle.label | a |
299303
subpaths
300304
| 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] &... : |
301305
| 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 ... : |
@@ -376,3 +380,4 @@ subpaths
376380
| test.swift:357:15:357:18 | .1 | test.swift:351:31:351:38 | call to source() : | test.swift:357:15:357:18 | .1 | result |
377381
| test.swift:360:15:360:18 | .0 | test.swift:351:18:351:25 | call to source() : | test.swift:360:15:360:18 | .0 | result |
378382
| test.swift:361:15:361:18 | .1 | test.swift:351:31:351:38 | call to source() : | test.swift:361:15:361:18 | .1 | result |
383+
| test.swift:440:19:440:19 | a | test.swift:259:12:259:19 | call to source() : | test.swift:440:19:440:19 | a | result |

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

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,55 @@
318318
| test.swift:361:15:361:15 | t2 | test.swift:362:15:362:15 | t2 |
319319
| test.swift:375:9:375:13 | SSA def(a) | test.swift:377:12:377:12 | a |
320320
| test.swift:375:22:375:23 | .myNone | test.swift:375:9:375:13 | SSA def(a) |
321+
| test.swift:377:12:377:12 | a | test.swift:387:32:387:32 | a |
321322
| test.swift:380:10:380:25 | SSA def(a) | test.swift:381:19:381:19 | a |
322323
| test.swift:382:10:382:30 | SSA def(a) | test.swift:383:19:383:19 | a |
323324
| test.swift:382:10:382:30 | SSA def(b) | test.swift:384:19:384:19 | b |
324-
| test.swift:387:9:387:13 | SSA def(b) | test.swift:389:12:389:12 | b |
325-
| test.swift:387:22:387:40 | call to ... | test.swift:387:9:387:13 | SSA def(b) |
326-
| test.swift:392:10:392:25 | SSA def(a) | test.swift:393:19:393:19 | a |
327-
| test.swift:394:10:394:30 | SSA def(a) | test.swift:395:19:395:19 | a |
328-
| test.swift:394:10:394:30 | SSA def(b) | test.swift:396:19:396:19 | b |
329-
| test.swift:399:9:399:9 | SSA def(c) | test.swift:401:12:401:12 | c |
330-
| test.swift:399:13:399:38 | call to ... | test.swift:399:9:399:9 | SSA def(c) |
331-
| test.swift:404:10:404:25 | SSA def(a) | test.swift:405:19:405:19 | a |
332-
| test.swift:406:10:406:30 | SSA def(a) | test.swift:407:19:407:19 | a |
333-
| test.swift:406:10:406:30 | SSA def(b) | test.swift:408:19:408:19 | b |
325+
| test.swift:387:13:387:28 | SSA def(x) | test.swift:388:19:388:19 | x |
326+
| test.swift:387:32:387:32 | a | test.swift:387:13:387:28 | SSA def(x) |
327+
| test.swift:387:32:387:32 | a | test.swift:390:37:390:37 | a |
328+
| test.swift:390:13:390:33 | SSA def(x) | test.swift:391:19:391:19 | x |
329+
| test.swift:390:13:390:33 | SSA def(y) | test.swift:392:19:392:19 | y |
330+
| test.swift:390:37:390:37 | a | test.swift:390:13:390:33 | SSA def(x) |
331+
| test.swift:390:37:390:37 | a | test.swift:390:13:390:33 | SSA def(y) |
332+
| test.swift:390:37:390:37 | a | test.swift:407:32:407:32 | a |
333+
| test.swift:395:9:395:13 | SSA def(b) | test.swift:397:12:397:12 | b |
334+
| test.swift:395:22:395:40 | call to ... | test.swift:395:9:395:13 | SSA def(b) |
335+
| test.swift:400:10:400:25 | SSA def(a) | test.swift:401:19:401:19 | a |
336+
| test.swift:402:10:402:30 | SSA def(a) | test.swift:403:19:403:19 | a |
337+
| test.swift:402:10:402:30 | SSA def(b) | test.swift:404:19:404:19 | b |
338+
| test.swift:407:13:407:28 | SSA def(x) | test.swift:408:19:408:19 | x |
339+
| test.swift:407:32:407:32 | a | test.swift:407:13:407:28 | SSA def(x) |
340+
| test.swift:407:32:407:32 | a | test.swift:410:37:410:37 | a |
341+
| test.swift:410:13:410:33 | SSA def(x) | test.swift:411:19:411:19 | x |
342+
| test.swift:410:13:410:33 | SSA def(y) | test.swift:412:19:412:19 | y |
343+
| test.swift:410:37:410:37 | a | test.swift:410:13:410:33 | SSA def(x) |
344+
| test.swift:410:37:410:37 | a | test.swift:410:13:410:33 | SSA def(y) |
345+
| test.swift:410:37:410:37 | a | test.swift:427:32:427:32 | a |
346+
| test.swift:415:9:415:9 | SSA def(c) | test.swift:417:12:417:12 | c |
347+
| test.swift:415:13:415:38 | call to ... | test.swift:415:9:415:9 | SSA def(c) |
348+
| test.swift:420:10:420:25 | SSA def(a) | test.swift:421:19:421:19 | a |
349+
| test.swift:422:10:422:30 | SSA def(a) | test.swift:423:19:423:19 | a |
350+
| test.swift:422:10:422:30 | SSA def(b) | test.swift:424:19:424:19 | b |
351+
| test.swift:427:13:427:28 | SSA def(x) | test.swift:428:19:428:19 | x |
352+
| test.swift:427:32:427:32 | a | test.swift:427:13:427:28 | SSA def(x) |
353+
| test.swift:427:32:427:32 | a | test.swift:430:37:430:37 | a |
354+
| test.swift:430:13:430:33 | SSA def(x) | test.swift:431:19:431:19 | x |
355+
| test.swift:430:13:430:33 | SSA def(y) | test.swift:432:19:432:19 | y |
356+
| test.swift:430:37:430:37 | a | test.swift:430:13:430:33 | SSA def(x) |
357+
| test.swift:430:37:430:37 | a | test.swift:430:13:430:33 | SSA def(y) |
358+
| test.swift:436:21:436:27 | SSA def(y) | test.swift:439:27:439:27 | y |
359+
| test.swift:436:21:436:27 | SSA def(y) | test.swift:444:22:444:22 | y |
360+
| test.swift:436:21:436:27 | y | test.swift:436:21:436:27 | SSA def(y) |
361+
| test.swift:437:9:437:9 | SSA def(x) | test.swift:439:16:439:16 | x |
362+
| test.swift:437:13:437:28 | call to optionalSource() | test.swift:437:9:437:9 | SSA def(x) |
363+
| test.swift:439:8:439:12 | SSA def(a) | test.swift:440:19:440:19 | a |
364+
| test.swift:439:16:439:16 | x | test.swift:439:8:439:12 | SSA def(a) |
365+
| test.swift:439:16:439:16 | x | test.swift:444:19:444:19 | x |
366+
| test.swift:439:19:439:23 | SSA def(b) | test.swift:441:19:441:19 | b |
367+
| test.swift:439:27:439:27 | y | test.swift:439:19:439:23 | SSA def(b) |
368+
| test.swift:439:27:439:27 | y | test.swift:444:22:444:22 | y |
369+
| test.swift:444:9:444:9 | SSA def(tuple1) | test.swift:445:12:445:12 | tuple1 |
370+
| test.swift:444:18:444:23 | (...) | test.swift:444:9:444:9 | SSA def(tuple1) |
371+
| test.swift:446:10:446:37 | SSA def(a) | test.swift:447:19:447:19 | a |
372+
| test.swift:446:10:446:37 | SSA def(b) | test.swift:448:19:448:19 | b |

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,3 +432,21 @@ func testEnums() {
432432
sink(arg: y) // $ MISSING: flow=415
433433
}
434434
}
435+
436+
func testOptionals2(y: Int?) {
437+
let x = optionalSource()
438+
439+
if let a = x, let b = y {
440+
sink(arg: a) // $ flow=259
441+
sink(arg: b)
442+
}
443+
444+
let tuple1 = (x, y)
445+
switch tuple1 {
446+
case (.some(let a), .some(let b)):
447+
sink(arg: a) // $ MISSING: flow=259
448+
sink(arg: b)
449+
default:
450+
()
451+
}
452+
}

0 commit comments

Comments
 (0)