From daa7bd7fd4ae498a6aaefbd6816c783970619ff4 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Tue, 9 Feb 2021 14:01:08 +0100 Subject: [PATCH] Move ReturningStmt::getValue implementation to internal library --- ql/src/codeql_ruby/ast/Statement.qll | 11 +---------- ql/src/codeql_ruby/ast/internal/Statement.qll | 10 ++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/ql/src/codeql_ruby/ast/Statement.qll b/ql/src/codeql_ruby/ast/Statement.qll index 79f8dc935d5..edc62cf0627 100644 --- a/ql/src/codeql_ruby/ast/Statement.qll +++ b/ql/src/codeql_ruby/ast/Statement.qll @@ -2,7 +2,6 @@ private import codeql_ruby.AST private import codeql_ruby.CFG private import internal.Statement private import codeql_ruby.controlflow.internal.ControlFlowGraphImpl -private import codeql_ruby.ast.internal.TreeSitter /** * A statement. @@ -42,15 +41,7 @@ class ReturningStmt extends Stmt { final override string toString() { result = range.toString() } /** Gets the returned value, if any. */ - final Expr getValue() { - exists(Generated::ArgumentList a, int c | - a = range.getArgumentList() and c = count(a.getChild(_)) - | - result = a.getChild(0) and c = 1 - or - result = a and c > 1 - ) - } + final Expr getValue() { result = range.getValue() } } /** diff --git a/ql/src/codeql_ruby/ast/internal/Statement.qll b/ql/src/codeql_ruby/ast/internal/Statement.qll index 3d61261e37e..2a3a7ce1ef4 100644 --- a/ql/src/codeql_ruby/ast/internal/Statement.qll +++ b/ql/src/codeql_ruby/ast/internal/Statement.qll @@ -8,6 +8,16 @@ module Stmt { module ReturningStmt { abstract class Range extends Stmt::Range { abstract Generated::ArgumentList getArgumentList(); + + final Expr getValue() { + exists(Generated::ArgumentList a, int c | + a = this.getArgumentList() and c = count(a.getChild(_)) + | + result = a.getChild(0) and c = 1 + or + result = a and c > 1 + ) + } } }