Skip to content

Commit 9d069b3

Browse files
committed
Swift: Create ArgumentNodes and OutNodes for MaD.
1 parent 0b6ea70 commit 9d069b3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ class SummaryCall extends DataFlowCall, TSummaryCall {
229229
cached
230230
private module Cached {
231231
cached
232-
newtype TDataFlowCallable = TDataFlowFunc(CfgScope scope)
232+
newtype TDataFlowCallable =
233+
TDataFlowFunc(CfgScope scope) or
234+
TSummarizedCallable(FlowSummary::SummarizedCallable c)
233235

234236
/** Gets a viable run-time target for the call `call`. */
235237
cached
@@ -241,6 +243,8 @@ private module Cached {
241243
result = TDataFlowFunc(call.(PropertySetterCall).getAccessorDecl())
242244
or
243245
result = TDataFlowFunc(call.(PropertyObserverCall).getAccessorDecl())
246+
or
247+
result = TSummarizedCallable(call.asCall().getStaticTarget())
244248
}
245249

246250
cached

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,14 @@ private module ArgumentNodes {
340340
)
341341
}
342342
}
343+
344+
class SummaryArgumentNode extends SummaryNode, ArgumentNode {
345+
SummaryArgumentNode() { FlowSummaryImpl::Private::summaryArgumentNode(_, this, _) }
346+
347+
override predicate argumentOf(DataFlowCall call, ArgumentPosition pos) {
348+
FlowSummaryImpl::Private::summaryArgumentNode(call, this, pos)
349+
}
350+
}
343351
}
344352

345353
import ArgumentNodes
@@ -410,6 +418,12 @@ private module OutNodes {
410418
}
411419
}
412420

421+
class SummaryOutNode extends OutNode, SummaryNode {
422+
override DataFlowCall getCall(ReturnKind kind) {
423+
FlowSummaryImpl::Private::summaryOutNode(result, this, kind)
424+
}
425+
}
426+
413427
class InOutUpdateArgNode extends OutNode, ExprPostUpdateNode {
414428
Argument arg;
415429

@@ -596,6 +610,9 @@ predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c)
596610
predicate lambdaCall(DataFlowCall call, LambdaCallKind kind, Node receiver) {
597611
kind = TLambdaCallKind() and
598612
receiver.asExpr() = call.asCall().getExpr().(ApplyExpr).getFunction()
613+
or
614+
kind = TLambdaCallKind() and
615+
receiver = call.(SummaryCall).getReceiver()
599616
}
600617

601618
/** Extra data-flow steps needed for lambda flow analysis. */

0 commit comments

Comments
 (0)