From 46a8f8c8edeb21618ea9ea909e34988ef829a23d Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Wed, 5 Feb 2020 13:57:03 +0000 Subject: [PATCH] Remove `Function.getACallExpr`. --- ql/src/RedundantCode/NegativeLengthCheck.ql | 4 ++-- ql/src/semmle/go/Expr.qll | 2 +- ql/src/semmle/go/Scopes.qll | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ql/src/RedundantCode/NegativeLengthCheck.ql b/ql/src/RedundantCode/NegativeLengthCheck.ql index c199d09fbc8..491d286f0b9 100644 --- a/ql/src/RedundantCode/NegativeLengthCheck.ql +++ b/ql/src/RedundantCode/NegativeLengthCheck.ql @@ -16,7 +16,7 @@ where (len = Builtin::len() or len = Builtin::cap()) and ( exists(RelationalComparisonExpr rel | rel = cmp | - rel.getLesserOperand() = len.getACallExpr() and + rel.getLesserOperand() = len.getACall().asExpr() and rel.getGreaterOperand().getIntValue() = ub and ( ub < 0 @@ -27,7 +27,7 @@ where ) or exists(EqualityTestExpr eq | eq = cmp | - eq.getAnOperand() = len.getACallExpr() and + eq.getAnOperand() = len.getACall().asExpr() and eq.getAnOperand().getIntValue() = ub and ub < 0 and r = "equal" diff --git a/ql/src/semmle/go/Expr.qll b/ql/src/semmle/go/Expr.qll index 3ea5102d7b6..857a7e487ef 100644 --- a/ql/src/semmle/go/Expr.qll +++ b/ql/src/semmle/go/Expr.qll @@ -464,7 +464,7 @@ class CallExpr extends CallOrConversionExpr { } /** Gets the declared target of this call. */ - Function getTarget() { this = result.getACallExpr() } + Function getTarget() { getCalleeExpr() = result.getAReference() } override predicate mayHaveOwnSideEffects() { getTarget().mayHaveSideEffects() or diff --git a/ql/src/semmle/go/Scopes.qll b/ql/src/semmle/go/Scopes.qll index 0fc1060e18f..f1407576764 100644 --- a/ql/src/semmle/go/Scopes.qll +++ b/ql/src/semmle/go/Scopes.qll @@ -276,9 +276,6 @@ class Field extends Variable { /** A built-in or declared function. */ class Function extends ValueEntity, @functionobject { - /** Gets an expression representing a call to this function. */ - CallExpr getACallExpr() { result.getCalleeExpr() = getAReference() } - /** Gets a call to this function. */ DataFlow::CallNode getACall() { this = result.getTarget()