Skip to content

Commit af079ff

Browse files
committed
Swift: Adapt to FlowSummaryImpl changes
1 parent aae96d0 commit af079ff

2 files changed

Lines changed: 45 additions & 13 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,10 +497,10 @@ class FlowSummaryNode extends NodeImpl, TFlowSummaryNode {
497497
}
498498

499499
override DataFlowCallable getEnclosingCallable() {
500-
result.asSummarizedCallable() = this.getSummarizedCallable()
500+
result = this.getSummaryNode().getEnclosingCallable()
501501
}
502502

503-
override Location getLocationImpl() { result = this.getSummarizedCallable().getLocation() }
503+
override Location getLocationImpl() { result = this.getSummaryNode().getLocation() }
504504

505505
override string toStringImpl() { result = this.getSummaryNode().toString() }
506506
}

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

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,20 @@ module Input implements InputSig<Location, DataFlowImplSpecific::SwiftDataFlow>
1616

1717
class SummarizedCallableBase = Function;
1818

19-
class SourceBase = Void;
19+
class SourceBase extends Void {
20+
Location getLocation() { none() }
21+
}
2022

21-
class SinkBase = Void;
23+
class SinkBase = SourceBase;
2224

23-
class FlowSummaryCallBase = Void;
25+
class FlowSummaryCallBase = SourceBase;
2426

2527
predicate callableFromSource(SummarizedCallableBase c) { c.hasBody() }
2628

29+
DataFlowCallable getSummarizedCallableAsDataFlowCallable(SummarizedCallableBase c) {
30+
result.asSummarizedCallable() = c
31+
}
32+
2733
ArgumentPosition callbackSelfParameterPosition() { result instanceof ThisArgumentPosition }
2834

2935
ReturnKind getStandardReturnValueKind() { result instanceof NormalReturnKind }
@@ -114,18 +120,43 @@ module Input implements InputSig<Location, DataFlowImplSpecific::SwiftDataFlow>
114120

115121
private import Make<Location, DataFlowImplSpecific::SwiftDataFlow, Input> as Impl
116122

117-
private module StepsInput implements Impl::Private::StepsInputSig {
118-
Impl::Private::SummaryNode getSummaryNode(Node n) {
119-
result = n.(FlowSummaryNode).getSummaryNode()
123+
private module Input2 implements Impl::Private::InputSig2 {
124+
private import codeql.util.Void
125+
126+
class SourceSinkReportingElement extends Void {
127+
Location getLocation() { none() }
128+
129+
DataFlowCallable getEnclosingCallable() { none() }
120130
}
121131

122-
DataFlowCall getACall(Public::SummarizedCallable sc) { result.asCall().getStaticTarget() = sc }
132+
bindingset[source, s]
133+
SourceSinkReportingElement getSourceEntryElement(
134+
Impl::Public::SourceElement source, Impl::Private::SummaryComponentStack s
135+
) {
136+
none()
137+
}
123138

124-
DataFlowCallable getSourceNodeEnclosingCallable(Input::SourceBase source) { none() }
139+
bindingset[e, s]
140+
Node getSourceExitNode(SourceSinkReportingElement e, Impl::Private::SummaryComponentStack s) {
141+
none()
142+
}
143+
144+
SourceSinkReportingElement getSinkExitElement(
145+
Impl::Public::SinkElement sink, Impl::Private::SummaryComponent sc
146+
) {
147+
none()
148+
}
149+
150+
bindingset[e, sc]
151+
Node getSinkEntryNode(SourceSinkReportingElement e, Impl::Private::SummaryComponent sc) { none() }
152+
}
125153

126-
Node getSourceNode(Input::SourceBase source, Impl::Private::SummaryComponentStack s) { none() }
154+
private import Impl::Private::Make2<Input2> as Impl2
127155

128-
Node getSinkNode(Input::SinkBase sink, Impl::Private::SummaryComponent sc) { none() }
156+
private module StepsInput implements Impl2::StepsInputSig {
157+
Impl2::SummaryNode getSummaryNode(Node n) { result = n.(FlowSummaryNode).getSummaryNode() }
158+
159+
DataFlowCall getACall(Public::SummarizedCallable sc) { result.asCall().getStaticTarget() = sc }
129160
}
130161

131162
module SourceSinkInterpretationInput implements
@@ -252,8 +283,9 @@ module SourceSinkInterpretationInput implements
252283

253284
module Private {
254285
import Impl::Private
286+
import Impl2
255287

256-
module Steps = Impl::Private::Steps<StepsInput>;
288+
module Steps = Impl2::Steps<StepsInput>;
257289

258290
module External {
259291
import Impl::Private::External

0 commit comments

Comments
 (0)