mirror of
https://github.com/github/codeql.git
synced 2026-05-03 04:39:29 +02:00
Ruby: Make isCapturedAccess work with synthesized scopes
This commit is contained in:
@@ -51,7 +51,7 @@ class LocalVariable extends Variable, TLocalVariable {
|
||||
*
|
||||
* `x` is a captured variable, whereas `y` is not.
|
||||
*/
|
||||
predicate isCaptured() { this.getAnAccess().isCapturedAccess() }
|
||||
final predicate isCaptured() { this.getAnAccess().isCapturedAccess() }
|
||||
}
|
||||
|
||||
/** A global variable. */
|
||||
@@ -152,7 +152,7 @@ class LocalVariableAccess extends VariableAccess instanceof LocalVariableAccessI
|
||||
* the access to `x` in the first `puts x` is a captured access, while
|
||||
* the access to `x` in the second `puts x` is not.
|
||||
*/
|
||||
predicate isCapturedAccess() { isCapturedAccess(this) }
|
||||
final predicate isCapturedAccess() { isCapturedAccess(this) }
|
||||
}
|
||||
|
||||
/** An access to a local variable where the value is updated. */
|
||||
@@ -200,10 +200,4 @@ class SelfVariableAccess extends LocalVariableAccess instanceof SelfVariableAcce
|
||||
}
|
||||
|
||||
/** An access to the `self` variable where the value is read. */
|
||||
class SelfVariableReadAccess extends SelfVariableAccess, VariableReadAccess {
|
||||
// We override the definition in `LocalVariableAccess` because it gives the
|
||||
// wrong result for synthesised `self` variables.
|
||||
override predicate isCapturedAccess() {
|
||||
this.getVariable().getDeclaringScope() != this.getCfgScope()
|
||||
}
|
||||
}
|
||||
class SelfVariableReadAccess extends SelfVariableAccess, VariableReadAccess { }
|
||||
|
||||
Reference in New Issue
Block a user