mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
Python: support for with-definitions
This commit is contained in:
@@ -42,6 +42,19 @@ module EssaFlow {
|
||||
// nodeTo is `x`, essa var
|
||||
nodeFrom.asCfgNode() = nodeTo.asEssaNode().getDefinition().(AssignmentDefinition).getValue()
|
||||
or
|
||||
// With definition
|
||||
// `with f(42) as x:`
|
||||
// nodeFrom is `f(42)`, cfg node
|
||||
// nodeTo is `x`, essa var
|
||||
exists(With with, ControlFlowNode contextManager, ControlFlowNode var |
|
||||
nodeFrom.asCfgNode() = contextManager and
|
||||
nodeTo.asEssaNode().getDefinition().(WithDefinition).getDefiningNode() = var and
|
||||
// see `with_flow`
|
||||
with.getContextExpr() = contextManager.getNode() and
|
||||
with.getOptionalVars() = var.getNode() and
|
||||
contextManager.strictlyDominates(var)
|
||||
)
|
||||
or
|
||||
// Use
|
||||
// `y = 42`
|
||||
// `x = f(y)`
|
||||
|
||||
Reference in New Issue
Block a user