mirror of
https://github.com/github/codeql.git
synced 2025-12-21 11:16:30 +01:00
(and for * patterns in match)
Since `PhaseDependentFlow` uses the following predicate, that relies on
.getScope() to be present for there to be any importTimeFlow (flow at
toplevel scope), it's important that data-flow nodes implement `.getScope`.
```
private predicate isTopLevel(Node node) { node.getScope() instanceof Module }
```
By implementing getScope, we can now rely on default implementation of
`getEnclosingCallable` in DataFlow::Node:
```
/** Gets the enclosing callable of this node. */
DataFlowCallable getEnclosingCallable() { result = getCallableScope(this.getScope()) }
```
8 lines
187 B
Python
8 lines
187 B
Python
# this test has code on module level, which works in slightly different ways than when
|
|
# inside a function
|
|
|
|
t = (SOURCE, NONSOURCE)
|
|
a, b = t
|
|
SINK(a) #$ flow="SOURCE, l:-2 -> a"
|
|
SINK_F(b)
|