mirror of
https://github.com/github/codeql.git
synced 2026-03-30 20:28:15 +02:00
Cfg: Move getCaseControlFlowOrder to shared code.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user