Skip to content

Commit 46144fe

Browse files
committed
Ruby: InClause and WhenClause are no longer Expr
1 parent 974ad07 commit 46144fe

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

ruby/ql/lib/codeql/ruby/ast/Control.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,13 +364,13 @@ class CaseExpr extends ControlExpr instanceof CaseExprImpl {
364364
* Gets the `n`th branch of this case expression, either a `WhenExpr`, an
365365
* `InClause`, or a `StmtSequence`.
366366
*/
367-
final Expr getBranch(int n) { result = super.getBranch(n) }
367+
final AstNode getBranch(int n) { result = super.getBranch(n) }
368368

369369
/**
370370
* Gets a branch of this case expression, either a `WhenExpr`, an
371371
* `InClause`, or a `StmtSequence`.
372372
*/
373-
final Expr getABranch() { result = this.getBranch(_) }
373+
final AstNode getABranch() { result = this.getBranch(_) }
374374

375375
/** Gets the `n`th `when` branch of this case expression. */
376376
deprecated final WhenExpr getWhenBranch(int n) { result = this.getBranch(n) }
@@ -409,7 +409,7 @@ class CaseExpr extends ControlExpr instanceof CaseExprImpl {
409409
* end
410410
* ```
411411
*/
412-
class WhenExpr extends Expr, TWhenExpr {
412+
class WhenExpr extends AstNode, TWhenExpr {
413413
private Ruby::When g;
414414

415415
WhenExpr() { this = TWhenExpr(g) }
@@ -461,7 +461,7 @@ class WhenExpr extends Expr, TWhenExpr {
461461
* end
462462
* ```
463463
*/
464-
class InClause extends Expr, TInClause {
464+
class InClause extends AstNode, TInClause {
465465
private Ruby::InClause g;
466466

467467
InClause() { this = TInClause(g) }

ruby/ql/lib/codeql/ruby/ast/internal/AST.qll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,10 +657,9 @@ class TSelf = TSelfReal or TSelfSynth;
657657
class TDestructuredLhsExpr = TDestructuredLeftAssignment or TLeftAssignmentList;
658658

659659
class TExpr =
660-
TSelf or TArgumentList or TInClause or TRescueClause or TRescueModifierExpr or TPair or
661-
TStringConcatenation or TCall or TBlockArgument or TConstantAccess or TControlExpr or
662-
TWhenExpr or TLiteral or TCallable or TVariableAccess or TStmtSequence or TOperation or
663-
TForwardArgument or TDestructuredLhsExpr;
660+
TSelf or TArgumentList or TRescueClause or TRescueModifierExpr or TPair or TStringConcatenation or
661+
TCall or TBlockArgument or TConstantAccess or TControlExpr or TLiteral or TCallable or
662+
TVariableAccess or TStmtSequence or TOperation or TForwardArgument or TDestructuredLhsExpr;
664663

665664
class TSplatExpr = TSplatExprReal or TSplatExprSynth;
666665

ruby/ql/lib/codeql/ruby/ast/internal/Control.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ private import codeql.ruby.ast.internal.AST
55
abstract class CaseExprImpl extends ControlExpr, TCase {
66
abstract Expr getValue();
77

8-
abstract Expr getBranch(int n);
8+
abstract AstNode getBranch(int n);
99
}
1010

1111
class CaseWhenExpr extends CaseExprImpl, TCaseExpr {
@@ -15,7 +15,7 @@ class CaseWhenExpr extends CaseExprImpl, TCaseExpr {
1515

1616
final override Expr getValue() { toGenerated(result) = g.getValue() }
1717

18-
final override Expr getBranch(int n) {
18+
final override AstNode getBranch(int n) {
1919
toGenerated(result) = g.getChild(n) or
2020
toGenerated(result) = g.getChild(n)
2121
}
@@ -28,7 +28,7 @@ class CaseMatch extends CaseExprImpl, TCaseMatch {
2828

2929
final override Expr getValue() { toGenerated(result) = g.getValue() }
3030

31-
final override Expr getBranch(int n) {
31+
final override AstNode getBranch(int n) {
3232
toGenerated(result) = g.getClauses(n)
3333
or
3434
n = count(g.getClauses(_)) and toGenerated(result) = g.getElse()

ruby/ql/lib/codeql/ruby/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ module Trees {
422422
super.last(last, c)
423423
or
424424
not exists(this.getElseBranch()) and
425-
exists(MatchingCompletion lc, Expr lastBranch |
425+
exists(MatchingCompletion lc, AstNode lastBranch |
426426
lastBranch = max(int i | | this.getBranch(i) order by i) and
427427
lc.getValue() = false and
428428
last(lastBranch, last, lc) and
@@ -436,7 +436,7 @@ module Trees {
436436
first(this.getBranch(0), succ) and
437437
c instanceof SimpleCompletion
438438
or
439-
exists(int i, Expr branch | branch = this.getBranch(i) |
439+
exists(int i, AstNode branch | branch = this.getBranch(i) |
440440
last(branch, pred, c) and
441441
first(this.getBranch(i + 1), succ) and
442442
c.(MatchingCompletion).getValue() = false

ruby/ql/test/library-tests/ast/control/CaseExpr.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ query predicate caseWhenBranches(CaseExpr c, WhenExpr when, int pIndex, Expr p,
1616
body = when.getBody()
1717
}
1818

19-
query predicate caseAllBranches(CaseExpr c, int n, Expr branch) { branch = c.getBranch(n) }
19+
query predicate caseAllBranches(CaseExpr c, int n, AstNode branch) { branch = c.getBranch(n) }

0 commit comments

Comments
 (0)