Merge pull request #13150 from michaelnebel/csharp/removejumpstep

C#: Remove jump step
This commit is contained in:
Michael Nebel 2023-06-15 12:53:37 +02:00 коммит произвёл GitHub
Родитель b7e9915151 04736b6e10
Коммит 47638123d0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 3 добавлений и 63 удалений

Просмотреть файл

@ -64,15 +64,6 @@ module SummaryComponent {
/** Gets a summary component that represents the return value of a call. */
SummaryComponent return() { result = return(any(DataFlowDispatch::NormalReturnKind rk)) }
/** Gets a summary component that represents a jump to `c`. */
SummaryComponent jump(Callable c) {
result =
return(any(DataFlowDispatch::JumpReturnKind jrk |
jrk.getTarget() = c.getUnboundDeclaration() and
jrk.getTargetReturnKind() instanceof DataFlowDispatch::NormalReturnKind
))
}
predicate syntheticGlobal = SummaryComponentInternal::syntheticGlobal/1;
class SyntheticGlobal = SummaryComponentInternal::SyntheticGlobal;
@ -114,9 +105,6 @@ module SummaryComponentStack {
/** Gets a singleton stack representing the return value of a call. */
SummaryComponentStack return() { result = singleton(SummaryComponent::return()) }
/** Gets a singleton stack representing a jump to `c`. */
SummaryComponentStack jump(Callable c) { result = singleton(SummaryComponent::jump(c)) }
/** Gets a singleton stack representing a synthetic global with name `name`. */
SummaryComponentStack syntheticGlobal(string synthetic) {
result = singleton(SummaryComponent::syntheticGlobal(synthetic))

Просмотреть файл

@ -74,18 +74,6 @@ newtype TReturnKind =
exists(Ssa::ExplicitDefinition def | def.isCapturedVariableDefinitionFlowOut(_, _) |
v = def.getSourceVariable().getAssignable()
)
} or
TJumpReturnKind(Callable target, ReturnKind rk) {
target.isUnboundDeclaration() and
(
rk instanceof NormalReturnKind and
(
target instanceof Constructor or
not target.getReturnType() instanceof VoidType
)
or
exists(target.getParameter(rk.(OutRefReturnKind).getPosition()))
)
}
/**
@ -257,27 +245,6 @@ class ImplicitCapturedReturnKind extends ReturnKind, TImplicitCapturedReturnKind
override string toString() { result = "captured " + v }
}
/**
* A value returned through the output of another callable.
*
* This is currently only used to model flow summaries where data may flow into
* one API entry point and out of another.
*/
class JumpReturnKind extends ReturnKind, TJumpReturnKind {
private Callable target;
private ReturnKind rk;
JumpReturnKind() { this = TJumpReturnKind(target, rk) }
/** Gets the target of the jump. */
Callable getTarget() { result = target }
/** Gets the return kind of the target. */
ReturnKind getTargetReturnKind() { result = rk }
override string toString() { result = "jump to " + target }
}
/** A callable used for data flow. */
class DataFlowCallable extends TDataFlowCallable {
/** Get the underlying source code callable, if any. */

Просмотреть файл

@ -1457,8 +1457,7 @@ private module ReturnNodes {
private ReturnKind rk;
SummaryReturnNode() {
FlowSummaryImpl::Private::summaryReturnNode(this.getSummaryNode(), rk) and
not rk instanceof JumpReturnKind
FlowSummaryImpl::Private::summaryReturnNode(this.getSummaryNode(), rk)
or
exists(Parameter p, int pos |
summaryPostUpdateNodeIsOutOrRef(this, p) and
@ -1708,12 +1707,6 @@ predicate jumpStep(Node pred, Node succ) {
flr.hasNonlocalValue()
)
or
exists(JumpReturnKind jrk, NonDelegateDataFlowCall call |
FlowSummaryImpl::Private::summaryReturnNode(pred.(FlowSummaryNode).getSummaryNode(), jrk) and
jrk.getTarget() = call.getATarget(_) and
succ = getAnOutNode(call, jrk.getTargetReturnKind())
)
or
FlowSummaryImpl::Private::Steps::summaryJumpStep(pred.(FlowSummaryNode).getSummaryNode(),
succ.(FlowSummaryNode).getSummaryNode())
}

Просмотреть файл

@ -61,7 +61,8 @@ DataFlowType getParameterType(SummarizedCallable c, ParameterPosition pos) {
)
}
private DataFlowType getReturnTypeBase(DotNet::Callable c, ReturnKind rk) {
/** Gets the return type of kind `rk` for callable `c`. */
DataFlowType getReturnType(DotNet::Callable c, ReturnKind rk) {
exists(Type t | result = Gvn::getGlobalValueNumber(t) |
rk instanceof NormalReturnKind and
(
@ -75,15 +76,6 @@ private DataFlowType getReturnTypeBase(DotNet::Callable c, ReturnKind rk) {
)
}
/** Gets the return type of kind `rk` for callable `c`. */
bindingset[c]
DataFlowType getReturnType(SummarizedCallable c, ReturnKind rk) {
result = getReturnTypeBase(c, rk)
or
rk =
any(JumpReturnKind jrk | result = getReturnTypeBase(jrk.getTarget(), jrk.getTargetReturnKind()))
}
/**
* Gets the type of the parameter matching arguments at position `pos` in a
* synthesized call that targets a callback of type `t`.