Skip to content

Commit f26c514

Browse files
committed
C#: Remove the JumpReturnKind and the related summary component stack.
1 parent afec9b0 commit f26c514

File tree

4 files changed

+2
-63
lines changed

4 files changed

+2
-63
lines changed

csharp/ql/lib/semmle/code/csharp/dataflow/FlowSummary.qll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,6 @@ module SummaryComponent {
6464
/** Gets a summary component that represents the return value of a call. */
6565
SummaryComponent return() { result = return(any(DataFlowDispatch::NormalReturnKind rk)) }
6666

67-
/** Gets a summary component that represents a jump to `c`. */
68-
SummaryComponent jump(Callable c) {
69-
result =
70-
return(any(DataFlowDispatch::JumpReturnKind jrk |
71-
jrk.getTarget() = c.getUnboundDeclaration() and
72-
jrk.getTargetReturnKind() instanceof DataFlowDispatch::NormalReturnKind
73-
))
74-
}
75-
7667
predicate syntheticGlobal = SummaryComponentInternal::syntheticGlobal/1;
7768

7869
class SyntheticGlobal = SummaryComponentInternal::SyntheticGlobal;
@@ -114,9 +105,6 @@ module SummaryComponentStack {
114105
/** Gets a singleton stack representing the return value of a call. */
115106
SummaryComponentStack return() { result = singleton(SummaryComponent::return()) }
116107

117-
/** Gets a singleton stack representing a jump to `c`. */
118-
SummaryComponentStack jump(Callable c) { result = singleton(SummaryComponent::jump(c)) }
119-
120108
/** Gets a singleton stack representing a synthetic global with name `name`. */
121109
SummaryComponentStack syntheticGlobal(string synthetic) {
122110
result = singleton(SummaryComponent::syntheticGlobal(synthetic))

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowDispatch.qll

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,6 @@ newtype TReturnKind =
7474
exists(Ssa::ExplicitDefinition def | def.isCapturedVariableDefinitionFlowOut(_, _) |
7575
v = def.getSourceVariable().getAssignable()
7676
)
77-
} or
78-
TJumpReturnKind(Callable target, ReturnKind rk) {
79-
target.isUnboundDeclaration() and
80-
(
81-
rk instanceof NormalReturnKind and
82-
(
83-
target instanceof Constructor or
84-
not target.getReturnType() instanceof VoidType
85-
)
86-
or
87-
exists(target.getParameter(rk.(OutRefReturnKind).getPosition()))
88-
)
8977
}
9078

9179
/**
@@ -257,27 +245,6 @@ class ImplicitCapturedReturnKind extends ReturnKind, TImplicitCapturedReturnKind
257245
override string toString() { result = "captured " + v }
258246
}
259247

260-
/**
261-
* A value returned through the output of another callable.
262-
*
263-
* This is currently only used to model flow summaries where data may flow into
264-
* one API entry point and out of another.
265-
*/
266-
class JumpReturnKind extends ReturnKind, TJumpReturnKind {
267-
private Callable target;
268-
private ReturnKind rk;
269-
270-
JumpReturnKind() { this = TJumpReturnKind(target, rk) }
271-
272-
/** Gets the target of the jump. */
273-
Callable getTarget() { result = target }
274-
275-
/** Gets the return kind of the target. */
276-
ReturnKind getTargetReturnKind() { result = rk }
277-
278-
override string toString() { result = "jump to " + target }
279-
}
280-
281248
/** A callable used for data flow. */
282249
class DataFlowCallable extends TDataFlowCallable {
283250
/** Get the underlying source code callable, if any. */

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,8 +1457,7 @@ private module ReturnNodes {
14571457
private ReturnKind rk;
14581458

14591459
SummaryReturnNode() {
1460-
FlowSummaryImpl::Private::summaryReturnNode(this.getSummaryNode(), rk) and
1461-
not rk instanceof JumpReturnKind
1460+
FlowSummaryImpl::Private::summaryReturnNode(this.getSummaryNode(), rk)
14621461
or
14631462
exists(Parameter p, int pos |
14641463
summaryPostUpdateNodeIsOutOrRef(this, p) and
@@ -1708,12 +1707,6 @@ predicate jumpStep(Node pred, Node succ) {
17081707
flr.hasNonlocalValue()
17091708
)
17101709
or
1711-
exists(JumpReturnKind jrk, NonDelegateDataFlowCall call |
1712-
FlowSummaryImpl::Private::summaryReturnNode(pred.(FlowSummaryNode).getSummaryNode(), jrk) and
1713-
jrk.getTarget() = call.getATarget(_) and
1714-
succ = getAnOutNode(call, jrk.getTargetReturnKind())
1715-
)
1716-
or
17171710
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred.(FlowSummaryNode).getSummaryNode(),
17181711
succ.(FlowSummaryNode).getSummaryNode())
17191712
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ DataFlowType getParameterType(SummarizedCallable c, ParameterPosition pos) {
6161
)
6262
}
6363

64-
private DataFlowType getReturnTypeBase(DotNet::Callable c, ReturnKind rk) {
64+
DataFlowType getReturnType(DotNet::Callable c, ReturnKind rk) {
6565
exists(Type t | result = Gvn::getGlobalValueNumber(t) |
6666
rk instanceof NormalReturnKind and
6767
(
@@ -75,15 +75,6 @@ private DataFlowType getReturnTypeBase(DotNet::Callable c, ReturnKind rk) {
7575
)
7676
}
7777

78-
/** Gets the return type of kind `rk` for callable `c`. */
79-
bindingset[c]
80-
DataFlowType getReturnType(SummarizedCallable c, ReturnKind rk) {
81-
result = getReturnTypeBase(c, rk)
82-
or
83-
rk =
84-
any(JumpReturnKind jrk | result = getReturnTypeBase(jrk.getTarget(), jrk.getTargetReturnKind()))
85-
}
86-
8778
/**
8879
* Gets the type of the parameter matching arguments at position `pos` in a
8980
* synthesized call that targets a callback of type `t`.

0 commit comments

Comments
 (0)