@@ -1275,18 +1275,26 @@ module ControlFlow {
12751275 or
12761276 // Case statement exits with any completion
12771277 result = lastConstCaseStmt ( cc , c )
1278+ or
1279+ // Condition exists with a `false` completion
1280+ result = lastCaseCondition ( cc , c ) and
1281+ c instanceof FalseCompletion
1282+ or
1283+ // Condition exists abnormally
1284+ result = lastCaseCondition ( cc , c ) and
1285+ not c instanceof NormalCompletion
12781286 )
12791287 or
12801288 cfe = any ( TypeCase tc |
12811289 // Type test exits with a non-match
12821290 result = lastTypeCaseNoMatch ( tc , c )
12831291 or
12841292 // Condition exists with a `false` completion
1285- result = lastTypeCaseCondition ( tc , c ) and
1293+ result = lastCaseCondition ( tc , c ) and
12861294 c instanceof FalseCompletion
12871295 or
12881296 // Condition exists abnormally
1289- result = lastTypeCaseCondition ( tc , c ) and
1297+ result = lastCaseCondition ( tc , c ) and
12901298 not c instanceof NormalCompletion
12911299 or
12921300 // Case statement exits with any completion
@@ -1581,7 +1589,7 @@ module ControlFlow {
15811589 }
15821590
15831591 pragma [ nomagic]
1584- private ControlFlowElement lastTypeCaseCondition ( TypeCase tc , Completion c ) {
1592+ private ControlFlowElement lastCaseCondition ( CaseStmt tc , Completion c ) {
15851593 result = last ( tc .getCondition ( ) , c )
15861594 }
15871595
@@ -2032,9 +2040,9 @@ module ControlFlow {
20322040 )
20332041 or
20342042 // Flow from last element of condition to next case
2035- exists ( TypeCase tc , int i |
2043+ exists ( CaseStmt tc , int i |
20362044 tc = ss .getCase ( i ) |
2037- cfe = lastTypeCaseCondition ( tc , c ) and
2045+ cfe = lastCaseCondition ( tc , c ) and
20382046 c instanceof FalseCompletion and
20392047 result = first ( ss .getCase ( i + 1 ) )
20402048 )
@@ -2064,9 +2072,20 @@ module ControlFlow {
20642072 c instanceof SimpleCompletion
20652073 or
20662074 // Flow from last element of case expression to first element of statement
2075+ not exists ( cc .getCondition ( ) ) and
20672076 cfe = lastConstCaseExpr ( cc , c ) and
20682077 c .( MatchingCompletion ) .isMatch ( ) and
20692078 result = first ( cc .getStmt ( ) )
2079+ or
2080+ // Flow from the last element of case expression to the condition
2081+ cfe = lastConstCaseExpr ( cc , c ) and
2082+ c .( MatchingCompletion ) .isMatch ( ) and
2083+ result = first ( cc .getCondition ( ) )
2084+ or
2085+ // Flow from last element of case condition to first element of statement
2086+ cfe = lastCaseCondition ( cc , c ) and
2087+ c instanceof TrueCompletion and
2088+ result = first ( cc .getStmt ( ) )
20702089 )
20712090 or
20722091 exists ( TypeCase tc |
@@ -2105,7 +2124,7 @@ module ControlFlow {
21052124 result = first ( tc .getStmt ( ) )
21062125 or
21072126 // Flow from condition to first element of statement
2108- cfe = lastTypeCaseCondition ( tc , c ) and
2127+ cfe = lastCaseCondition ( tc , c ) and
21092128 c instanceof TrueCompletion and
21102129 result = first ( tc .getStmt ( ) )
21112130 )
0 commit comments