From 39b7272241cd461546c61474655a45bf99c8cfb7 Mon Sep 17 00:00:00 2001 From: Max Schaefer Date: Wed, 5 Feb 2020 13:56:47 +0000 Subject: [PATCH] Teach `Function.getACall` to take virtual dispatch into account. --- ql/src/semmle/go/Scopes.qll | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ql/src/semmle/go/Scopes.qll b/ql/src/semmle/go/Scopes.qll index dc6e8ef52b9..0fc1060e18f 100644 --- a/ql/src/semmle/go/Scopes.qll +++ b/ql/src/semmle/go/Scopes.qll @@ -280,7 +280,11 @@ class Function extends ValueEntity, @functionobject { CallExpr getACallExpr() { result.getCalleeExpr() = getAReference() } /** Gets a call to this function. */ - DataFlow::CallNode getACall() { result.getExpr() = getACallExpr() } + DataFlow::CallNode getACall() { + this = result.getTarget() + or + this.(DeclaredFunction).getFuncDecl() = result.getACallee() + } /** Holds if this function has no observable side effects. */ predicate mayHaveSideEffects() { none() }