Skip to content

Commit 1750d00

Browse files
committed
C#: Add localMustFlowStep
1 parent e677c1f commit 1750d00

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,36 @@ module LocalFlow {
533533
) and
534534
not exists(getALastEvalNode(result))
535535
}
536+
537+
/**
538+
* Holds if the value of `node2` is given by `node1`.
539+
*/
540+
predicate localMustFlowStep(Node node1, Node node2) {
541+
exists(Callable c, Expr e |
542+
node1.(InstanceParameterNode).getCallable() = c and
543+
node2.asExpr() = e and
544+
(e instanceof ThisAccess or e instanceof BaseAccess) and
545+
c = e.getEnclosingCallable()
546+
)
547+
or
548+
hasNodePath(any(LocalExprStepConfiguration x), node1, node2) and
549+
(node2 instanceof SsaDefinitionExtNode or node2.asExpr() instanceof Cast)
550+
or
551+
exists(SsaImpl::Definition def |
552+
def = getSsaDefinitionExt(node1) and
553+
exists(SsaImpl::getAReadAtNode(def, node2.(ExprNode).getControlFlowNode()))
554+
)
555+
or
556+
node1 =
557+
unique(FlowSummaryNode n1 |
558+
FlowSummaryImpl::Private::Steps::summaryLocalStep(n1.getSummaryNode(),
559+
node2.(FlowSummaryNode).getSummaryNode(), true)
560+
)
561+
}
536562
}
537563

564+
predicate localMustFlowStep = LocalFlow::localMustFlowStep/2;
565+
538566
/**
539567
* This is the local flow predicate that is used as a building block in global
540568
* data flow. It excludes SSA flow through instance fields, as flow through fields

0 commit comments

Comments
 (0)