File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
python/ql/src/experimental/dataflow/internal Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,37 @@ class ParameterNode extends EssaNode {
150150 override DataFlowCallable getEnclosingCallable ( ) { this .isParameterOf ( result , _) }
151151}
152152
153- /** A data flow node corresponding to a module-level (global) variable that is accessed outside of the module scope. */
153+ /**
154+ * A data flow node corresponding to a module-level (global) variable that is accessed outside of the module scope.
155+ *
156+ * Global variables may appear twice in the data flow graph, as both `EssaNode`s and
157+ * `ModuleVariableNode`s. The former is used to represent data flow between global variables as it
158+ * occurs during module initialization, and the latter is used to represent data flow via global
159+ * variable reads and writes during run-time.
160+ *
161+ * It is possible for data to flow from assignments made at module initialization time to reads made
162+ * at run-time, but not vice versa. For example, there will be flow from `SOURCE` to `SINK` in the
163+ * following snippet:
164+ *
165+ * ```python
166+ * g = SOURCE
167+ *
168+ * def foo():
169+ * SINK(g)
170+ * ```
171+ * but not the other way round:
172+ *
173+ * ```python
174+ * SINK(g)
175+ *
176+ * def bar()
177+ * global g
178+ * g = SOURCE
179+ * ```
180+ *
181+ * Data flow through `ModuleVariableNode`s is represented as `jumpStep`s, and so any write of a
182+ * global variable can flow to any read of the same variable.
183+ */
154184class ModuleVariableNode extends Node , TModuleVariableNode {
155185 Module mod ;
156186 GlobalVariable var ;
You can’t perform that action at this time.
0 commit comments