Skip to content

Commit 098f8c4

Browse files
committed
Python: Add IterableNode
I'm specifically not using an abstract class, since that is an anti-pattern: #4357 (comment) (I'm still trying to wrap my head fully aroudn this)
1 parent 33e46e1 commit 098f8c4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

python/ql/src/semmle/python/Flow.qll

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,25 @@ class DictNode extends ControlFlowNode {
772772
}
773773
}
774774

775+
/**
776+
* A control flow node corresponding to an iterable literal. Currently does not include
777+
* dictionaries, use `DictNode` directly instead.
778+
*/
779+
class IterableNode extends ControlFlowNode {
780+
IterableNode() {
781+
this instanceof SequenceNode
782+
or
783+
this instanceof SetNode
784+
}
785+
786+
/** Gets the control flow node for an element of this iterable. */
787+
ControlFlowNode getAnElement() {
788+
result = this.(SequenceNode).getAnElement()
789+
or
790+
result = this.(SetNode).getAnElement()
791+
}
792+
}
793+
775794
private AstNode assigned_value(Expr lhs) {
776795
/* lhs = result */
777796
exists(Assign a | a.getATarget() = lhs and result = a.getValue())

0 commit comments

Comments
 (0)