Python: Disallow PostUpdateNode as LocalSourceNode

Previously, in cases like

```python
def foo(x):
    x.bar()
    x.baz()
    x.quux()
```

we would have flow from the first `x` to each use _and_ flow from the
post-update node for each method call to each subsequent use, and all
of these would be `LocalSourceNode`s. For large functions with the above
pattern, this would lead to a quadratic blowup in `hasLocalSource`.

With this commit, only the first of these will count as a
`LocalSourceNode`, and the blowup disappears.
This commit is contained in:
Taus
2021-04-15 17:56:14 +00:00
committed by GitHub
parent 591ac38c31
commit c9c8259ed0

View File

@@ -26,7 +26,8 @@ class LocalSourceNode extends Node {
cached
LocalSourceNode() {
not comes_from_cfgnode(this) and
not this instanceof ModuleVariableNode
not this instanceof ModuleVariableNode and
not this instanceof PostUpdateNode
or
this = any(ModuleVariableNode mvn).getARead()
}