Skip to content

Commit f3c1c53

Browse files
committed
Add CallExpr.getCalleeType()
This avoids using `getTarget()`, so it works even when that doesn't exist (for example when calling a variable with function type).
1 parent 3f095db commit f3c1c53

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

go/ql/lib/semmle/go/Expr.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,15 @@ class CallExpr extends CallOrConversionExpr {
885885
)
886886
}
887887

888+
/**
889+
* Gets the signature type of the invoked function.
890+
*
891+
* Note that it avoids calling `getTarget()` so that it works even when that
892+
* predicate isn't defined, for example when calling a variable with function
893+
* type.
894+
*/
895+
SignatureType getCalleeType() { result = this.getCalleeExpr().getType() }
896+
888897
/** Gets the declared target of this call. */
889898
Function getTarget() { this.getCalleeExpr() = result.getAReference() }
890899

0 commit comments

Comments
 (0)