8000 `CallExpr.getCalleeExpr` should get uninstantiated function · github/codeql-go@ce9c9cf · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit ce9c9cf

Browse files
owen-mcsmowton
authored andcommitted
CallExpr.getCalleeExpr should get uninstantiated function
1 parent 7a7ca61 commit ce9c9cf

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

ql/lib/semmle/go/Expr.qll

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,11 @@ class CallExpr extends CallOrConversionExpr {
839839
}
840840

841841
/** Gets the expression representing the function being called. */
842-
Expr getCalleeExpr() { result = this.getChildExpr(0) }
842+
Expr getCalleeExpr() {
843+
if this.getChildExpr(0) instanceof GenericFunctionInstantiationExpr
844+
then result = this.getChildExpr(0).(GenericFunctionInstantiationExpr).getBase()
845+
else result = this.getChildExpr(0)
846+
}
843847

844848
/** Gets the `i`th argument expression of this call (0-based). */
845849
Expr getArgument(int i) {
@@ -866,16 +870,11 @@ class CallExpr extends CallOrConversionExpr {
866870
result = callee.(Ident).getName()
867871
or
868872
result = callee.(SelectorExpr).getSelector().getName()
869-
or
870-
result = callee.(GenericFunctionInstantiationExpr).getBase().(Ident).getName()
871873
)
872874
}
873875

874876
/** Gets the declared target of this call. */
875-
Function getTarget() {
876-
this.getCalleeExpr() = result.getAReference() or
877-
this.getCalleeExpr().(GenericFunctionInstantiationExpr).getBase() = result.getAReference()
878-
}
877+
Function getTarget() { this.getCalleeExpr() = result.getAReference() }
879878

880879
/** Holds if this call has an ellipsis after its last argument. */
881880
predicate hasEllipsis() { has_ellipsis(this) }

0 commit comments

Comments
 (0)
0