Skip to content

Commit b74852f

Browse files
committed
cache a bit more (again)
1 parent d9ced55 commit b74852f

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

python/ql/lib/semmle/python/AstExtended.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ abstract class AstNode extends AstNode_ {
1818
* NOTE: For some statements and other purely syntactic elements,
1919
* there may not be a `ControlFlowNode`
2020
*/
21-
ControlFlowNode getAFlowNode() { py_flow_bb_node(result, this, _, _) }
21+
cached
22+
ControlFlowNode getAFlowNode() {
23+
Stages::AST::ref() and
24+
py_flow_bb_node(result, this, _, _)
25+
}
2226

2327
/** Gets the location for this AST node */
2428
cached

python/ql/lib/semmle/python/Flow.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,9 @@ class ControlFlowNode extends @py_flow_node {
194194
BasicBlock getBasicBlock() { result.contains(this) }
195195

196196
/** Gets the scope containing this flow node */
197+
cached
197198
Scope getScope() {
199+
Stages::AST::ref() and
198200
if this.getNode() instanceof Scope
199201
then
200202
/* Entry or exit node */

python/ql/lib/semmle/python/internal/CachedStages.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ module Stages {
7676
or
7777
exists(any(AstExtended::AstNode n).getParentNode())
7878
or
79+
exists(any(AstExtended::AstNode n).getAFlowNode())
80+
or
7981
exists(any(PyFlow::BasicBlock b).getImmediateDominator())
8082
or
83+
exists(any(PyFlow::BasicBlock b).getScope())
84+
or
8185
any(PyFlow::BasicBlock b).strictlyDominates(_)
8286
or
8387
any(PyFlow::BasicBlock b).strictlyReaches(_)
@@ -141,7 +145,6 @@ module Stages {
141145
private import semmle.python.objects.TObject as TObject
142146
private import semmle.python.Flow as Flow
143147
private import semmle.python.objects.ObjectInternal as ObjectInternal
144-
private import semmle.python.objects.ObjectAPI as ObjectAPI
145148
private import semmle.python.pointsto.PointsTo as PointsTo
146149

147150
/**

0 commit comments

Comments
 (0)