mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Ruby: Remove getDefinitionExt references.
This commit is contained in:
@@ -641,7 +641,7 @@ private module TrackInstanceInput implements CallGraphConstruction::InputSig {
|
||||
// type being checked against
|
||||
localFlowStep(nodeFrom, nodeTo, summary) and
|
||||
not hasAdjacentTypeCheckedRead(nodeTo) and
|
||||
not TypeInference::asModulePattern(nodeTo.(SsaDefinitionExtNode).getDefinitionExt(), _)
|
||||
not TypeInference::asModulePattern(nodeTo.(SsaDefinitionNodeImpl).getDefinition(), _)
|
||||
}
|
||||
|
||||
predicate stepCall(DataFlow::Node nodeFrom, DataFlow::Node nodeTo, StepSummary summary) {
|
||||
|
||||
@@ -93,9 +93,9 @@ module SsaFlow {
|
||||
result = TSelfToplevelParameterNode(p.asToplevelSelf())
|
||||
}
|
||||
|
||||
ParameterNodeImpl toParameterNodeImpl(SsaDefinitionExtNode node) {
|
||||
ParameterNodeImpl toParameterNodeImpl(SsaDefinitionNodeImpl node) {
|
||||
exists(SsaImpl::WriteDefinition def, SsaImpl::ParameterExt p |
|
||||
def = node.getDefinitionExt() and
|
||||
def = node.getDefinition() and
|
||||
result = toParameterNode(p) and
|
||||
p.isInitializedBy(def)
|
||||
)
|
||||
@@ -392,10 +392,10 @@ module VariableCapture {
|
||||
|
||||
// From an assignment or implicit initialization of a captured variable to its flow-insensitive node
|
||||
private predicate flowInsensitiveWriteStep(
|
||||
SsaDefinitionExtNode node1, CapturedVariableNode node2, CapturedVariable v
|
||||
SsaDefinitionNodeImpl node1, CapturedVariableNode node2, CapturedVariable v
|
||||
) {
|
||||
exists(CapturedSsaDefinitionExt def |
|
||||
def = node1.getDefinitionExt() and
|
||||
def = node1.getDefinition() and
|
||||
def.getSourceVariable() = v and
|
||||
(
|
||||
def instanceof Ssa::WriteDefinition
|
||||
@@ -408,11 +408,11 @@ module VariableCapture {
|
||||
|
||||
// From a captured variable node to its flow-sensitive capture nodes
|
||||
private predicate flowInsensitiveReadStep(
|
||||
CapturedVariableNode node1, SsaDefinitionExtNode node2, CapturedVariable v
|
||||
CapturedVariableNode node1, SsaDefinitionNodeImpl node2, CapturedVariable v
|
||||
) {
|
||||
exists(CapturedSsaDefinitionExt def |
|
||||
node1.getVariable() = v and
|
||||
def = node2.getDefinitionExt() and
|
||||
def = node2.getDefinition() and
|
||||
def.getSourceVariable() = v and
|
||||
(
|
||||
def instanceof Ssa::CapturedCallDefinition
|
||||
@@ -571,8 +571,8 @@ private module Cached {
|
||||
}
|
||||
|
||||
/** Holds if `n` wraps an SSA definition without ingoing flow. */
|
||||
private predicate entrySsaDefinition(SsaDefinitionExtNode n) {
|
||||
n.getDefinitionExt() =
|
||||
private predicate entrySsaDefinition(SsaDefinitionNodeImpl n) {
|
||||
n.getDefinition() =
|
||||
any(SsaImpl::WriteDefinition def | not def.(Ssa::WriteDefinition).assigns(_))
|
||||
}
|
||||
|
||||
@@ -614,7 +614,7 @@ private module Cached {
|
||||
// to parameters (which are themselves local sources)
|
||||
entrySsaDefinition(n) and
|
||||
not exists(SsaImpl::ParameterExt p |
|
||||
p.isInitializedBy(n.(SsaDefinitionExtNode).getDefinitionExt())
|
||||
p.isInitializedBy(n.(SsaDefinitionNodeImpl).getDefinition())
|
||||
)
|
||||
or
|
||||
isStoreTargetNode(n)
|
||||
@@ -749,51 +749,38 @@ predicate nodeIsHidden(Node n) {
|
||||
}
|
||||
|
||||
/** An SSA node. */
|
||||
abstract class SsaNode extends NodeImpl, TSsaNode {
|
||||
class SsaNode extends NodeImpl, TSsaNode {
|
||||
SsaImpl::DataFlowIntegration::SsaNode node;
|
||||
SsaImpl::DefinitionExt def;
|
||||
|
||||
SsaNode() {
|
||||
this = TSsaNode(node) and
|
||||
def = node.getDefinitionExt()
|
||||
}
|
||||
SsaNode() { this = TSsaNode(node) }
|
||||
|
||||
SsaImpl::DefinitionExt getDefinitionExt() { result = def }
|
||||
/** Gets the underlying variable. */
|
||||
Variable getVariable() { result = node.getSourceVariable() }
|
||||
|
||||
/** Holds if this node should be hidden from path explanations. */
|
||||
abstract predicate isHidden();
|
||||
predicate isHidden() { any() }
|
||||
|
||||
override CfgScope getCfgScope() { result = node.getBasicBlock().getScope() }
|
||||
|
||||
override Location getLocationImpl() { result = node.getLocation() }
|
||||
|
||||
override string toStringImpl() { result = node.toString() }
|
||||
}
|
||||
|
||||
/** An (extended) SSA definition, viewed as a node in a data flow graph. */
|
||||
class SsaDefinitionExtNode extends SsaNode {
|
||||
override SsaImpl::DataFlowIntegration::SsaDefinitionExtNode node;
|
||||
class SsaDefinitionNodeImpl extends SsaNode {
|
||||
override SsaImpl::DataFlowIntegration::SsaDefinitionNode node;
|
||||
|
||||
/** Gets the underlying variable. */
|
||||
Variable getVariable() { result = def.getSourceVariable() }
|
||||
SsaImpl::Definition getDefinition() { result = node.getDefinition() }
|
||||
|
||||
override predicate isHidden() {
|
||||
not def instanceof Ssa::WriteDefinition
|
||||
or
|
||||
isDesugarNode(def.(Ssa::WriteDefinition).getWriteAccess().getExpr())
|
||||
or
|
||||
def = getParameterDef(_)
|
||||
exists(SsaImpl::Definition def | def = this.getDefinition() |
|
||||
not def instanceof Ssa::WriteDefinition
|
||||
or
|
||||
isDesugarNode(def.(Ssa::WriteDefinition).getWriteAccess().getExpr())
|
||||
or
|
||||
def = getParameterDef(_)
|
||||
)
|
||||
}
|
||||
|
||||
override CfgScope getCfgScope() { result = def.getBasicBlock().getScope() }
|
||||
}
|
||||
|
||||
class SsaDefinitionNodeImpl extends SsaDefinitionExtNode {
|
||||
Ssa::Definition ssaDef;
|
||||
|
||||
SsaDefinitionNodeImpl() { ssaDef = def }
|
||||
|
||||
override Location getLocationImpl() { result = ssaDef.getLocation() }
|
||||
|
||||
override string toStringImpl() { result = ssaDef.toString() }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -833,17 +820,13 @@ class SsaDefinitionNodeImpl extends SsaDefinitionExtNode {
|
||||
*/
|
||||
class SsaInputNode extends SsaNode {
|
||||
override SsaImpl::DataFlowIntegration::SsaInputNode node;
|
||||
|
||||
override predicate isHidden() { any() }
|
||||
|
||||
override CfgScope getCfgScope() { result = node.getDefinitionExt().getBasicBlock().getScope() }
|
||||
}
|
||||
|
||||
/** An SSA definition for a `self` variable. */
|
||||
class SsaSelfDefinitionNode extends SsaDefinitionExtNode {
|
||||
class SsaSelfDefinitionNode extends SsaDefinitionNodeImpl {
|
||||
private SelfVariable self;
|
||||
|
||||
SsaSelfDefinitionNode() { self = def.getSourceVariable() }
|
||||
SsaSelfDefinitionNode() { self = super.getVariable() }
|
||||
|
||||
/** Gets the scope in which the `self` variable is declared. */
|
||||
Scope getSelfScope() { result = self.getDeclaringScope() }
|
||||
@@ -1976,9 +1959,9 @@ predicate localMustFlowStep(Node node1, Node node2) {
|
||||
or
|
||||
exists(SsaImpl::Definition def |
|
||||
def.(Ssa::WriteDefinition).assigns(node1.asExpr()) and
|
||||
node2.(SsaDefinitionExtNode).getDefinitionExt() = def
|
||||
node2.(SsaDefinitionNodeImpl).getDefinition() = def
|
||||
or
|
||||
def = node1.(SsaDefinitionExtNode).getDefinitionExt() and
|
||||
def = node1.(SsaDefinitionNodeImpl).getDefinition() and
|
||||
node2.asExpr() = SsaImpl::getARead(def)
|
||||
)
|
||||
or
|
||||
@@ -2122,8 +2105,8 @@ class CastNode extends Node {
|
||||
predicate neverSkipInPathGraph(Node n) {
|
||||
// ensure that all variable assignments are included in the path graph
|
||||
n =
|
||||
any(SsaDefinitionExtNode def |
|
||||
def.getDefinitionExt() instanceof Ssa::WriteDefinition and
|
||||
any(SsaDefinitionNodeImpl def |
|
||||
def.getDefinition() instanceof Ssa::WriteDefinition and
|
||||
not def.isHidden()
|
||||
)
|
||||
}
|
||||
@@ -2446,7 +2429,7 @@ module TypeInference {
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate ssaDefHasType(SsaDefinitionExtNode def, Module tp, boolean exact) {
|
||||
private predicate ssaDefHasType(SsaDefinitionNodeImpl def, Module tp, boolean exact) {
|
||||
exists(ParameterNodeImpl p |
|
||||
parameterNodeHasType(p, tp, exact) and
|
||||
p = SsaFlow::toParameterNodeImpl(def)
|
||||
@@ -2454,7 +2437,7 @@ module TypeInference {
|
||||
or
|
||||
selfInMethodOrToplevelHasType(def.getVariable(), tp, exact)
|
||||
or
|
||||
asModulePattern(def.getDefinitionExt(), tp) and
|
||||
asModulePattern(def.getDefinition(), tp) and
|
||||
exact = false
|
||||
}
|
||||
|
||||
@@ -2523,11 +2506,11 @@ module TypeInference {
|
||||
or
|
||||
parameterNodeHasType(n, tp, exact)
|
||||
or
|
||||
exists(SsaDefinitionExtNode def | ssaDefHasType(def, tp, exact) |
|
||||
exists(SsaDefinitionNodeImpl def | ssaDefHasType(def, tp, exact) |
|
||||
n = def or
|
||||
n.asExpr() =
|
||||
any(CfgNodes::ExprCfgNode read |
|
||||
read = def.getDefinitionExt().getARead() and
|
||||
read = def.getDefinition().(SsaImpl::DefinitionExt).getARead() and
|
||||
not isTypeCheckedRead(read, _) // could in principle be checked against a new type
|
||||
)
|
||||
)
|
||||
|
||||
@@ -363,7 +363,7 @@ class PostUpdateNode extends Node {
|
||||
/** An SSA definition, viewed as a node in a data flow graph. */
|
||||
class SsaDefinitionNode extends Node instanceof SsaDefinitionNodeImpl {
|
||||
/** Gets the underlying SSA definition. */
|
||||
Ssa::Definition getDefinition() { result = super.getDefinitionExt() }
|
||||
Ssa::Definition getDefinition() { result = super.getDefinition() }
|
||||
|
||||
/** Gets the underlying variable. */
|
||||
Variable getVariable() { result = this.getDefinition().getSourceVariable() }
|
||||
@@ -434,7 +434,7 @@ private module Cached {
|
||||
LocalSourceNode getConstantAccessNode(ConstantAccess access) {
|
||||
// Namespaces don't evaluate to the constant being accessed, they return the value of their last statement.
|
||||
// Use the definition of 'self' in the namespace as the representative in this case.
|
||||
result.(SsaDefinitionExtNode).getDefinitionExt().(Ssa::SelfDefinition).getSourceVariable() =
|
||||
result.(SsaDefinitionNode).getDefinition().(Ssa::SelfDefinition).getSourceVariable() =
|
||||
access.(Namespace).getModuleSelfVariable()
|
||||
or
|
||||
not access instanceof Namespace and
|
||||
@@ -1002,7 +1002,7 @@ class ModuleNode instanceof Module {
|
||||
* This only gets `self` at the module level, not inside any (singleton) method.
|
||||
*/
|
||||
LocalSourceNode getModuleLevelSelf() {
|
||||
result.(SsaDefinitionExtNode).getVariable() = super.getADeclaration().getModuleSelfVariable()
|
||||
result.(SsaDefinitionNode).getVariable() = super.getADeclaration().getModuleSelfVariable()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -88,7 +88,7 @@ private module Cached {
|
||||
nodeFrom.asExpr() = value and
|
||||
value = case.getValue() and
|
||||
clause = case.getBranch(_) and
|
||||
def = nodeTo.(SsaDefinitionExtNode).getDefinitionExt() and
|
||||
def = nodeTo.(SsaDefinitionNodeImpl).getDefinition() and
|
||||
def.getControlFlowNode() = variablesInPattern(clause.getPattern()) and
|
||||
not def.(Ssa::WriteDefinition).assigns(value)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user