Skip to content

Commit 456209b

Browse files
committed
Python: Move predicate closer to its use
1 parent 86bb884 commit 456209b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

python/ql/lib/semmle/python/dataflow/new/internal/VariableCapture.qll

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ private module CaptureInput implements Shared::InputSig<Location> {
1717
ExprCfgNode() { isExpressionNode(this) }
1818
}
1919

20-
private predicate closureFlowStep(ExprCfgNode nodeFrom, ExprCfgNode nodeTo) {
21-
// TODO: Other languages have an extra case here looking like
22-
// simpleAstFlowStep(nodeFrom, nodeTo)
23-
// we should investigate the potential benefit of adding that.
24-
exists(SsaVariable def |
25-
def.getAUse() = nodeTo and
26-
def.getAnUltimateDefinition().getDefinition().(DefinitionNode).getValue() = nodeFrom
27-
)
28-
}
29-
3020
class Callable extends Scope {
3121
predicate isConstructor() { none() }
3222
}
@@ -95,6 +85,16 @@ private module CaptureInput implements Shared::InputSig<Location> {
9585
CapturedVariable getVariable() { result = v }
9686
}
9787

88+
private predicate closureFlowStep(ExprCfgNode nodeFrom, ExprCfgNode nodeTo) {
89+
// TODO: Other languages have an extra case here looking like
90+
// simpleAstFlowStep(nodeFrom, nodeTo)
91+
// we should investigate the potential benefit of adding that.
92+
exists(SsaVariable def |
93+
def.getAUse() = nodeTo and
94+
def.getAnUltimateDefinition().getDefinition().(DefinitionNode).getValue() = nodeFrom
95+
)
96+
}
97+
9898
class ClosureExpr extends Expr {
9999
ClosureExpr() {
100100
this.getNode() instanceof CallableExpr

0 commit comments

Comments
 (0)