diff --git a/ql/src/codeql_ruby/ast/Expr.qll b/ql/src/codeql_ruby/ast/Expr.qll index f584b7f96f7..6f27b0462bc 100644 --- a/ql/src/codeql_ruby/ast/Expr.qll +++ b/ql/src/codeql_ruby/ast/Expr.qll @@ -73,8 +73,8 @@ class StmtSequence extends Expr, TStmtSequence { /** Gets a statement in this sequence. */ final Stmt getAStmt() { result = this.getStmt(_) } - /** Gets the last expression in this sequence, if any. */ - final Expr getLastExpr() { result = this.getStmt(this.getNumberOfStatements() - 1) } + /** Gets the last statement in this sequence, if any. */ + final Stmt getLastStmt() { result = this.getStmt(this.getNumberOfStatements() - 1) } /** Gets the number of statements in this sequence. */ final int getNumberOfStatements() { result = count(this.getAStmt()) } diff --git a/ql/src/codeql_ruby/controlflow/CfgNodes.qll b/ql/src/codeql_ruby/controlflow/CfgNodes.qll index d67849934fc..3a80fffbae4 100644 --- a/ql/src/codeql_ruby/controlflow/CfgNodes.qll +++ b/ql/src/codeql_ruby/controlflow/CfgNodes.qll @@ -284,7 +284,7 @@ module ExprNodes { } private class StmtSequenceChildMapping extends ExprChildMapping, StmtSequence { - override predicate relevantChild(Expr e) { e = this.getLastExpr() } + override predicate relevantChild(Expr e) { e = this.getLastStmt() } } /** A control-flow node that wraps a `StmtSequence` AST expression. */ @@ -293,8 +293,8 @@ module ExprNodes { final override StmtSequence getExpr() { result = ExprCfgNode.super.getExpr() } - /** Gets the last expression in this sequence, if any. */ - final ExprCfgNode getLastExpr() { e.hasCfgChild(e.getLastExpr(), this, result) } + /** Gets the last statement in this sequence, if any. */ + final ExprCfgNode getLastStmt() { e.hasCfgChild(e.getLastStmt(), this, result) } } private class ForExprChildMapping extends ExprChildMapping, ForExpr { diff --git a/ql/src/codeql_ruby/controlflow/internal/Completion.qll b/ql/src/codeql_ruby/controlflow/internal/Completion.qll index b25098b2a06..dc80bbb98f2 100644 --- a/ql/src/codeql_ruby/controlflow/internal/Completion.qll +++ b/ql/src/codeql_ruby/controlflow/internal/Completion.qll @@ -176,7 +176,7 @@ private predicate inBooleanContext(AstNode n) { or n = any(NotExpr parent | inBooleanContext(parent)).getOperand() or - n = any(StmtSequence parent | inBooleanContext(parent)).getLastExpr() + n = any(StmtSequence parent | inBooleanContext(parent)).getLastStmt() or exists(CaseExpr c, WhenExpr w | not exists(c.getValue()) and diff --git a/ql/src/codeql_ruby/controlflow/internal/Splitting.qll b/ql/src/codeql_ruby/controlflow/internal/Splitting.qll index 7a81548ed5d..8543c64f055 100644 --- a/ql/src/codeql_ruby/controlflow/internal/Splitting.qll +++ b/ql/src/codeql_ruby/controlflow/internal/Splitting.qll @@ -226,7 +226,7 @@ private module ConditionalCompletionSplitting { last(succ.(LogicalOrExpr).getAnOperand(), pred, c) and completion = c or - last(succ.(ParenthesizedExpr).getLastExpr(), pred, c) and + last(succ.(StmtSequence).getLastStmt(), pred, c) and completion = c or last(succ.(ConditionalExpr).getBranch(_), pred, c) and diff --git a/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll b/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll index 222fa8ac7bb..2352f9c4693 100644 --- a/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll +++ b/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll @@ -126,7 +126,7 @@ private module Cached { or nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::AssignExprCfgNode).getRhs() or - nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::StmtSequenceCfgNode).getLastExpr() + nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::StmtSequenceCfgNode).getLastStmt() or nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::ConditionalExprCfgNode).getBranch(_) or