mirror of
https://github.com/github/codeql.git
synced 2026-05-14 11:19:27 +02:00
C#: Address some review comments.
This commit is contained in:
@@ -183,14 +183,7 @@ module Ssa {
|
||||
* Subsequent reads can be found by following the steps defined by
|
||||
* `AssignableRead.getANextRead()`.
|
||||
*/
|
||||
AssignableRead ssaGetAFirstUse(SsaDefinition def) {
|
||||
exists(ControlFlowNode cfn |
|
||||
SsaImpl::firstReadSameVar(def, cfn) and
|
||||
result.getControlFlowNode() = cfn
|
||||
)
|
||||
}
|
||||
|
||||
predicate isLiveOutRefParameterDefinition = SsaImpl::isLiveOutRefParameterDefinition/2;
|
||||
AssignableRead ssaGetAFirstUse(SsaDefinition def) { SsaImpl::firstReadSameVar(def, result) }
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `SsaDefinition` instead.
|
||||
@@ -350,7 +343,7 @@ module Ssa {
|
||||
* `AssignableRead.getANextRead()`.
|
||||
*/
|
||||
deprecated final AssignableRead getAFirstReadAtNode(ControlFlowNode cfn) {
|
||||
SsaImpl::firstReadSameVar(this, cfn) and
|
||||
SsaImpl::firstReadSameVar(this, result) and
|
||||
result.getControlFlowNode() = cfn
|
||||
}
|
||||
|
||||
@@ -416,7 +409,7 @@ module Ssa {
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use `isLiveOutRefParameterDefinition(SsaDefinition, Parameter)` instead.
|
||||
* DEPRECATED.
|
||||
*
|
||||
* Holds if this SSA definition assigns to `out`/`ref` parameter `p`, and the
|
||||
* parameter may remain unchanged throughout the rest of the enclosing callable.
|
||||
|
||||
@@ -1605,7 +1605,7 @@ private module ReturnNodes {
|
||||
|
||||
OutRefReturnNode() {
|
||||
exists(Parameter p |
|
||||
Ssa::isLiveOutRefParameterDefinition(this.getDefinition(), p) and
|
||||
SsaImpl::isLiveOutRefParameterDefinition(this.getDefinition(), p) and
|
||||
kind.getPosition() = p.getPosition()
|
||||
|
|
||||
p.isOut() and kind instanceof OutReturnKind
|
||||
|
||||
@@ -854,12 +854,14 @@ private module Cached {
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if the value defined at SSA definition `def` can reach a read at `cfn`,
|
||||
* Holds if the value defined at SSA definition `def` can reach a read `read`,
|
||||
* without passing through any other read.
|
||||
*/
|
||||
cached
|
||||
predicate firstReadSameVar(Definition def, ControlFlowNode cfn) {
|
||||
exists(BasicBlock bb, int i | Impl::firstUse(def, bb, i, true) and cfn = bb.getNode(i))
|
||||
predicate firstReadSameVar(Definition def, AssignableRead read) {
|
||||
exists(BasicBlock bb, int i |
|
||||
Impl::firstUse(def, bb, i, true) and read.getControlFlowNode() = bb.getNode(i)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import csharp
|
||||
private import semmle.code.csharp.controlflow.Guards
|
||||
private import semmle.code.csharp.dataflow.internal.SsaImpl as SsaImpl
|
||||
|
||||
private predicate outRefDef(DataFlow::ExprNode ne, int outRef) {
|
||||
exists(SsaExplicitWrite def, Parameter outRefParameter |
|
||||
outRefParameter.isOutOrRef() and
|
||||
ne.getExpr() = def.getValue() and
|
||||
Ssa::isLiveOutRefParameterDefinition(def, outRefParameter) and
|
||||
SsaImpl::isLiveOutRefParameterDefinition(def, outRefParameter) and
|
||||
outRef = outRefParameter.getPosition()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import csharp
|
||||
private import semmle.code.csharp.dataflow.internal.SsaImpl as SsaImpl
|
||||
|
||||
from Ssa::SourceVariable v, SsaDefinition def
|
||||
where
|
||||
v = def.getSourceVariable() and
|
||||
Ssa::isLiveOutRefParameterDefinition(def, _)
|
||||
SsaImpl::isLiveOutRefParameterDefinition(def, _)
|
||||
select v, def
|
||||
|
||||
Reference in New Issue
Block a user