mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #20300 from aschackmull/cfg/successortype
Shared: Add a shared SuccessorType implementation
This commit is contained in:
@@ -1259,9 +1259,9 @@ private class ControlFlowNodeAlias = ControlFlowNode;
|
||||
final private class FinalBasicBlock = BasicBlock;
|
||||
|
||||
module Cfg implements BB::CfgSig<Location> {
|
||||
class ControlFlowNode = ControlFlowNodeAlias;
|
||||
private import codeql.controlflow.SuccessorType
|
||||
|
||||
class SuccessorType = Unit;
|
||||
class ControlFlowNode = ControlFlowNodeAlias;
|
||||
|
||||
class BasicBlock extends FinalBasicBlock {
|
||||
// Note `PY:BasicBlock` does not have a `getLocation`.
|
||||
@@ -1275,7 +1275,24 @@ module Cfg implements BB::CfgSig<Location> {
|
||||
|
||||
BasicBlock getASuccessor() { result = super.getASuccessor() }
|
||||
|
||||
BasicBlock getASuccessor(SuccessorType t) { result = super.getASuccessor() and exists(t) }
|
||||
private BasicBlock getANonDirectSuccessor(SuccessorType t) {
|
||||
result = this.getATrueSuccessor() and
|
||||
t.(BooleanSuccessor).getValue() = true
|
||||
or
|
||||
result = this.getAFalseSuccessor() and
|
||||
t.(BooleanSuccessor).getValue() = false
|
||||
or
|
||||
result = this.getAnExceptionalSuccessor() and
|
||||
t instanceof ExceptionSuccessor
|
||||
}
|
||||
|
||||
BasicBlock getASuccessor(SuccessorType t) {
|
||||
result = this.getANonDirectSuccessor(t)
|
||||
or
|
||||
result = super.getASuccessor() and
|
||||
t instanceof DirectSuccessor and
|
||||
not result = this.getANonDirectSuccessor(_)
|
||||
}
|
||||
|
||||
predicate strictlyDominates(BasicBlock bb) { super.strictlyDominates(bb) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user