Skip to content

Commit 4641bdc

Browse files
committed
Ruby: Deprecate getAControlFlowNode.
1 parent 736b110 commit 4641bdc

7 files changed

Lines changed: 22 additions & 18 deletions

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Call extends Expr instanceof CallImpl {
6363
TCfgScope(result) = viableCallableLambda(c, _)
6464
)
6565
or
66-
result = getTarget(TNormalCall(this.getAControlFlowNode()))
66+
result = getTarget(TNormalCall(this.getControlFlowNode()))
6767
}
6868

6969
override AstNode getAChild(string pred) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@ class Stmt extends AstNode, TStmt {
1616
/** Gets the control-flow node for this statement, if any. */
1717
ControlFlowNode getControlFlowNode() { result.injects(this) }
1818

19-
/** Gets a control-flow node for this statement, if any. */
20-
CfgNodes::AstCfgNode getAControlFlowNode() { result.getAstNode() = this }
19+
/**
20+
* DEPRECATED: Use `getControlFlowNode()` instead.
21+
*
22+
* Gets a control-flow node for this statement, if any.
23+
*/
24+
deprecated CfgNodes::AstCfgNode getAControlFlowNode() { result.getAstNode() = this }
2125

2226
/** Gets the control-flow scope of this statement, if any. */
2327
CfgScope getCfgScope() { result = getEnclosingCallable(this) }

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private module Propagation {
9595
or
9696
isIntExpr(e.(ConstantReadAccess).getValue(), i)
9797
or
98-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isInt(n, i))
98+
isInt(e.getControlFlowNode(), i)
9999
}
100100

101101
predicate isFloat(ExprCfgNode e, float f) {
@@ -153,7 +153,7 @@ private module Propagation {
153153
or
154154
isFloatExpr(e.(ConstantReadAccess).getValue(), f)
155155
or
156-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isFloat(n, f))
156+
isFloat(e.getControlFlowNode(), f)
157157
}
158158

159159
predicate isRational(ExprCfgNode e, int numerator, int denominator) {
@@ -175,7 +175,7 @@ private module Propagation {
175175
or
176176
isRationalExpr(e.(ConstantReadAccess).getValue(), numerator, denominator)
177177
or
178-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isRational(n, numerator, denominator))
178+
isRational(e.getControlFlowNode(), numerator, denominator)
179179
}
180180

181181
predicate isComplex(ExprCfgNode e, float real, float imaginary) {
@@ -197,7 +197,7 @@ private module Propagation {
197197
or
198198
isComplexExpr(e.(ConstantReadAccess).getValue(), real, imaginary)
199199
or
200-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isComplex(n, real, imaginary))
200+
isComplex(e.getControlFlowNode(), real, imaginary)
201201
}
202202

203203
overlay[local]
@@ -309,7 +309,7 @@ private module Propagation {
309309
or
310310
isStringExpr(e.(ConstantReadAccess).getValue(), s)
311311
or
312-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isString(n, s))
312+
isString(e.getControlFlowNode(), s)
313313
}
314314

315315
predicate isSymbol(ExprCfgNode e, string s) {
@@ -334,7 +334,7 @@ private module Propagation {
334334
or
335335
isSymbolExpr(e.(ConstantReadAccess).getValue(), s)
336336
or
337-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isSymbol(n, s))
337+
isSymbol(e.getControlFlowNode(), s)
338338
}
339339

340340
predicate isRegExp(ExprCfgNode e, string s, string flags) {
@@ -359,7 +359,7 @@ private module Propagation {
359359
or
360360
isRegExpExpr(e.(ConstantReadAccess).getValue(), s, flags)
361361
or
362-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isRegExp(n, s, flags))
362+
isRegExp(e.getControlFlowNode(), s, flags)
363363
}
364364

365365
predicate isBoolean(ExprCfgNode e, boolean b) {
@@ -381,7 +381,7 @@ private module Propagation {
381381
or
382382
isBooleanExpr(e.(ConstantReadAccess).getValue(), b)
383383
or
384-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isBoolean(n, b))
384+
isBoolean(e.getControlFlowNode(), b)
385385
}
386386

387387
predicate isNil(ExprCfgNode e) {
@@ -403,7 +403,7 @@ private module Propagation {
403403
or
404404
isNilExpr(e.(ConstantReadAccess).getValue())
405405
or
406-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isNil(n))
406+
isNil(e.getControlFlowNode())
407407
}
408408
}
409409

@@ -566,7 +566,7 @@ private predicate isArrayExpr(Expr e, ArrayLiteralCfgNode arr) {
566566
// control flow paths.
567567
// Note(hmac): I don't think this is necessary, as `getSource` will not return
568568
// results if the source is a phi node.
569-
forex(ExprCfgNode n | n = e.getAControlFlowNode() | isArrayConstant(n, arr))
569+
isArrayConstant(e.getControlFlowNode(), arr)
570570
or
571571
// if `e` is an array, then `e.freeze` is also an array
572572
e.(MethodCall).getMethodName() = "freeze" and

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@ private module LibraryCallbackSummaries {
106106
LibraryLambdaMethod() { this = "<library method accepting a callback>" }
107107

108108
final override MethodCall getACall() {
109-
libraryCall(result.getAControlFlowNode()) and
109+
libraryCall(result.getControlFlowNode()) and
110110
result.hasBlock()
111111
or
112-
libraryCallHasLambdaArg(result.getAControlFlowNode(), _)
112+
libraryCallHasLambdaArg(result.getControlFlowNode(), _)
113113
}
114114

115115
override predicate propagatesFlow(

ruby/ql/src/queries/analysis/Definitions.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ newtype DefLoc =
4343
meth = call.getATarget()
4444
or
4545
// include implicit `initialize` calls
46-
meth = getInitializeTarget(call.getAControlFlowNode())
46+
meth = getInitializeTarget(call.getControlFlowNode())
4747
} or
4848
/** A local variable. */
4949
LocalVariableLoc(VariableReadAccess read, VariableWriteAccess write) {

ruby/ql/src/queries/variables/DeadStoreOfLocal.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ class RelevantLocalVariableWriteAccess extends LocalVariableWriteAccess {
4444
from RelevantLocalVariableWriteAccess write, LocalVariable v
4545
where
4646
v = write.getVariable() and
47-
exists(write.getAControlFlowNode()) and
47+
exists(write.getControlFlowNode()) and
4848
not exists(Ssa::WriteDefinition def | def.getWriteAccess().getAstNode() = write)
4949
select write, "This assignment to $@ is useless, since its value is never read.", v, v.getName()

ruby/ql/src/queries/variables/UninitializedLocal.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ private predicate isInBooleanContext(AstNode n) {
4949

5050
private predicate isGuarded(LocalVariableReadAccess read) {
5151
exists(AstCfgNode guard, boolean branch |
52-
Guards::guardControlsBlock(guard, read.getAControlFlowNode().getBasicBlock(), branch)
52+
Guards::guardControlsBlock(guard, read.getControlFlowNode().getBasicBlock(), branch)
5353
|
5454
// guard is `var`
5555
guard.getAstNode() = read.getVariable().getAnAccess() and

0 commit comments

Comments
 (0)