File tree Expand file tree Collapse file tree
python/ql/lib/semmle/python Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -619,7 +619,9 @@ class UnaryExprNode extends ControlFlowNode {
619619 * and nodes implicitly assigned in class and function definitions and imports.
620620 */
621621class 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 ( ) )
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments