Skip to content

Commit 61b6764

Browse files
committed
Ruby: Adapt to parameterized SSA implementation
1 parent 760c7be commit 61b6764

File tree

5 files changed

+123
-113
lines changed

5 files changed

+123
-113
lines changed
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import codeql.ruby.dataflow.SSA
2-
import codeql.ruby.dataflow.internal.SsaImplCommon::Consistency
2+
import codeql.ruby.dataflow.internal.SsaImpl::Consistency as Consistency
33

4-
class MyRelevantDefinition extends RelevantDefinition, Ssa::Definition {
4+
class MyRelevantDefinition extends Consistency::RelevantDefinition, Ssa::Definition {
55
override predicate hasLocationInfo(
66
string filepath, int startline, int startcolumn, int endline, int endcolumn
77
) {
88
this.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
99
}
1010
}
11+
12+
query predicate nonUniqueDef = Consistency::nonUniqueDef/4;
13+
14+
query predicate readWithoutDef = Consistency::readWithoutDef/3;
15+
16+
query predicate deadDef = Consistency::deadDef/2;
17+
18+
query predicate notDominatedByDef = Consistency::notDominatedByDef/4;

ruby/ql/lib/codeql/ruby/dataflow/SSA.qll

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ module Ssa {
99
private import codeql.Locations
1010
private import codeql.ruby.CFG
1111
private import codeql.ruby.ast.Variable
12-
private import internal.SsaImplCommon as SsaImplCommon
1312
private import internal.SsaImpl as SsaImpl
1413
private import CfgNodes::ExprNodes
1514

1615
/** A static single assignment (SSA) definition. */
17-
class Definition extends SsaImplCommon::Definition {
16+
class Definition extends SsaImpl::Definition {
1817
/**
1918
* Gets the control flow node of this SSA definition, if any. Phi nodes are
2019
* examples of SSA definitions without a control flow node, as they are
@@ -190,7 +189,7 @@ module Ssa {
190189
* puts x
191190
* ```
192191
*/
193-
class WriteDefinition extends Definition, SsaImplCommon::WriteDefinition {
192+
class WriteDefinition extends Definition, SsaImpl::WriteDefinition {
194193
private VariableWriteAccess write;
195194

196195
WriteDefinition() {
@@ -223,7 +222,7 @@ module Ssa {
223222
/**
224223
* An SSA definition that corresponds to the value of `self` upon entry to a method, class or module.
225224
*/
226-
class SelfDefinition extends Definition, SsaImplCommon::WriteDefinition {
225+
class SelfDefinition extends Definition, SsaImpl::WriteDefinition {
227226
private SelfVariable v;
228227

229228
SelfDefinition() {
@@ -254,7 +253,7 @@ module Ssa {
254253
* since the assignment to `x` is conditional, an unitialized definition for
255254
* `x` is inserted at the start of `m`.
256255
*/
257-
class UninitializedDefinition extends Definition, SsaImplCommon::WriteDefinition {
256+
class UninitializedDefinition extends Definition, SsaImpl::WriteDefinition {
258257
UninitializedDefinition() {
259258
exists(BasicBlock bb, int i, Variable v |
260259
this.definesAt(v, bb, i) and
@@ -283,7 +282,7 @@ module Ssa {
283282
*
284283
* an entry definition for `y` is inserted at the start of the `do` block.
285284
*/
286-
class CapturedEntryDefinition extends Definition, SsaImplCommon::WriteDefinition {
285+
class CapturedEntryDefinition extends Definition, SsaImpl::WriteDefinition {
287286
CapturedEntryDefinition() {
288287
exists(BasicBlock bb, int i, Variable v |
289288
this.definesAt(v, bb, i) and
@@ -312,7 +311,7 @@ module Ssa {
312311
*
313312
* a definition for `y` is inserted at the call to `times`.
314313
*/
315-
class CapturedCallDefinition extends Definition, SsaImplCommon::UncertainWriteDefinition {
314+
class CapturedCallDefinition extends Definition, SsaImpl::UncertainWriteDefinition {
316315
CapturedCallDefinition() {
317316
exists(Variable v, BasicBlock bb, int i |
318317
this.definesAt(v, bb, i) and
@@ -343,7 +342,7 @@ module Ssa {
343342
*
344343
* a phi node for `x` is inserted just before the call `puts x`.
345344
*/
346-
class PhiNode extends Definition, SsaImplCommon::PhiNode {
345+
class PhiNode extends Definition, SsaImpl::PhiNode {
347346
/**
348347
* Gets an input of this phi node.
349348
*

0 commit comments

Comments
 (0)