Skip to content

Commit 68999f3

Browse files
committed
Swift: Fix test by including the 'allowParameterReturnInSelf' hook from the variable capture library.
1 parent 9b150e4 commit 68999f3

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,12 @@ predicate additionalLambdaFlowStep(Node nodeFrom, Node nodeTo, boolean preserves
13871387
* One example would be to allow flow like `p.foo = p.bar;`, which is disallowed
13881388
* by default as a heuristic.
13891389
*/
1390-
predicate allowParameterReturnInSelf(ParameterNode p) { none() }
1390+
predicate allowParameterReturnInSelf(ParameterNode p) {
1391+
exists(Callable c |
1392+
c = p.(ParameterNodeImpl).getEnclosingCallable().asSourceCallable() and
1393+
CaptureFlow::heuristicAllowInstanceParameterReturnInSelf(c)
1394+
)
1395+
}
13911396

13921397
/** An approximated `Content`. */
13931398
class ContentApprox = Unit;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,5 @@ func multi() {
187187
var y = source("multi", 1)
188188
var f = { () in x = y }
189189
f()
190-
sink(x) // $ MISSING: hasValueFlow=multi
190+
sink(x) // $ hasValueFlow=multi
191191
}

0 commit comments

Comments
 (0)