From fd6aeba9f596567c3b295a59a8a4ef0065a87922 Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Thu, 11 Feb 2021 15:25:54 +0100 Subject: [PATCH] AST: make Expr extend Stmt --- ql/src/codeql_ruby/ast/Expr.qll | 17 +---------------- ql/src/codeql_ruby/ast/Statement.qll | 4 ++++ ql/src/codeql_ruby/ast/internal/Expr.qll | 6 ++---- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/ql/src/codeql_ruby/ast/Expr.qll b/ql/src/codeql_ruby/ast/Expr.qll index 3440d9bd6b9..bad205bd99c 100644 --- a/ql/src/codeql_ruby/ast/Expr.qll +++ b/ql/src/codeql_ruby/ast/Expr.qll @@ -1,30 +1,15 @@ private import codeql_ruby.AST -private import codeql_ruby.CFG private import internal.Expr -private import internal.Variable -private import codeql_ruby.controlflow.internal.ControlFlowGraphImpl /** * An expression. * * This is the root QL class for all expressions. */ -class Expr extends AstNode { +class Expr extends Stmt { override Expr::Range range; Expr() { this = range } - - /** Gets a control-flow node for this expression, if any. */ - CfgNodes::AstCfgNode getAControlFlowNode() { result.getNode() = this } - - /** Gets the control-flow scope of this expression, if any. */ - CfgScope getCfgScope() { result = getCfgScope(this) } - - /** Gets the variable scope that this expression belongs to. */ - VariableScope getVariableScope() { result = enclosingScope(this) } - - /** Gets the enclosing callable, if any. */ - Callable getEnclosingCallable() { result = this.getCfgScope() } } /** diff --git a/ql/src/codeql_ruby/ast/Statement.qll b/ql/src/codeql_ruby/ast/Statement.qll index b4d7ff892db..d9c284a416d 100644 --- a/ql/src/codeql_ruby/ast/Statement.qll +++ b/ql/src/codeql_ruby/ast/Statement.qll @@ -1,6 +1,7 @@ private import codeql_ruby.AST private import codeql_ruby.CFG private import internal.Statement +private import internal.Variable private import codeql_ruby.controlflow.internal.ControlFlowGraphImpl /** @@ -17,6 +18,9 @@ class Stmt extends AstNode { /** Gets the control-flow scope of this statement, if any. */ CfgScope getCfgScope() { result = getCfgScope(this) } + /** Gets the variable scope that this statement belongs to. */ + VariableScope getVariableScope() { result = enclosingScope(this) } + /** Gets the enclosing callable, if any. */ Callable getEnclosingCallable() { result = this.getCfgScope() } } diff --git a/ql/src/codeql_ruby/ast/internal/Expr.qll b/ql/src/codeql_ruby/ast/internal/Expr.qll index 575af203d61..bed8763cf36 100644 --- a/ql/src/codeql_ruby/ast/internal/Expr.qll +++ b/ql/src/codeql_ruby/ast/internal/Expr.qll @@ -1,11 +1,9 @@ private import codeql_ruby.AST -private import codeql_ruby.ast.internal.AST -private import codeql_ruby.ast.internal.Pattern +private import codeql_ruby.ast.internal.Statement private import codeql_ruby.ast.internal.TreeSitter -private import codeql_ruby.ast.internal.Variable module Expr { - abstract class Range extends AstNode::Range { } + abstract class Range extends Stmt::Range { } } module Literal {