Skip to content

Commit 368b232

Browse files
committed
C#: Remove the no-match steps (they occur due to control flow splitting).
1 parent 945ac96 commit 368b232

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

csharp/ql/lib/semmle/code/csharp/controlflow/ControlFlowGraph.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ module ControlFlow {
225225
result = this.getASuccessorByType(any(BooleanSuccessor t | t.getValue() = false))
226226
}
227227

228+
/**
229+
* Gets an immediate `match` predecessor, if any.
230+
*/
231+
Node getAMatchPredecessor() {
232+
result = this.getAPredecessorByType(any(MatchingSuccessor t | t.isMatch()))
233+
}
234+
228235
/** Gets the enclosing callable of this control flow node. */
229236
final Callable getEnclosingCallable() { result = Impl::getNodeCfgScope(this) }
230237
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2597,12 +2597,19 @@ predicate readStep(Node node1, ContentSet c, Node node2) {
25972597
or
25982598
dynamicPropertyRead(node1.asExpr(), c, node2.asExpr())
25992599
or
2600-
patternPropertyRead(node1.asExpr(), c, node2.asExpr())
2601-
or
26022600
node2.asExpr().(AwaitExpr).getExpr() = node1.asExpr() and
26032601
c = getResultContent()
26042602
)
26052603
or
2604+
exists(ReadStepConfiguration x, ControlFlow::Node cfn1, ControlFlow::Node cfn2 |
2605+
cfn1 = node1.getControlFlowNode() and
2606+
cfn2 = node2.getControlFlowNode() and
2607+
cfn1.getAMatchPredecessor() = cfn2 and
2608+
x.hasExprPath(_, cfn1, _, cfn2)
2609+
|
2610+
patternPropertyRead(node1.asExpr(), c, node2.asExpr())
2611+
)
2612+
or
26062613
FlowSummaryImpl::Private::Steps::summaryReadStep(node1.(FlowSummaryNode).getSummaryNode(), c,
26072614
node2.(FlowSummaryNode).getSummaryNode())
26082615
or

0 commit comments

Comments
 (0)