Python: change type of LibraryCallable::getACall

The other callables return control flow nodes,
so it is slightly inconsistent for this to return a
data flow node, but it does make models based
on API graphs nicer.
This commit is contained in:
Rasmus Lerchedahl Petersen
2022-09-19 14:02:52 +02:00
parent 33b508d6e6
commit 37fb27fa1c
4 changed files with 25 additions and 15 deletions

View File

@@ -84,10 +84,10 @@ private class SummarizedCallableFromModel extends SummarizedCallable {
this = package + ";" + type + ";" + path
}
override CallNode getACall() {
override CallCfgNode getACall() {
exists(API::CallNode base |
ModelOutput::resolvedSummaryBase(package, type, path, base) and
result = base.asCfgNode()
result = base.getACall()
)
}

View File

@@ -281,7 +281,7 @@ abstract class LibraryCallable extends string {
LibraryCallable() { any() }
/** Gets a call to this library callable. */
abstract CallNode getACall();
abstract CallCfgNode getACall();
/** Gets a data-flow node, where this library callable is used as a call-back. */
abstract ArgumentNode getACallback();
@@ -398,7 +398,7 @@ class LibraryCallableValue extends DataFlowCallable, TLibraryCallable {
override string toString() { result = callable.toString() }
override CallNode getACall() { result = callable.getACall() }
override CallNode getACall() { result = callable.getACall().getNode() }
/** Gets a data-flow node, where this library callable is used as a call-back. */
ArgumentNode getACallback() { result = callable.getACallback() }
@@ -772,7 +772,7 @@ DataFlowCallable viableCallable(DataFlowSourceCall call) {
// Instead we reolve the call from the summary.
exists(LibraryCallable callable |
result = TLibraryCallable(callable) and
call.getNode() = callable.getACall()
call.getNode() = callable.getACall().getNode()
)
}

View File

@@ -10,7 +10,7 @@ private import semmle.python.ApiGraphs
class ReversedSummary extends SummarizedCallable {
ReversedSummary() { this = "builtins.reversed" }
override CallNode getACall() { result = API::builtin("reversed").getACall().getNode() }
override DataFlow::CallCfgNode getACall() { result = API::builtin("reversed").getACall() }
override DataFlow::ArgumentNode getACallback() {
result = API::builtin("reversed").getAValueReachableFromSource()