Skip to content

Commit 367a498

Browse files
committed
Python: CG trace: handle class instantiation properly in points-to
1 parent 3ead2e3 commit 367a498

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

python/tools/recorded-call-graph-metrics/ql/RecordedCalls.qll

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,14 @@ module PointsToBasedCallGraph {
248248
xmlCallee = this.getXMLCallee() and
249249
(
250250
xmlCallee instanceof XMLPythonCallee and
251-
calleeValue.(PythonFunctionValue).getScope() = xmlCallee.(XMLPythonCallee).getACallee()
251+
(
252+
// normal function
253+
calleeValue.(PythonFunctionValue).getScope() = xmlCallee.(XMLPythonCallee).getACallee()
254+
or
255+
// class instantiation -- points-to says the call goes to the class
256+
calleeValue.(ClassValue).lookup("__init__").(PythonFunctionValue).getScope() =
257+
xmlCallee.(XMLPythonCallee).getACallee()
258+
)
252259
or
253260
xmlCallee instanceof XMLExternalCallee and
254261
calleeValue.(BuiltinFunctionObjectInternal).getBuiltin() =

0 commit comments

Comments
 (0)