Skip to content

Commit 6525035

Browse files
committed
Address comments
1 parent a22868b commit 6525035

File tree

5 files changed

+29
-16
lines changed

5 files changed

+29
-16
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -423,17 +423,17 @@ class ReferencePattern extends CasePattern, TReferencePattern {
423423
any(Ruby::ExpressionReferencePattern g | this = TExpressionReferencePattern(g)).getValue()
424424
}
425425

426-
/** Gets the value this reference pattern matches against. */
427-
final Expr getValue() { toGenerated(result) = value }
426+
/** Gets the value this reference pattern matches against. For example `2 * x` in `^(2 * x)` */
427+
final Expr getExpr() { toGenerated(result) = value }
428428

429429
final override string getAPrimaryQlClass() { result = "ReferencePattern" }
430430

431431
final override string toString() { result = "^..." }
432432

433-
override AstNode getAChild(string pred) {
433+
final override AstNode getAChild(string pred) {
434434
result = super.getAChild(pred)
435435
or
436-
pred = "getValue" and result = this.getValue()
436+
pred = "getExpr" and result = this.getExpr()
437437
}
438438
}
439439

@@ -450,5 +450,5 @@ class ReferencePattern extends CasePattern, TReferencePattern {
450450
*/
451451
deprecated class VariableReferencePattern extends ReferencePattern, TVariableReferencePattern {
452452
/** Gets the variable access corresponding to this variable reference pattern. */
453-
final VariableReadAccess getVariableAccess() { result = this.getValue() }
453+
final VariableReadAccess getVariableAccess() { result = this.getExpr() }
454454
}

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,19 @@ private module ImplicitHashValueSynthesis {
10331033
}
10341034
}
10351035

1036+
/**
1037+
* ```rb
1038+
* def foo(&)
1039+
* bar(&)
1040+
* end
1041+
* ```
1042+
* desugars to,
1043+
* ```rb
1044+
* def foo(&__synth_0)
1045+
* bar(&__synth_0)
1046+
* end
1047+
* ```
1048+
*/
10361049
private module AnonymousBlockParameterSynth {
10371050
private BlockParameter anonymousBlockParameter() {
10381051
exists(Ruby::BlockParameter p | not exists(p.getName()) and toGenerated(result) = p)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ private predicate inMatchingContext(AstNode n) {
235235
or
236236
n instanceof CasePattern
237237
or
238-
n = any(ReferencePattern p).getValue()
238+
n = any(ReferencePattern p).getExpr()
239239
or
240240
n.(Trees::DefaultValueParameterTree).hasDefaultValue()
241241
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ module Trees {
732732
}
733733

734734
private class ReferencePatternTree extends StandardPreOrderTree, ReferencePattern {
735-
override ControlFlowTree getChildElement(int i) { result = this.getValue() and i = 0 }
735+
override ControlFlowTree getChildElement(int i) { result = this.getExpr() and i = 0 }
736736
}
737737

738738
private class InClauseTree extends PreOrderTree, InClause {

ruby/ql/test/library-tests/ast/Ast.expected

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ control/cases.rb:
952952
# 87| getPattern: [IntegerLiteral] 5
953953
# 88| getBranch: [InClause] in ... then ...
954954
# 88| getPattern: [ReferencePattern] ^...
955-
# 88| getValue: [LocalVariableAccess] foo
955+
# 88| getExpr: [LocalVariableAccess] foo
956956
# 89| getBranch: [InClause] in ... then ...
957957
# 89| getPattern: [StringLiteral] "string"
958958
# 89| getComponent: [StringTextComponent] string
@@ -1050,7 +1050,7 @@ control/cases.rb:
10501050
# 111| getPattern: [AlternativePattern] ... | ...
10511051
# 111| getAlternative: [IntegerLiteral] 5
10521052
# 111| getAlternative: [ReferencePattern] ^...
1053-
# 111| getValue: [LocalVariableAccess] foo
1053+
# 111| getExpr: [LocalVariableAccess] foo
10541054
# 111| getAlternative: [StringLiteral] "string"
10551055
# 111| getComponent: [StringTextComponent] string
10561056
# 111| getAlternative: [LocalVariableAccess] var
@@ -1146,28 +1146,28 @@ control/cases.rb:
11461146
# 147| getReceiver: [Self, SelfVariableAccess] self
11471147
# 148| getBranch: [InClause] in ... then ...
11481148
# 148| getPattern: [ReferencePattern] ^...
1149-
# 148| getValue: [LocalVariableAccess] foo
1149+
# 148| getExpr: [LocalVariableAccess] foo
11501150
# 149| getBranch: [InClause] in ... then ...
11511151
# 149| getPattern: [ReferencePattern] ^...
1152-
# 149| getValue: [GlobalVariableAccess] $foo
1152+
# 149| getExpr: [GlobalVariableAccess] $foo
11531153
# 150| getBranch: [InClause] in ... then ...
11541154
# 150| getPattern: [ReferencePattern] ^...
1155-
# 150| getValue: [InstanceVariableAccess] @foo
1155+
# 150| getExpr: [InstanceVariableAccess] @foo
11561156
# 151| getBranch: [InClause] in ... then ...
11571157
# 151| getPattern: [ReferencePattern] ^...
1158-
# 151| getValue: [ClassVariableAccess] @@foo
1158+
# 151| getExpr: [ClassVariableAccess] @@foo
11591159
# 154| getStmt: [CaseExpr] case ...
11601160
# 154| getValue: [MethodCall] call to expr
11611161
# 154| getReceiver: [Self, SelfVariableAccess] self
11621162
# 155| getBranch: [InClause] in ... then ...
11631163
# 155| getPattern: [ReferencePattern] ^...
1164-
# 155| getValue: [LocalVariableAccess] foo
1164+
# 155| getExpr: [LocalVariableAccess] foo
11651165
# 156| getBranch: [InClause] in ... then ...
11661166
# 156| getPattern: [ReferencePattern] ^...
1167-
# 156| getValue: [InstanceVariableAccess] @foo
1167+
# 156| getExpr: [InstanceVariableAccess] @foo
11681168
# 157| getBranch: [InClause] in ... then ...
11691169
# 157| getPattern: [ReferencePattern] ^...
1170-
# 157| getValue: [AddExpr] ... + ...
1170+
# 157| getExpr: [AddExpr] ... + ...
11711171
# 157| getAnOperand/getLeftOperand/getReceiver: [IntegerLiteral] 1
11721172
# 157| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 1
11731173
modules/classes.rb:

0 commit comments

Comments
 (0)