Skip to content

Commit 5854908

Browse files
committed
Ruby: Ensure Node::{toString,getLocation} are computed in data flow stage
1 parent 367aa35 commit 5854908

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPrivate.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,12 @@ private module Cached {
340340
p.(KeywordParameter).getDefaultValue() = e.getExprNode().getExpr()
341341
}
342342

343+
cached
344+
Location getLocation(NodeImpl n) { result = n.getLocationImpl() }
345+
346+
cached
347+
string toString(NodeImpl n) { result = n.toStringImpl() }
348+
343349
/**
344350
* This is the local flow predicate that is used as a building block in global
345351
* data flow.

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ class Node extends TNode {
1919
Parameter asParameter() { result = this.(ParameterNode).getParameter() }
2020

2121
/** Gets a textual representation of this node. */
22-
cached
23-
final string toString() { result = this.(NodeImpl).toStringImpl() }
22+
final string toString() { result = toString(this) }
2423

2524
/** Gets the location of this node. */
26-
cached
27-
final Location getLocation() { result = this.(NodeImpl).getLocationImpl() }
25+
final Location getLocation() { result = getLocation(this) }
2826

2927
/**
3028
* Holds if this element is at the specified location.

0 commit comments

Comments
 (0)