Python: Cleanup, docs, and an extra test case

This commit is contained in:
Taus Brock-Nannestad
2020-09-16 14:46:04 +02:00
parent 7cdd290b90
commit 2d3e23ebb0
3 changed files with 11 additions and 4 deletions

View File

@@ -240,6 +240,7 @@ class DataFlowClassValue extends DataFlowCallable, TClassValue {
override string getName() { result = c.getName() }
}
/** A class representing the scope in which a `ModuleVariableNode` appears. */
class DataFlowModuleScope extends DataFlowCallable, TModule {
Module mod;

View File

@@ -150,6 +150,7 @@ class ParameterNode extends EssaNode {
override DataFlowCallable getEnclosingCallable() { this.isParameterOf(result, _) }
}
/** A data flow node corresponding to a module-level (global) variable that is accessed outside of the module scope. */
class ModuleVariableNode extends Node, TModuleVariableNode {
Module mod;
GlobalVariable var;
@@ -176,10 +177,8 @@ class ModuleVariableNode extends Node, TModuleVariableNode {
}
/** Gets an `EssaNode` that corresponds to an assignment of this global variable. */
Node getAWrite() {
exists(DefinitionNode defn |
result.asVar().getDefinition().(EssaNodeDefinition).definedBy(var, defn)
)
EssaNode getAWrite() {
result.asVar().getDefinition().(EssaNodeDefinition).definedBy(var, any(DefinitionNode defn))
}
override DataFlowCallable getEnclosingCallable() { result.(DataFlowModuleScope).getScope() = mod }