mirror of
https://github.com/github/codeql.git
synced 2026-05-14 11:19:27 +02:00
C#: Deprecate member predicate Definition.getAReadAtNode.
This commit is contained in:
@@ -586,7 +586,7 @@ private Ssa::Definition getAnSsaQualifier(Expr e, ControlFlowNode cfn) {
|
||||
}
|
||||
|
||||
private AssignableAccess getATrackedAccess(Ssa::Definition def, ControlFlowNode cfn) {
|
||||
result = def.getAReadAtNode(cfn)
|
||||
result = def.getARead() and cfn = result.getControlFlowNode()
|
||||
or
|
||||
result = def.(Ssa::ExplicitDefinition).getADefinition().getTargetAccess() and
|
||||
cfn = def.getControlFlowNode()
|
||||
|
||||
@@ -124,11 +124,9 @@ private predicate nonNullDef(Ssa::ExplicitDefinition def) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `node` is a dereference `d` of SSA definition `def`.
|
||||
* Holds if `d` is a dereference of SSA definition `def`.
|
||||
*/
|
||||
private predicate dereferenceAt(ControlFlowNode node, Ssa::Definition def, Dereference d) {
|
||||
d = def.getAReadAtNode(node)
|
||||
}
|
||||
private predicate dereferenceAt(Ssa::Definition def, Dereference d) { d = def.getARead() }
|
||||
|
||||
private predicate isMaybeNullArgument(Ssa::ParameterDefinition def, MaybeNullExpr arg) {
|
||||
exists(AssignableDefinitions::ImplicitParameterDefinition pdef, Parameter p |
|
||||
@@ -214,7 +212,7 @@ private predicate defMaybeNull(Ssa::Definition def, ControlFlowNode node, string
|
||||
)
|
||||
or
|
||||
// A variable of nullable type may be null
|
||||
exists(Dereference d | dereferenceAt(_, def, d) |
|
||||
exists(Dereference d | dereferenceAt(def, d) |
|
||||
node = def.getControlFlowNode() and
|
||||
d.hasNullableType() and
|
||||
not def instanceof Ssa::PhiNode and
|
||||
@@ -254,7 +252,8 @@ private module NullnessConfig implements ControlFlowReachability::ConfigSig {
|
||||
|
||||
predicate sink(ControlFlowNode node, SsaDefinition def) {
|
||||
exists(Dereference d |
|
||||
dereferenceAt(node, def, d) and
|
||||
dereferenceAt(def, d) and
|
||||
node = d.getControlFlowNode() and
|
||||
not d instanceof NonNullExpr
|
||||
)
|
||||
}
|
||||
@@ -271,7 +270,8 @@ predicate maybeNullDeref(Dereference d, Ssa::SourceVariable v, string msg, Eleme
|
||||
defMaybeNull(origin, src, msg, reason) and
|
||||
NullnessFlow::flow(src, origin, sink, ssa) and
|
||||
ssa.getSourceVariable() = v and
|
||||
dereferenceAt(sink, ssa, d) and
|
||||
dereferenceAt(ssa, d) and
|
||||
sink = d.getControlFlowNode() and
|
||||
not d.isAlwaysNull(v)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -236,9 +236,11 @@ module Ssa {
|
||||
* - The reads of `this.Field` on lines 10 and 11 can be reached from the phi
|
||||
* node between lines 9 and 10.
|
||||
*/
|
||||
final AssignableRead getARead() { result = this.getAReadAtNode(_) }
|
||||
final AssignableRead getARead() { result = SsaImpl::getAReadAtNode(this, _) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `getARead()` instead.
|
||||
*
|
||||
* Gets a read of the source variable underlying this SSA definition at
|
||||
* control flow node `cfn` that can be reached from this SSA definition
|
||||
* without passing through any other SSA definitions. Example:
|
||||
@@ -265,7 +267,7 @@ module Ssa {
|
||||
* - The reads of `this.Field` on lines 10 and 11 can be reached from the phi
|
||||
* node between lines 9 and 10.
|
||||
*/
|
||||
final AssignableRead getAReadAtNode(ControlFlowNode cfn) {
|
||||
deprecated final AssignableRead getAReadAtNode(ControlFlowNode cfn) {
|
||||
result = SsaImpl::getAReadAtNode(this, cfn)
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ module VariableCapture {
|
||||
exists(Ssa::Definition def, AssignableDefinition adef |
|
||||
LocalFlow::defAssigns(adef, _, _, e1) and
|
||||
def.getAnUltimateDefinition().(Ssa::ExplicitDefinition).getADefinition() = adef and
|
||||
exists(def.getAReadAtNode(e2))
|
||||
def.getARead().getControlFlowNode() = e2
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -245,7 +245,7 @@ private module Impl {
|
||||
)
|
||||
}
|
||||
|
||||
ExprNode getARead(Ssa::Definition v) { exists(v.getAReadAtNode(result)) }
|
||||
ExprNode getARead(Ssa::Definition v) { v.getARead().getControlFlowNode() = result }
|
||||
|
||||
Field getField(ExprNode fa) { result = fa.getExpr().(FieldAccess).getTarget() }
|
||||
|
||||
|
||||
@@ -12,13 +12,13 @@ private class ExprNode = ControlFlowNodes::ExprNode;
|
||||
/** An SSA variable. */
|
||||
class SsaVariable extends Definition {
|
||||
/** Gets a read of this SSA variable. */
|
||||
ExprNode getAUse() { exists(this.getAReadAtNode(result)) }
|
||||
ExprNode getAUse() { this.getARead().getControlFlowNode() = result }
|
||||
}
|
||||
|
||||
/** Gets a node that reads `src` via an SSA explicit definition. */
|
||||
ExprNode getAnExplicitDefinitionRead(ExprNode src) {
|
||||
exists(ExplicitDefinition def |
|
||||
exists(def.getAReadAtNode(result)) and
|
||||
def.getARead().getControlFlowNode() = result and
|
||||
hasChild(def.getElement(), def.getADefinition().getSource(), def.getControlFlowNode(), src)
|
||||
)
|
||||
}
|
||||
@@ -27,7 +27,7 @@ ExprNode getAnExplicitDefinitionRead(ExprNode src) {
|
||||
* Gets an expression that equals `v - delta`.
|
||||
*/
|
||||
ExprNode ssaRead(Definition v, int delta) {
|
||||
exists(v.getAReadAtNode(result)) and delta = 0
|
||||
v.getARead().getControlFlowNode() = result and delta = 0
|
||||
or
|
||||
exists(ExprNode::AddOperation add, int d1, ConstantIntegerExpr c |
|
||||
result = add and
|
||||
|
||||
Reference in New Issue
Block a user