Skip to content

Commit aac3071

Browse files
committed
C#: Move isLiveOutRefParameterDefinition to top-level.
1 parent 5ea3dc2 commit aac3071

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

csharp/ql/lib/semmle/code/csharp/dataflow/SSA.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@ module Ssa {
200200
)
201201
}
202202

203+
predicate isLiveOutRefParameterDefinition = SsaImpl::isLiveOutRefParameterDefinition/2;
204+
203205
/**
204206
* A static single assignment (SSA) definition. Either an explicit variable
205207
* definition (`ExplicitDefinition`), an implicit variable definition
@@ -418,10 +420,12 @@ module Ssa {
418420
}
419421

420422
/**
423+
* DEPRECATED: Use `isLiveOutRefParameterDefinition(SsaDefinition, Parameter)` instead.
424+
*
421425
* Holds if this SSA definition assigns to `out`/`ref` parameter `p`, and the
422426
* parameter may remain unchanged throughout the rest of the enclosing callable.
423427
*/
424-
final predicate isLiveOutRefParameterDefinition(Parameter p) {
428+
deprecated final predicate isLiveOutRefParameterDefinition(Parameter p) {
425429
SsaImpl::isLiveOutRefParameterDefinition(this, p)
426430
}
427431

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ class SsaNode extends NodeImpl, TSsaNode {
12291229
class SsaDefinitionNode extends SsaNode {
12301230
override SsaImpl::DataFlowIntegration::SsaDefinitionNode node;
12311231

1232-
Ssa::Definition getDefinition() { result = node.getDefinition() }
1232+
SsaDefinition getDefinition() { result = node.getDefinition() }
12331233

12341234
override ControlFlowNode getControlFlowNodeImpl() {
12351235
result = this.getDefinition().getControlFlowNode()
@@ -1598,7 +1598,7 @@ private module ReturnNodes {
15981598

15991599
OutRefReturnNode() {
16001600
exists(Parameter p |
1601-
this.getDefinition().isLiveOutRefParameterDefinition(p) and
1601+
Ssa::isLiveOutRefParameterDefinition(this.getDefinition(), p) and
16021602
kind.getPosition() = p.getPosition()
16031603
|
16041604
p.isOut() and kind instanceof OutReturnKind

csharp/ql/lib/semmle/code/csharp/dataflow/internal/SsaImpl.qll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,10 @@ private module Cached {
899899
Impl::uncertainWriteDefinitionInput(def, result)
900900
}
901901

902+
/**
903+
* Holds if the SSA definition `def` assigns to `out`/`ref` parameter `p`, and the
904+
* parameter may remain unchanged throughout the rest of the enclosing callable.
905+
*/
902906
cached
903907
predicate isLiveOutRefParameterDefinition(SsaDefinition def, Parameter p) {
904908
p.isOutOrRef() and

csharp/ql/test/library-tests/dataflow/callablereturnsarg/Common.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ private predicate outRefDef(DataFlow::ExprNode ne, int outRef) {
55
exists(Ssa::ExplicitDefinition def, Parameter outRefParameter |
66
outRefParameter.isOutOrRef() and
77
ne.getExpr() = def.getADefinition().getSource() and
8-
def.isLiveOutRefParameterDefinition(outRefParameter) and
8+
Ssa::isLiveOutRefParameterDefinition(def, outRefParameter) and
99
outRef = outRefParameter.getPosition()
1010
)
1111
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import csharp
22

3-
from Ssa::SourceVariable v, Ssa::Definition def
3+
from Ssa::SourceVariable v, SsaDefinition def
44
where
55
v = def.getSourceVariable() and
6-
def.isLiveOutRefParameterDefinition(_)
6+
Ssa::isLiveOutRefParameterDefinition(def, _)
77
select v, def

0 commit comments

Comments
 (0)