mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
cache more basicblock predicates
This commit is contained in:
@@ -1012,9 +1012,7 @@ class BasicBlock extends @py_flow_node {
|
||||
}
|
||||
|
||||
/** Whether this basic block dominates the other */
|
||||
cached
|
||||
predicate dominates(BasicBlock other) {
|
||||
Stages::AST::ref() and
|
||||
this = other
|
||||
or
|
||||
this.strictlyDominates(other)
|
||||
@@ -1060,7 +1058,11 @@ class BasicBlock extends @py_flow_node {
|
||||
}
|
||||
|
||||
/** Gets a successor to this basic block */
|
||||
BasicBlock getASuccessor() { result = this.getLastNode().getASuccessor().getBasicBlock() }
|
||||
cached
|
||||
BasicBlock getASuccessor() {
|
||||
Stages::AST::ref() and
|
||||
result = this.getLastNode().getASuccessor().getBasicBlock()
|
||||
}
|
||||
|
||||
/** Gets a predecessor to this basic block */
|
||||
BasicBlock getAPredecessor() { result.getASuccessor() = this }
|
||||
@@ -1130,7 +1132,11 @@ class BasicBlock extends @py_flow_node {
|
||||
}
|
||||
|
||||
/** Holds if this basic block strictly reaches the other. Is the start of other reachable from the end of this. */
|
||||
predicate strictlyReaches(BasicBlock other) { this.getASuccessor+() = other }
|
||||
cached
|
||||
predicate strictlyReaches(BasicBlock other) {
|
||||
Stages::AST::ref() and
|
||||
this.getASuccessor+() = other
|
||||
}
|
||||
|
||||
/** Holds if this basic block reaches the other. Is the start of other reachable from the end of this. */
|
||||
predicate reaches(BasicBlock other) { this = other or this.strictlyReaches(other) }
|
||||
|
||||
@@ -80,7 +80,9 @@ module Stages {
|
||||
or
|
||||
any(PyFlow::BasicBlock b).strictlyDominates(_)
|
||||
or
|
||||
any(PyFlow::BasicBlock b).dominates(_)
|
||||
any(PyFlow::BasicBlock b).strictlyReaches(_)
|
||||
or
|
||||
exists(any(PyFlow::BasicBlock b).getASuccessor())
|
||||
or
|
||||
exists(any(PyFlow::ControlFlowNode b).getScope())
|
||||
or
|
||||
|
||||
Reference in New Issue
Block a user