Skip to content

Commit 5950c33

Browse files
committed
Python: Refactor references to NormalCall.
1 parent bee073d commit 5950c33

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

python/ql/src/meta/analysis-quality/CallGraphQuality.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,20 @@ module TypeTrackingBasedCallGraph {
103103
/** A call that can be resolved by type-tracking. */
104104
class ResolvableCall extends RelevantCall {
105105
ResolvableCall() {
106-
exists(TT::TNormalCall(this, _, _))
106+
TT::resolveCall(this, _, _)
107107
or
108108
TT::resolveClassCall(this, _)
109109
}
110110

111111
/** Gets a resolved target of this call. */
112112
Target getTarget() {
113-
exists(TT::DataFlowCall call, TT::CallType ct, Function targetFunc |
114-
call = TT::TNormalCall(this, targetFunc, ct) and
113+
exists(TT::CallType ct, Function targetFunc |
114+
TT::resolveCall(this, targetFunc, ct) and
115115
not ct instanceof TT::CallTypeClass and
116116
targetFunc = result.(TargetFunction).getFunction()
117117
)
118118
or
119-
// a TT::TNormalCall only exists when the call can be resolved to a function.
119+
// TT::resolveCall only holds when the call can be resolved to a function.
120120
// Since points-to just says the call goes directly to the class itself, and
121121
// type-tracking based wants to resolve this to the constructor, which might not
122122
// exist. So to do a proper comparison, we don't require the call to be resolve to

python/ql/test/experimental/library-tests/CallGraph/InlineCallGraphTest.ql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,8 @@ predicate typeTrackerCallEdge(CallNode call, Function callable) {
3131
predicate typeTrackerClassCall(CallNode call, Function callable) {
3232
exists(call.getLocation().getFile().getRelativePath()) and
3333
exists(callable.getLocation().getFile().getRelativePath()) and
34-
exists(TT::NormalCall cc |
35-
cc = TT::TNormalCall(call, _, any(TT::TCallType t | t instanceof TT::CallTypeClass)) and
36-
TT::TFunction(callable) = TT::viableCallable(cc)
37-
)
34+
TT::resolveCall(call, callable, any(TT::TCallType t | t instanceof TT::CallTypeClass)) and
35+
TT::TFunction(callable) instanceof TT::DataFlowFunction
3836
}
3937

4038
module CallGraphTest implements TestSig {

python/ql/test/library-tests/dataflow/calls/DataFlowCallTest.ql

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ module DataFlowCallTest implements TestSig {
2121
value = prettyExpr(call.getNode().getNode()) and
2222
tag = "call"
2323
or
24-
value = call.(DataFlowDispatch::NormalCall).getCallType().toString() and
25-
tag = "callType"
24+
exists(DataFlowDispatch::CallType callType |
25+
DataFlowDispatch::resolveCall(call.getNode(), _, callType) and
26+
value = callType.toString() and
27+
tag = "callType"
28+
)
2629
or
2730
exists(DataFlowDispatch::ArgumentPosition pos, DataFlow::Node arg |
2831
arg = call.getArgument(pos)

0 commit comments

Comments
 (0)