Skip to content

Commit 25043f5

Browse files
authored
Merge pull request github#11376 from RasmusWL/call-graph-code
Python: New type-tracking based call-graph
2 parents 5cb3279 + c4fbfb0 commit 25043f5

File tree

208 files changed

+5048
-2392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+5048
-2392
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
category: majorAnalysis
3+
---
4+
* We use a new analysis for the call-graph (determining which function is called). This can lead to changed results. In most cases this is much more accurate than the old call-graph that was based on points-to, but we do lose a few valid edges in the call-graph, especially around methods that are not defined inside its' class.

python/ql/lib/semmle/python/Flow.qll

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class ControlFlowNode extends @py_flow_node {
125125
/** Gets a textual representation of this element. */
126126
cached
127127
string toString() {
128-
Stages::DataFlow::ref() and
128+
Stages::AST::ref() and
129129
exists(Scope s | s.getEntryNode() = this | result = "Entry node for " + s.toString())
130130
or
131131
exists(Scope s | s.getANormalExit() = this | result = "Exit node for " + s.toString())
@@ -411,6 +411,12 @@ class CallNode extends ControlFlowNode {
411411
result.getNode() = this.getNode().getStarArg() and
412412
result.getBasicBlock().dominates(this.getBasicBlock())
413413
}
414+
415+
/** Gets a dictionary (**) argument of this call, if any. */
416+
ControlFlowNode getKwargs() {
417+
result.getNode() = this.getNode().getKwargs() and
418+
result.getBasicBlock().dominates(this.getBasicBlock())
419+
}
414420
}
415421

416422
/** A control flow corresponding to an attribute expression, such as `value.attr` */

0 commit comments

Comments
 (0)