Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c9e3a62

Browse files
committed
cached stages iteration 5
1 parent a8f9a91 commit c9e3a62

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,9 @@ class UnaryExprNode extends ControlFlowNode {
619619
* and nodes implicitly assigned in class and function definitions and imports.
620620
*/
621621
class DefinitionNode extends ControlFlowNode {
622+
cached
622623
DefinitionNode() {
624+
Stages::SSA::ref() and
623625
exists(Assign a | a.getATarget().getAFlowNode() = this)
624626
or
625627
exists(AnnAssign a | a.getTarget().getAFlowNode() = this and exists(a.getValue()))
@@ -678,6 +680,7 @@ abstract class SequenceNode extends ControlFlowNode {
678680
ControlFlowNode getAnElement() { result = this.getElement(_) }
679681

680682
/** Gets the control flow node for the nth element of this sequence */
683+
cached
681684
abstract ControlFlowNode getElement(int n);
682685
}
683686

@@ -686,6 +689,7 @@ class TupleNode extends SequenceNode {
686689
TupleNode() { toAst(this) instanceof Tuple }
687690

688691
override ControlFlowNode getElement(int n) {
692+
Stages::SSA::ref() and
689693
exists(Tuple t | this.getNode() = t and result.getNode() = t.getElt(n)) and
690694
(
691695
result.getBasicBlock().dominates(this.getBasicBlock())

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ module Stages {
8686
any(PyFlow::BasicBlock b).dominates(_)
8787
or
8888
exists(any(PyFlow::ControlFlowNode b).getScope())
89+
or
90+
exists(PyFlow::DefinitionNode b)
91+
or
92+
exists(any(PyFlow::SequenceNode n).getElement(_))
8993
}
9094
}
9195

0 commit comments

Comments
 (0)