cached stages iteration 3.5

This commit is contained in:
Erik Krogh Kristensen
2021-12-08 01:00:34 +01:00
parent 37a9b41e26
commit f68357a063
2 changed files with 15 additions and 2 deletions

View File

@@ -47,10 +47,18 @@ abstract class AstNode extends AstNode_ {
* Expr.getASubExpression(), Stmt.getASubStatement(), Stmt.getASubExpression() or
* Scope.getAStmt() applied to the parent.
*/
AstNode getParentNode() { result.getAChildNode() = this }
cached
AstNode getParentNode() {
Stages::SSA::ref() and
result.getAChildNode() = this
}
/** Whether this contains `inner` syntactically */
predicate contains(AstNode inner) { this.getAChildNode+() = inner }
cached
predicate contains(AstNode inner) {
Stages::SSA::ref() and
this.getAChildNode+() = inner
}
pragma[noinline]
private predicate containsInScope(AstNode inner, Scope scope) {
@@ -114,6 +122,7 @@ class Comprehension extends Comprehension_, AstNode {
result = Comprehension_.super.getLocation()
}
pragma[nomagic]
override AstNode getAChildNode() {
Stages::SSA::ref() and
result = this.getASubExpression()

View File

@@ -75,6 +75,10 @@ module Stages {
or
exists(any(AstExtended::AstNode n).getAChildNode())
or
exists(any(AstExtended::AstNode n).getParentNode())
or
any(AstExtended::AstNode n).contains(_)
or
exists(any(PyFlow::BasicBlock b).getImmediateDominator())
or
any(PyFlow::BasicBlock b).strictlyDominates(_)