mirror of
https://github.com/github/codeql.git
synced 2026-04-30 19:26:02 +02:00
Python: Add IterableNode
I'm specifically not using an abstract class, since that is an anti-pattern: https://github.com/github/codeql/pull/4357#discussion_r520526275 (I'm still trying to wrap my head fully aroudn this)
This commit is contained in:
@@ -772,6 +772,25 @@ class DictNode extends ControlFlowNode {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A control flow node corresponding to an iterable literal. Currently does not include
|
||||
* dictionaries, use `DictNode` directly instead.
|
||||
*/
|
||||
class IterableNode extends ControlFlowNode {
|
||||
IterableNode() {
|
||||
this instanceof SequenceNode
|
||||
or
|
||||
this instanceof SetNode
|
||||
}
|
||||
|
||||
/** Gets the control flow node for an element of this iterable. */
|
||||
ControlFlowNode getAnElement() {
|
||||
result = this.(SequenceNode).getAnElement()
|
||||
or
|
||||
result = this.(SetNode).getAnElement()
|
||||
}
|
||||
}
|
||||
|
||||
private AstNode assigned_value(Expr lhs) {
|
||||
/* lhs = result */
|
||||
exists(Assign a | a.getATarget() = lhs and result = a.getValue())
|
||||
|
||||
Reference in New Issue
Block a user