From dc34b10cb6cc20b39dcb1522d2ecf81b0f91540c Mon Sep 17 00:00:00 2001 From: Anders Schack-Mulligen Date: Fri, 24 Apr 2026 16:04:36 +0200 Subject: [PATCH] C#: Replace Ssa::ExplicitDefinition with SsaExplicitWrite. --- .../ql/consistency-queries/SsaConsistency.ql | 4 +-- .../ql/lib/semmle/code/csharp/Assignable.qll | 4 +-- .../semmle/code/csharp/controlflow/Guards.qll | 10 ++---- .../semmle/code/csharp/dataflow/Nullness.qll | 16 ++++------ .../lib/semmle/code/csharp/dataflow/SSA.qll | 10 ++++-- .../dataflow/internal/DataFlowPrivate.qll | 11 +++---- .../code/csharp/dataflow/internal/SsaImpl.qll | 8 +++-- .../internal/rangeanalysis/RangeUtils.qll | 2 +- .../rangeanalysis/SignAnalysisSpecific.qll | 32 ++++++------------- .../internal/rangeanalysis/SsaUtils.qll | 14 ++++---- csharp/ql/src/Dead Code/DeadStoreOfLocal.ql | 2 +- .../src/Likely Bugs/Dynamic/BadDynamicCall.ql | 7 ++-- .../ql/test/library-tests/csharp7/DefUse.ql | 7 +--- .../dataflow/callablereturnsarg/Common.qll | 4 +-- .../dataflow/defuse/defUseEquivalence.ql | 6 +++- .../dataflow/ssa-large/countssa.ql | 4 +-- .../dataflow/ssa/BaseSsaConsistency.ql | 8 ++--- .../dataflow/ssa/SsaExplicitDef.ql | 4 +-- 18 files changed, 67 insertions(+), 86 deletions(-) diff --git a/csharp/ql/consistency-queries/SsaConsistency.ql b/csharp/ql/consistency-queries/SsaConsistency.ql index e9c9191b63a..003e7ddd5e9 100644 --- a/csharp/ql/consistency-queries/SsaConsistency.ql +++ b/csharp/ql/consistency-queries/SsaConsistency.ql @@ -7,8 +7,8 @@ query predicate localDeclWithSsaDef(LocalVariableDeclExpr d) { // Local variables in C# must be initialized before every use, so uninitialized // local variables should not have an SSA definition, as that would imply that // the declaration is live (can reach a use without passing through a definition) - exists(ExplicitDefinition def | - d = def.getADefinition().(AssignableDefinitions::LocalVariableDefinition).getDeclaration() + exists(SsaExplicitWrite def | + d = def.getDefinition().(AssignableDefinitions::LocalVariableDefinition).getDeclaration() | not d = any(ForeachStmt fs).getVariableDeclExpr() and not d = any(SpecificCatchClause scc).getVariableDeclExpr() and diff --git a/csharp/ql/lib/semmle/code/csharp/Assignable.qll b/csharp/ql/lib/semmle/code/csharp/Assignable.qll index 066cdeaed15..7bd432d48ce 100644 --- a/csharp/ql/lib/semmle/code/csharp/Assignable.qll +++ b/csharp/ql/lib/semmle/code/csharp/Assignable.qll @@ -500,9 +500,7 @@ class AssignableDefinition extends TAssignableDefinition { */ pragma[nomagic] AssignableRead getAFirstRead() { - exists(Ssa::ExplicitDefinition def | result = Ssa::ssaGetAFirstUse(def) | - this = def.getADefinition() - ) + exists(SsaExplicitWrite def | result = Ssa::ssaGetAFirstUse(def) | this = def.getDefinition()) } /** Gets a textual representation of this assignable definition. */ diff --git a/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll b/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll index 48adada60d8..168ce6a1e5c 100644 --- a/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll +++ b/csharp/ql/lib/semmle/code/csharp/controlflow/Guards.qll @@ -588,7 +588,7 @@ private SsaDefinition getAnSsaQualifier(Expr e, ControlFlowNode cfn) { private AssignableAccess getATrackedAccess(SsaDefinition def, ControlFlowNode cfn) { result = def.getARead() and cfn = result.getControlFlowNode() or - result = def.(Ssa::ExplicitDefinition).getADefinition().getTargetAccess() and + result = def.(SsaExplicitWrite).getDefinition().getTargetAccess() and cfn = def.getControlFlowNode() } @@ -830,9 +830,7 @@ module Internal { ).getARead() } - private predicate nullDef(Ssa::ExplicitDefinition def) { - nullValueImplied(def.getADefinition().getSource()) - } + private predicate nullDef(SsaExplicitWrite def) { nullValueImplied(def.getValue()) } predicate nonNullValueImplied(Expr e) { nonNullValue(e) @@ -845,9 +843,7 @@ module Internal { ).getARead() } - private predicate nonNullDef(Ssa::ExplicitDefinition def) { - nonNullValueImplied(def.getADefinition().getSource()) - } + private predicate nonNullDef(SsaExplicitWrite def) { nonNullValueImplied(def.getValue()) } /** A callable that always returns a non-`null` value. */ private class NonNullCallable extends Callable { diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll index 95dfcf3f0ec..662cd5a5d18 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/Nullness.qll @@ -80,9 +80,7 @@ class AlwaysNullExpr extends Expr { } /** Holds if SSA definition `def` is always `null`. */ -private predicate nullDef(Ssa::ExplicitDefinition def) { - def.getADefinition().getSource() instanceof AlwaysNullExpr -} +private predicate nullDef(SsaExplicitWrite def) { def.getValue() instanceof AlwaysNullExpr } /** An expression that is never `null`. */ class NonNullExpr extends Expr { @@ -108,10 +106,10 @@ class NonNullExpr extends Expr { } /** Holds if SSA definition `def` is never `null`. */ -private predicate nonNullDef(Ssa::ExplicitDefinition def) { - def.getADefinition().getSource() instanceof NonNullExpr +private predicate nonNullDef(SsaExplicitWrite def) { + def.getValue() instanceof NonNullExpr or - exists(AssignableDefinition ad | ad = def.getADefinition() | + exists(AssignableDefinition ad | ad = def.getDefinition() | ad instanceof AssignableDefinitions::PatternDefinition or ad = @@ -191,7 +189,7 @@ private predicate defMaybeNull(SsaDefinition def, ControlFlowNode node, string m not de = any(Ssa::PhiNode phi).getARead() and // Don't use a check as reason if there is a `null` assignment // or argument - not def.(Ssa::ExplicitDefinition).getADefinition().getSource() instanceof MaybeNullExpr and + not def.(SsaExplicitWrite).getValue() instanceof MaybeNullExpr and not isMaybeNullArgument(def, _) ) or @@ -205,7 +203,7 @@ private predicate defMaybeNull(SsaDefinition def, ControlFlowNode node, string m ) or // If the source of a variable is `null` then the variable may be `null` - exists(AssignableDefinition adef | adef = def.(Ssa::ExplicitDefinition).getADefinition() | + exists(AssignableDefinition adef | adef = def.(SsaExplicitWrite).getDefinition() | adef.getSource() = maybeNullExpr(node.asExpr()) and reason = adef.getExpr() and msg = "because of $@ assignment" @@ -336,7 +334,7 @@ class Dereference extends G::DereferenceableExpr { private predicate isAlwaysNull0(SsaDefinition def) { forall(SsaDefinition input | input = getAnUltimateDefinition(def) | - input.(Ssa::ExplicitDefinition).getADefinition().getSource() instanceof AlwaysNullExpr + input.(SsaExplicitWrite).getValue() instanceof AlwaysNullExpr ) and not nonNullDef(def) and this = def.getARead() and diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll index dd07dcb9f28..ed75874b842 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll @@ -428,19 +428,25 @@ module Ssa { } /** + * DEPRECATED: Use `SsaExplicitWrite` instead. + * * An SSA definition that corresponds to an explicit assignable definition. */ - class ExplicitDefinition extends Definition, SsaImpl::WriteDefinition { + deprecated class ExplicitDefinition extends Definition, SsaImpl::WriteDefinition { AssignableDefinition ad; ExplicitDefinition() { SsaImpl::explicitDefinition(this, _, ad) } /** + * DEPRECATED: Use `SsaExplicitWrite.getDefinition()` instead. + * * Gets an underlying assignable definition. The result is always unique, * except for pathological `out`/`ref` assignments like `M(out x, out x)`, * where there may be more than one underlying definition. */ - final AssignableDefinition getADefinition() { result = SsaImpl::getADefinition(this) } + deprecated final AssignableDefinition getADefinition() { + result = SsaImpl::getADefinition(this) + } /** * DEPRECATED. diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll index 0f553b6e036..b55b0cbd934 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll @@ -272,7 +272,7 @@ module VariableCapture { or exists(SsaDefinition def, AssignableDefinition adef | LocalFlow::defAssigns(adef, _, _, e1) and - def.getAnUltimateDefinition().(Ssa::ExplicitDefinition).getADefinition() = adef and + def.getAnUltimateDefinition().(SsaExplicitWrite).getDefinition() = adef and def.getARead().getControlFlowNode() = e2 ) } @@ -600,8 +600,8 @@ module LocalFlow { or ThisFlow::adjacentThisRefs(nodeFrom.(PostUpdateNode).getPreUpdateNode(), nodeTo) or - exists(AssignableDefinition def, ControlFlowNode cfn, Ssa::ExplicitDefinition ssaDef | - ssaDef.getADefinition() = def and + exists(AssignableDefinition def, ControlFlowNode cfn, SsaExplicitWrite ssaDef | + ssaDef.getDefinition() = def and ssaDef.getControlFlowNode() = cfn and nodeFrom = TAssignableDefinitionNode(def, cfn) and nodeTo.(SsaDefinitionNode).getDefinition() = ssaDef @@ -2220,12 +2220,11 @@ private predicate readContentStep(Node node1, Content c, Node node2) { c instanceof ElementContent or exists( - ForeachStmt fs, Ssa::ExplicitDefinition def, - AssignableDefinitions::LocalVariableDefinition defTo + ForeachStmt fs, SsaExplicitWrite def, AssignableDefinitions::LocalVariableDefinition defTo | node1.asExpr() = fs.getIterableExpr() and defTo.getDeclaration() = fs.getVariableDeclExpr() and - def.getADefinition() = defTo and + def.getDefinition() = defTo and node2.(SsaDefinitionNode).getDefinition() = def and c instanceof ElementContent ) diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll index 6966152475b..89c7276a1a2 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll @@ -825,7 +825,7 @@ private module Cached { } cached - AssignableDefinition getADefinition(Ssa::ExplicitDefinition def) { + deprecated AssignableDefinition getADefinition(Ssa::ExplicitDefinition def) { exists(Ssa::SourceVariable v, AssignableDefinition ad | explicitDefinition(def, v, ad) | result = ad or result = getASameOutRefDefAfter(v, ad) @@ -858,7 +858,9 @@ private module Cached { } cached - predicate explicitDefinition(WriteDefinition def, Ssa::SourceVariable v, AssignableDefinition ad) { + deprecated predicate explicitDefinition( + WriteDefinition def, Ssa::SourceVariable v, AssignableDefinition ad + ) { exists(BasicBlock bb, int i | def.definesAt(v, bb, i) and variableDefinition(bb, i, v, ad) @@ -1023,7 +1025,7 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu * as we, conservatively, consider such definitions to be certain. */ predicate allowFlowIntoUncertainDef(UncertainWriteDefinition def) { - def instanceof Ssa::ExplicitDefinition + def instanceof SsaExplicitWrite or def = any(Ssa::ImplicitQualifierDefinition qdef | diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/RangeUtils.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/RangeUtils.qll index fafb85440a2..b85f68883ab 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/RangeUtils.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/RangeUtils.qll @@ -19,7 +19,7 @@ private module Impl { } /** Holds if SSA definition `def` equals `e + delta`. */ - predicate ssaUpdateStep(ExplicitDefinition def, ExprNode e, int delta) { + predicate ssaUpdateStep(SsaExplicitWrite def, ExprNode e, int delta) { exists(ControlFlowNode cfn | cfn = def.getControlFlowNode() | e = cfn.(ExprNode::Assignment).getRightOperand() and delta = 0 and diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll index 55b3ac31aa3..96d6b2b979a 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SignAnalysisSpecific.qll @@ -35,7 +35,7 @@ module Private { class Expr = CS::ControlFlowNodes::ExprNode; - class VariableUpdate = CS::Ssa::ExplicitDefinition; + class VariableUpdate = CS::SsaExplicitWrite; class Field = CS::Field; @@ -122,37 +122,25 @@ private module Impl { } /** Returns the underlying variable update of the explicit SSA variable `v`. */ - Ssa::ExplicitDefinition getExplicitSsaAssignment(Ssa::ExplicitDefinition v) { result = v } + SsaExplicitWrite getExplicitSsaAssignment(SsaExplicitWrite v) { result = v } /** Returns the assignment of the variable update `def`. */ - ExprNode getExprFromSsaAssignment(Ssa::ExplicitDefinition def) { - exists(AssignableDefinition adef | - adef = def.getADefinition() and - hasChild(adef.getExpr(), adef.getSource(), def.getControlFlowNode(), result) - ) - or - exists(AssignableDefinitions::AssignOperationDefinition adef | - adef = def.getADefinition() and - result.getExpr() = adef.getSource() - ) - } + ExprNode getExprFromSsaAssignment(SsaExplicitWrite def) { result.getExpr() = def.getValue() } /** Holds if `def` can have any sign. */ - predicate explicitSsaDefWithAnySign(Ssa::ExplicitDefinition def) { - not exists(def.getADefinition().getSource()) and - not def.getElement() instanceof MutatorOperation + predicate explicitSsaDefWithAnySign(SsaExplicitWrite def) { + not exists(def.getValue()) and + not def.getDefiningExpr() instanceof MutatorOperation } /** Returns the operand of the operation if `def` is a decrement. */ - ExprNode getDecrementOperand(Ssa::ExplicitDefinition def) { - hasChild(def.getElement(), def.getElement().(DecrementOperation).getOperand(), - def.getControlFlowNode(), result) + ExprNode getDecrementOperand(SsaExplicitWrite def) { + result.getExpr() = def.getDefiningExpr().(DecrementOperation).getOperand() } /** Returns the operand of the operation if `def` is an increment. */ - ExprNode getIncrementOperand(Ssa::ExplicitDefinition def) { - hasChild(def.getElement(), def.getElement().(IncrementOperation).getOperand(), - def.getControlFlowNode(), result) + ExprNode getIncrementOperand(SsaExplicitWrite def) { + result.getExpr() = def.getDefiningExpr().(IncrementOperation).getOperand() } /** Gets the variable underlying the implicit SSA variable `def`. */ diff --git a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaUtils.qll b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaUtils.qll index 5681976a378..33afe07dae3 100644 --- a/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaUtils.qll +++ b/csharp/ql/lib/semmle/code/csharp/dataflow/internal/rangeanalysis/SsaUtils.qll @@ -17,9 +17,9 @@ class SsaVariable extends SsaDefinition { /** Gets a node that reads `src` via an SSA explicit definition. */ ExprNode getAnExplicitDefinitionRead(ExprNode src) { - exists(ExplicitDefinition def | + exists(SsaExplicitWrite def | def.getARead().getControlFlowNode() = result and - hasChild(def.getElement(), def.getADefinition().getSource(), def.getControlFlowNode(), src) + hasChild(def.getDefiningExpr(), def.getValue(), def.getControlFlowNode(), src) ) } @@ -45,15 +45,15 @@ ExprNode ssaRead(SsaDefinition v, int delta) { delta = d1 + c.getIntValue() ) or - v.(ExplicitDefinition).getControlFlowNode().(ExprNode::PreIncrExpr) = result and delta = 0 + v.(SsaExplicitWrite).getControlFlowNode().(ExprNode::PreIncrExpr) = result and delta = 0 or - v.(ExplicitDefinition).getControlFlowNode().(ExprNode::PreDecrExpr) = result and delta = 0 + v.(SsaExplicitWrite).getControlFlowNode().(ExprNode::PreDecrExpr) = result and delta = 0 or - v.(ExplicitDefinition).getControlFlowNode().(ExprNode::PostIncrExpr) = result and delta = 1 // x++ === ++x - 1 + v.(SsaExplicitWrite).getControlFlowNode().(ExprNode::PostIncrExpr) = result and delta = 1 // x++ === ++x - 1 or - v.(ExplicitDefinition).getControlFlowNode().(ExprNode::PostDecrExpr) = result and delta = -1 // x-- === --x + 1 + v.(SsaExplicitWrite).getControlFlowNode().(ExprNode::PostDecrExpr) = result and delta = -1 // x-- === --x + 1 or - v.(ExplicitDefinition).getControlFlowNode().(ExprNode::Assignment) = result and delta = 0 + v.(SsaExplicitWrite).getControlFlowNode().(ExprNode::Assignment) = result and delta = 0 or result.(ExprNode::AssignExpr).getRightOperand() = ssaRead(v, delta) } diff --git a/csharp/ql/src/Dead Code/DeadStoreOfLocal.ql b/csharp/ql/src/Dead Code/DeadStoreOfLocal.ql index 12baac99c78..cf57707608b 100644 --- a/csharp/ql/src/Dead Code/DeadStoreOfLocal.ql +++ b/csharp/ql/src/Dead Code/DeadStoreOfLocal.ql @@ -92,7 +92,7 @@ class RelevantDefinition extends AssignableDefinition { private predicate isMaybeLive() { exists(LocalVariable v | v = this.getTarget() | // SSA definitions are only created for live variables - this = any(Ssa::ExplicitDefinition ssaDef).getADefinition() + this = any(SsaExplicitWrite ssaDef).getDefinition() or mayEscape(v) or diff --git a/csharp/ql/src/Likely Bugs/Dynamic/BadDynamicCall.ql b/csharp/ql/src/Likely Bugs/Dynamic/BadDynamicCall.ql index 4d68f6ee628..afb44727e34 100644 --- a/csharp/ql/src/Likely Bugs/Dynamic/BadDynamicCall.ql +++ b/csharp/ql/src/Likely Bugs/Dynamic/BadDynamicCall.ql @@ -36,17 +36,16 @@ abstract class BadDynamicCall extends DynamicExpr { } private Type possibleTypeForRelevantSource(Variable v, int i, Expr source) { - exists(AssignableRead read, SsaDefinition ssaDef, Ssa::ExplicitDefinition ultimateSsaDef | + exists(AssignableRead read, SsaDefinition ssaDef, SsaExplicitWrite ultimateSsaDef | read = this.getARelevantVariableAccess(i) and v = read.getTarget() and result = source.getType() and read = ssaDef.getARead() and ultimateSsaDef = ssaDef.getAnUltimateDefinition() | - ultimateSsaDef.getADefinition() = - any(AssignableDefinition def | source = def.getSource().stripImplicit()) + ultimateSsaDef.getValue().stripImplicit() = source or - ultimateSsaDef.getADefinition() = + ultimateSsaDef.getDefinition() = any(AssignableDefinitions::ImplicitParameterDefinition p | source = p.getParameter().getAnAssignedValue().stripImplicit() ) diff --git a/csharp/ql/test/library-tests/csharp7/DefUse.ql b/csharp/ql/test/library-tests/csharp7/DefUse.ql index e696307be28..ccdd4db0157 100644 --- a/csharp/ql/test/library-tests/csharp7/DefUse.ql +++ b/csharp/ql/test/library-tests/csharp7/DefUse.ql @@ -3,11 +3,6 @@ import csharp from AssignableDefinition def, AssignableRead read, SsaDefinition ult, SsaDefinition ssaDef where ssaDef.getAnUltimateDefinition() = ult and - ( - ult.(Ssa::ExplicitDefinition).getADefinition() = def - or - ult.(Ssa::ParameterDefinition).getParameter() = - def.(AssignableDefinitions::ImplicitParameterDefinition).getParameter() - ) and + ult.(SsaExplicitWrite).getDefinition() = def and read = ssaDef.getARead() select def, read diff --git a/csharp/ql/test/library-tests/dataflow/callablereturnsarg/Common.qll b/csharp/ql/test/library-tests/dataflow/callablereturnsarg/Common.qll index 95a93e24a2a..2af01c72333 100644 --- a/csharp/ql/test/library-tests/dataflow/callablereturnsarg/Common.qll +++ b/csharp/ql/test/library-tests/dataflow/callablereturnsarg/Common.qll @@ -2,9 +2,9 @@ import csharp private import semmle.code.csharp.controlflow.Guards private predicate outRefDef(DataFlow::ExprNode ne, int outRef) { - exists(Ssa::ExplicitDefinition def, Parameter outRefParameter | + exists(SsaExplicitWrite def, Parameter outRefParameter | outRefParameter.isOutOrRef() and - ne.getExpr() = def.getADefinition().getSource() and + ne.getExpr() = def.getValue() and Ssa::isLiveOutRefParameterDefinition(def, outRefParameter) and outRef = outRefParameter.getPosition() ) diff --git a/csharp/ql/test/library-tests/dataflow/defuse/defUseEquivalence.ql b/csharp/ql/test/library-tests/dataflow/defuse/defUseEquivalence.ql index 800ae971759..1897c97bd65 100644 --- a/csharp/ql/test/library-tests/dataflow/defuse/defUseEquivalence.ql +++ b/csharp/ql/test/library-tests/dataflow/defuse/defUseEquivalence.ql @@ -12,6 +12,10 @@ predicate defReaches( def.(AssignableDefinitions::ImplicitParameterDefinition).getParameter().getControlFlowNode() ].getASuccessor() or + def.getTarget() = v and + cfn = + def.(AssignableDefinitions::ImplicitParameterDefinition).getEnclosingCallable().getEntryPoint() + or exists(ControlFlowNode mid | defReaches(def, v, mid) | not mid = any(AssignableDefinition ad | ad.getTarget() = v and ad.isCertain()) @@ -30,7 +34,7 @@ predicate defUsePair(AssignableDefinition def, AssignableRead read) { private LocalScopeVariableRead getAReachableUncertainRead(AssignableDefinition def) { exists(SsaDefinition ssaDef | - def = ssaDef.getAnUltimateDefinition().(Ssa::ExplicitDefinition).getADefinition() + def = ssaDef.getAnUltimateDefinition().(SsaExplicitWrite).getDefinition() | result = ssaDef.getARead() ) diff --git a/csharp/ql/test/library-tests/dataflow/ssa-large/countssa.ql b/csharp/ql/test/library-tests/dataflow/ssa-large/countssa.ql index 94218ca6c7e..e9d2f74ff27 100644 --- a/csharp/ql/test/library-tests/dataflow/ssa-large/countssa.ql +++ b/csharp/ql/test/library-tests/dataflow/ssa-large/countssa.ql @@ -2,6 +2,6 @@ import csharp from int uses, int live where - uses = strictcount(Ssa::ExplicitDefinition ssa, AssignableRead read | read = ssa.getARead()) and - live = strictcount(Ssa::ExplicitDefinition ssa, BasicBlock bb | ssa.isLiveAtEndOfBlock(bb)) + uses = strictcount(SsaExplicitWrite ssa, AssignableRead read | read = ssa.getARead()) and + live = strictcount(SsaExplicitWrite ssa, BasicBlock bb | ssa.isLiveAtEndOfBlock(bb)) select uses, live diff --git a/csharp/ql/test/library-tests/dataflow/ssa/BaseSsaConsistency.ql b/csharp/ql/test/library-tests/dataflow/ssa/BaseSsaConsistency.ql index d68e39fb396..2634ef14a37 100644 --- a/csharp/ql/test/library-tests/dataflow/ssa/BaseSsaConsistency.ql +++ b/csharp/ql/test/library-tests/dataflow/ssa/BaseSsaConsistency.ql @@ -8,12 +8,8 @@ where ar = ssaDef.getARead() and def = ssaDef.getDefinition() and v = def.getTarget() and - not exists(Ssa::ExplicitDefinition edef | - edef.getADefinition() = def and - edef.getARead() = ar - ) and - not exists(Ssa::ParameterDefinition edef | - edef.getParameter() = def.(AssignableDefinitions::ImplicitParameterDefinition).getParameter() and + not exists(SsaExplicitWrite edef | + edef.getDefinition() = def and edef.getARead() = ar ) select ar, def diff --git a/csharp/ql/test/library-tests/dataflow/ssa/SsaExplicitDef.ql b/csharp/ql/test/library-tests/dataflow/ssa/SsaExplicitDef.ql index bf4c70ee673..4e37c24b0cc 100644 --- a/csharp/ql/test/library-tests/dataflow/ssa/SsaExplicitDef.ql +++ b/csharp/ql/test/library-tests/dataflow/ssa/SsaExplicitDef.ql @@ -1,5 +1,5 @@ import csharp -from Ssa::SourceVariable v, Ssa::ExplicitDefinition def +from Ssa::SourceVariable v, SsaExplicitWrite def where v = def.getSourceVariable() -select v, def, def.getADefinition() +select v, def, def.getDefinition()