Skip to content

Commit ed6cdfc

Browse files
committed
C#: Move isLiveOutRefParameterDefinition to top-level.
1 parent 9345c44 commit ed6cdfc

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
@@ -190,6 +190,8 @@ module Ssa {
190190
)
191191
}
192192

193+
predicate isLiveOutRefParameterDefinition = SsaImpl::isLiveOutRefParameterDefinition/2;
194+
193195
/**
194196
* A static single assignment (SSA) definition. Either an explicit variable
195197
* definition (`ExplicitDefinition`), an implicit variable definition
@@ -408,10 +410,12 @@ module Ssa {
408410
}
409411

410412
/**
413+
* DEPRECATED: Use `isLiveOutRefParameterDefinition(SsaDefinition, Parameter)` instead.
414+
*
411415
* Holds if this SSA definition assigns to `out`/`ref` parameter `p`, and the
412416
* parameter may remain unchanged throughout the rest of the enclosing callable.
413417
*/
414-
final predicate isLiveOutRefParameterDefinition(Parameter p) {
418+
deprecated final predicate isLiveOutRefParameterDefinition(Parameter p) {
415419
SsaImpl::isLiveOutRefParameterDefinition(this, p)
416420
}
417421

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,7 @@ class SsaNode extends NodeImpl, TSsaNode {
12441244
class SsaDefinitionNode extends SsaNode {
12451245
override SsaImpl::DataFlowIntegration::SsaDefinitionNode node;
12461246

1247-
Ssa::Definition getDefinition() { result = node.getDefinition() }
1247+
SsaDefinition getDefinition() { result = node.getDefinition() }
12481248

12491249
override ControlFlowNode getControlFlowNodeImpl() {
12501250
result = this.getDefinition().getControlFlowNode()
@@ -1613,7 +1613,7 @@ private module ReturnNodes {
16131613

16141614
OutRefReturnNode() {
16151615
exists(Parameter p |
1616-
this.getDefinition().isLiveOutRefParameterDefinition(p) and
1616+
Ssa::isLiveOutRefParameterDefinition(this.getDefinition(), p) and
16171617
kind.getPosition() = p.getPosition()
16181618
|
16191619
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
@@ -914,6 +914,10 @@ private module Cached {
914914
Impl::uncertainWriteDefinitionInput(def, result)
915915
}
916916

917+
/**
918+
* Holds if the SSA definition `def` assigns to `out`/`ref` parameter `p`, and the
919+
* parameter may remain unchanged throughout the rest of the enclosing callable.
920+
*/
917921
cached
918922
predicate isLiveOutRefParameterDefinition(SsaDefinition def, Parameter p) {
919923
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)