C#: Move isLiveOutRefParameterDefinition to top-level.

This commit is contained in:
Anders Schack-Mulligen
2026-04-24 08:47:36 +02:00
parent 9345c44e0f
commit ed6cdfc227
5 changed files with 14 additions and 6 deletions

View File

@@ -190,6 +190,8 @@ module Ssa {
)
}
predicate isLiveOutRefParameterDefinition = SsaImpl::isLiveOutRefParameterDefinition/2;
/**
* A static single assignment (SSA) definition. Either an explicit variable
* definition (`ExplicitDefinition`), an implicit variable definition
@@ -408,10 +410,12 @@ module Ssa {
}
/**
* DEPRECATED: Use `isLiveOutRefParameterDefinition(SsaDefinition, Parameter)` instead.
*
* Holds if this SSA definition assigns to `out`/`ref` parameter `p`, and the
* parameter may remain unchanged throughout the rest of the enclosing callable.
*/
final predicate isLiveOutRefParameterDefinition(Parameter p) {
deprecated final predicate isLiveOutRefParameterDefinition(Parameter p) {
SsaImpl::isLiveOutRefParameterDefinition(this, p)
}

View File

@@ -1244,7 +1244,7 @@ class SsaNode extends NodeImpl, TSsaNode {
class SsaDefinitionNode extends SsaNode {
override SsaImpl::DataFlowIntegration::SsaDefinitionNode node;
Ssa::Definition getDefinition() { result = node.getDefinition() }
SsaDefinition getDefinition() { result = node.getDefinition() }
override ControlFlowNode getControlFlowNodeImpl() {
result = this.getDefinition().getControlFlowNode()
@@ -1613,7 +1613,7 @@ private module ReturnNodes {
OutRefReturnNode() {
exists(Parameter p |
this.getDefinition().isLiveOutRefParameterDefinition(p) and
Ssa::isLiveOutRefParameterDefinition(this.getDefinition(), p) and
kind.getPosition() = p.getPosition()
|
p.isOut() and kind instanceof OutReturnKind

View File

@@ -914,6 +914,10 @@ private module Cached {
Impl::uncertainWriteDefinitionInput(def, result)
}
/**
* Holds if the SSA definition `def` assigns to `out`/`ref` parameter `p`, and the
* parameter may remain unchanged throughout the rest of the enclosing callable.
*/
cached
predicate isLiveOutRefParameterDefinition(SsaDefinition def, Parameter p) {
p.isOutOrRef() and

View File

@@ -5,7 +5,7 @@ private predicate outRefDef(DataFlow::ExprNode ne, int outRef) {
exists(Ssa::ExplicitDefinition def, Parameter outRefParameter |
outRefParameter.isOutOrRef() and
ne.getExpr() = def.getADefinition().getSource() and
def.isLiveOutRefParameterDefinition(outRefParameter) and
Ssa::isLiveOutRefParameterDefinition(def, outRefParameter) and
outRef = outRefParameter.getPosition()
)
}

View File

@@ -1,7 +1,7 @@
import csharp
from Ssa::SourceVariable v, Ssa::Definition def
from Ssa::SourceVariable v, SsaDefinition def
where
v = def.getSourceVariable() and
def.isLiveOutRefParameterDefinition(_)
Ssa::isLiveOutRefParameterDefinition(def, _)
select v, def