From 93a84684a5eefe0b9df54a69960742cf26dc8e66 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Wed, 5 Feb 2020 13:42:06 +0000 Subject: [PATCH] Remove predicate `CallExpr.calls`. This sort of reasoning should be done at the data-flow level. --- ql/src/semmle/go/Expr.qll | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/ql/src/semmle/go/Expr.qll b/ql/src/semmle/go/Expr.qll index 2fa9559809c..b86c73d3697 100644 --- a/ql/src/semmle/go/Expr.qll +++ b/ql/src/semmle/go/Expr.qll @@ -442,14 +442,6 @@ class CallExpr extends CallOrConversionExpr { /** Gets the expression representing the function being called. */ Expr getCalleeExpr() { result = getChildExpr(0) } - /** Holds if this call is of the form `base.method(...)`. */ - predicate calls(Expr base, string method) { - exists(SelectorExpr callee | callee = getCalleeExpr().stripParens() | - callee.getBase() = base and - method = callee.getSelector().getName() - ) - } - /** Gets the `i`th argument expression of this call (0-based). */ Expr getArgument(int i) { i >= 0 and @@ -462,10 +454,13 @@ class CallExpr extends CallOrConversionExpr { /** Gets the number of argument expressions of this call. */ int getNumArgument() { result = count(getAnArgument()) } - /** Gets the name of the invoked function or method. */ + /** Gets the name of the invoked function or method if it can be determined syntactically. */ string getCalleeName() { - result = getCalleeExpr().stripParens().(Ident).getName() or - calls(_, result) + exists(Expr callee | callee = getCalleeExpr().stripParens() | + result = callee.(Ident).getName() + or + result = callee.(SelectorExpr).getSelector().getName() + ) } /** Gets the declared target of this call. */