Refactor UnreachableBasicBlock to make it clearer

This commit is contained in:
Owen Mansel-Chan
2024-11-14 14:53:12 +00:00
parent efb34aea45
commit bf0fba6c49

View File

@@ -217,13 +217,15 @@ class UnreachableBasicBlock extends BasicBlock {
not this instanceof CatchClause
or
// Switch statements with a constant comparison expression may have unreachable cases.
exists(ConstSwitchStmt constSwitchStmt, BasicBlock failingCaseBlock |
failingCaseBlock = constSwitchStmt.getAFailingCase().getBasicBlock()
|
exists(ConstSwitchStmt constSwitchStmt, BasicBlock unreachableCaseBlock |
// Not accessible from the switch expression
unreachableCaseBlock = constSwitchStmt.getAFailingCase().getBasicBlock() and
// Not accessible from the successful case
not constSwitchStmt.getMatchingCase().getBasicBlock().getABBSuccessor*() = failingCaseBlock and
// Blocks dominated by the failing case block are unreachable
failingCaseBlock.bbDominates(this)
not constSwitchStmt.getMatchingCase().getBasicBlock().getABBSuccessor*() =
unreachableCaseBlock
|
// Blocks dominated by an unreachable case block are unreachable
unreachableCaseBlock.bbDominates(this)
)
}
}