Skip to content

Commit c429faf

Browse files
committed
C#: Split pattern reads into two steps.
1 parent 2a5c794 commit c429faf

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

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

+17-3
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,20 @@ module LocalFlow {
610610
or
611611
exists(Switch sw | sw.getACase() = cfe and sw.getExpr() = e1 and scope = sw)
612612
)
613+
or
614+
isSuccessor = true and
615+
scope =
616+
any(IsExpr ie |
617+
e1 = ie.getExpr() and
618+
e2 = ie.getPattern()
619+
)
620+
or
621+
isSuccessor = true and
622+
scope =
623+
any(Switch e |
624+
e1 = e.getExpr() and
625+
e2 = e.getACase().getPattern()
626+
)
613627
)
614628
}
615629

@@ -919,13 +933,13 @@ private predicate patternPropertyRead0(RecursivePatternExpr rpe, ContentSet c, V
919933

920934
private predicate patternPropertyRead(Expr e1, ContentSet c, VariablePatternExpr e2) {
921935
exists(IsExpr ie, RecursivePatternExpr rpe |
922-
e1 = ie.getExpr() and
936+
e1 = rpe and
923937
rpe = ie.getPattern() and
924938
patternPropertyRead0(rpe, c, e2)
925939
)
926940
or
927941
exists(Switch sw, RecursivePatternExpr rpe |
928-
e1 = sw.getExpr() and
942+
e1 = rpe and
929943
rpe = sw.getACase().getPattern() and
930944
patternPropertyRead0(rpe, c, e2)
931945
)
@@ -2454,7 +2468,7 @@ private class ReadStepConfiguration extends ControlFlowReachabilityConfiguration
24542468
isSuccessor = false
24552469
or
24562470
exactScope = false and
2457-
isSuccessor = true and
2471+
isSuccessor = false and
24582472
patternPropertyRead(e1, _, e2) and
24592473
scope = e1
24602474
}

0 commit comments

Comments
 (0)