Fix guard basic block for switch cases

This commit is contained in:
Chris Smowton
2023-11-16 16:49:19 +00:00
parent 6583c72c5d
commit c1814408f0
2 changed files with 33 additions and 3 deletions

View File

@@ -450,6 +450,20 @@ class SwitchCase extends Stmt, @case {
result = this.getSwitch().getExpr() or result = this.getSwitchExpr().getExpr()
}
/**
* Gets the `i`th case in this case's switch block.
*/
SwitchCase getSiblingCase(int i) {
result = this.getSwitch().getCase(i) or result = this.getSwitchExpr().getCase(i)
}
/**
* Gets this case's ordinal in its switch block.
*/
int getCaseIndex() {
this = this.getSwitch().getCase(result) or this = this.getSwitchExpr().getCase(result)
}
/**
* Holds if this `case` is a switch labeled rule of the form `... -> ...`.
*/