Cfg: Move getCaseControlFlowOrder to shared code.

This commit is contained in:
Anders Schack-Mulligen
2026-03-10 10:39:32 +01:00
parent be9c1d074f
commit 35ac66d3aa
2 changed files with 20 additions and 20 deletions

View File

@@ -134,15 +134,6 @@ private module Ast implements AstSig<Location> {
}
}
int getCaseControlFlowOrder(Switch s, Case c) {
exists(int pos | s.getCase(pos) = c |
// if a default case is not last in the AST, move it last in the CFG order
if c instanceof DefaultCase and exists(s.getCase(pos + 1))
then result = strictcount(s.getCase(_))
else result = pos
)
}
private Stmt getSwitchStmt(Switch s, int i) {
result = s.(SwitchStmt).getStmt(i) or
result = s.(SwitchExpr).getStmt(i)
@@ -191,6 +182,8 @@ private module Ast implements AstSig<Location> {
}
}
class DefaultCase extends Case instanceof J::DefaultCase { }
predicate fallsThrough(Case c) { not c.(J::SwitchCase).isRule() }
class ConditionalExpr = J::ConditionalExpr;