Fix WhenExpr flow

This commit is contained in:
Tony Torralba
2022-03-03 11:31:08 +01:00
committed by Ian Lynagh
parent 5979981199
commit 9735423c79
2 changed files with 3 additions and 1 deletions

View File

@@ -1248,7 +1248,7 @@ private module ControlFlowGraphImpl {
)
or
// When expressions:
exists(WhenExpr whenexpr | n = whenexpr |
exists(WhenExpr whenexpr |
n = whenexpr and
result = first(whenexpr.getBranch(0)) and
completion = NormalCompletion()

View File

@@ -156,6 +156,8 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
or
node2.asExpr() = any(NotNullExpr nne | node1.asExpr() = nne.getExpr())
or
node2.asExpr().(WhenExpr).getBranch(_).getAResult() = node1.asExpr()
or
exists(MethodAccess ma, ValuePreservingMethod m, int argNo |
ma.getCallee().getSourceDeclaration() = m and m.returnsValue(argNo)
|