diff --git a/ruby/ql/lib/codeql/ruby/ast/Control.qll b/ruby/ql/lib/codeql/ruby/ast/Control.qll index 765a09e472c..b4862724763 100644 --- a/ruby/ql/lib/codeql/ruby/ast/Control.qll +++ b/ruby/ql/lib/codeql/ruby/ast/Control.qll @@ -102,7 +102,7 @@ class IfExpr extends ConditionalExpr, TIfExpr { cond = false and result = this.getElse() } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = super.getAChild(pred) or pred = "getThen" and result = this.getThen() @@ -192,8 +192,8 @@ class UnlessExpr extends ConditionalExpr, TUnlessExpr { final override string toString() { result = "unless ..." } - override AstNode getAChild(string pred) { - result = ConditionalExpr.super.getAChild(pred) + final override AstNode getAChild(string pred) { + result = super.getAChild(pred) or pred = "getThen" and result = this.getThen() or @@ -229,8 +229,8 @@ class IfModifierExpr extends ConditionalExpr, TIfModifierExpr { final override string toString() { result = "... if ..." } - override AstNode getAChild(string pred) { - result = ConditionalExpr.super.getAChild(pred) + final override AstNode getAChild(string pred) { + result = super.getAChild(pred) or pred = "getBody" and result = this.getBody() } @@ -264,8 +264,8 @@ class UnlessModifierExpr extends ConditionalExpr, TUnlessModifierExpr { final override string toString() { result = "... unless ..." } - override AstNode getAChild(string pred) { - result = ConditionalExpr.super.getAChild(pred) + final override AstNode getAChild(string pred) { + result = super.getAChild(pred) or pred = "getBody" and result = this.getBody() } @@ -300,8 +300,8 @@ class TernaryIfExpr extends ConditionalExpr, TTernaryIfExpr { final override string toString() { result = "... ? ... : ..." } - override AstNode getAChild(string pred) { - result = ConditionalExpr.super.getAChild(pred) + final override AstNode getAChild(string pred) { + result = super.getAChild(pred) or pred = "getThen" and result = this.getThen() or @@ -390,7 +390,7 @@ class CaseExpr extends ControlExpr instanceof CaseExprImpl { final override string toString() { result = "case ..." } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = ControlExpr.super.getAChild(pred) or pred = "getValue" and result = this.getValue() @@ -444,7 +444,7 @@ class WhenExpr extends Expr, TWhenExpr { final override string toString() { result = "when ..." } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = super.getAChild(pred) or pred = "getBody" and result = this.getBody() @@ -517,7 +517,7 @@ class InClause extends Expr, TInClause { final override string toString() { result = "in ... then ..." } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = super.getAChild(pred) or pred = "getBody" and result = this.getBody() @@ -552,7 +552,7 @@ class ConditionalLoop extends Loop, TConditionalLoop { Expr getCondition() { none() } override AstNode getAChild(string pred) { - result = Loop.super.getAChild(pred) + result = super.getAChild(pred) or pred = "getCondition" and result = this.getCondition() } @@ -707,8 +707,8 @@ class ForExpr extends Loop, TForExpr { final override string toString() { result = "for ... in ..." } - override AstNode getAChild(string pred) { - result = Loop.super.getAChild(pred) + final override AstNode getAChild(string pred) { + result = super.getAChild(pred) or pred = "getPattern" and result = this.getPattern() or diff --git a/ruby/ql/lib/codeql/ruby/ast/Expr.qll b/ruby/ql/lib/codeql/ruby/ast/Expr.qll index c1918ae495e..a0609567e29 100644 --- a/ruby/ql/lib/codeql/ruby/ast/Expr.qll +++ b/ruby/ql/lib/codeql/ruby/ast/Expr.qll @@ -140,7 +140,11 @@ class DestructuredLhsExpr extends LhsExpr, TDestructuredLhsExpr { override string toString() { result = "(..., ...)" } - override AstNode getAChild(string pred) { pred = "getElement" and result = this.getElement(_) } + final override AstNode getAChild(string pred) { + result = super.getAChild(pred) + or + pred = "getElement" and result = this.getElement(_) + } } /** A sequence of expressions. */ @@ -213,7 +217,7 @@ class BodyStmt extends StmtSequence, TBodyStmt { final predicate hasEnsure() { exists(this.getEnsure()) } override AstNode getAChild(string pred) { - result = StmtSequence.super.getAChild(pred) + result = super.getAChild(pred) or pred = "getRescue" and result = this.getRescue(_) or @@ -291,7 +295,7 @@ class Pair extends Expr, TPair { final override string toString() { result = "Pair" } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = super.getAChild(pred) or pred = "getKey" and result = this.getKey() @@ -360,7 +364,7 @@ class RescueClause extends Expr, TRescueClause { final override string toString() { result = "rescue ..." } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = super.getAChild(pred) or pred = "getException" and result = this.getException(_) @@ -402,7 +406,7 @@ class RescueModifierExpr extends Expr, TRescueModifierExpr { final override string toString() { result = "... rescue ..." } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = super.getAChild(pred) or pred = "getBody" and result = this.getBody() @@ -463,7 +467,7 @@ class StringConcatenation extends Expr, TStringConcatenation { final override string toString() { result = "\"...\" \"...\"" } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = super.getAChild(pred) or pred = "getString" and result = this.getString(_) diff --git a/ruby/ql/lib/codeql/ruby/ast/Operation.qll b/ruby/ql/lib/codeql/ruby/ast/Operation.qll index 486c22fc56c..d8ab49d770f 100644 --- a/ruby/ql/lib/codeql/ruby/ast/Operation.qll +++ b/ruby/ql/lib/codeql/ruby/ast/Operation.qll @@ -450,7 +450,7 @@ class Assignment extends Operation instanceof AssignmentImpl { final override string toString() { result = "... " + this.getOperator() + " ..." } - override AstNode getAChild(string pred) { + final override AstNode getAChild(string pred) { result = Operation.super.getAChild(pred) or pred = "getLeftOperand" and result = this.getLeftOperand() diff --git a/ruby/ql/lib/codeql/ruby/ast/Parameter.qll b/ruby/ql/lib/codeql/ruby/ast/Parameter.qll index 88b68bf40b8..efbd8a66ce8 100644 --- a/ruby/ql/lib/codeql/ruby/ast/Parameter.qll +++ b/ruby/ql/lib/codeql/ruby/ast/Parameter.qll @@ -59,7 +59,11 @@ class DestructuredParameter extends Parameter, TDestructuredParameter { override string toString() { result = "(..., ...)" } - override AstNode getAChild(string pred) { pred = "getElement" and result = this.getElement(_) } + final override AstNode getAChild(string pred) { + result = super.getAChild(pred) + or + pred = "getElement" and result = this.getElement(_) + } final override string getAPrimaryQlClass() { result = "DestructuredParameter" } } diff --git a/ruby/ql/lib/codeql/ruby/ast/internal/AST.qll b/ruby/ql/lib/codeql/ruby/ast/internal/AST.qll index 5bba77f6be7..b78eded2eda 100644 --- a/ruby/ql/lib/codeql/ruby/ast/internal/AST.qll +++ b/ruby/ql/lib/codeql/ruby/ast/internal/AST.qll @@ -321,9 +321,9 @@ private module Cached { TBraceBlockReal or TBreakStmt or TCaseEqExpr or TCaseExpr or TCaseMatch or TCharacterLiteral or TClassDeclaration or TClassVariableAccessReal or TComplementExpr or TComplexLiteral or TDefinedExpr or TDelimitedSymbolLiteral or TDestructuredLeftAssignment or - TDivExprReal or TDo or TDoBlock or TElementReference or TElse or TElsif or TEmptyStmt or - TEncoding or TEndBlock or TEnsure or TEqExpr or TExponentExprReal or TFalseLiteral or - TFile or TFindPattern or TFloatLiteral or TForExpr or TForwardParameter or + TDestructuredParameter or TDivExprReal or TDo or TDoBlock or TElementReference or TElse or + TElsif or TEmptyStmt or TEncoding or TEndBlock or TEnsure or TEqExpr or TExponentExprReal or + TFalseLiteral or TFile or TFindPattern or TFloatLiteral or TForExpr or TForwardParameter or TForwardArgument or TGEExpr or TGTExpr or TGlobalVariableAccessReal or THashKeySymbolLiteral or THashLiteral or THashPattern or THashSplatExpr or THashSplatNilParameter or THashSplatParameter or THereDoc or TIdentifierMethodCall or TIf or @@ -342,8 +342,8 @@ private module Cached { TStringConcatenation or TStringEscapeSequenceComponent or TStringInterpolationComponent or TStringTextComponent or TSubExprReal or TSubshellLiteral or TSymbolArrayLiteral or TTernaryIfExpr or TThen or TTokenConstantAccess or TTokenMethodName or TTokenSuperCall or - TToplevel or TTrueLiteral or TDestructuredParameter or TUnaryMinusExpr or TUnaryPlusExpr or - TUndefStmt or TUnlessExpr or TUnlessModifierExpr or TUntilExpr or TUntilModifierExpr or + TToplevel or TTrueLiteral or TUnaryMinusExpr or TUnaryPlusExpr or TUndefStmt or + TUnlessExpr or TUnlessModifierExpr or TUntilExpr or TUntilModifierExpr or TVariableReferencePattern or TWhenExpr or TWhileExpr or TWhileModifierExpr or TYieldCall; class TAstNodeSynth =