mirror of
https://github.com/github/codeql.git
synced 2025-12-17 09:13:20 +01:00
Java: Replace SsaPhiNode with SsaPhiDefinition.
This commit is contained in:
@@ -142,7 +142,7 @@ private predicate varMaybeNull(SsaVariable v, ControlFlowNode node, string msg,
|
|||||||
msg = "as suggested by $@ null guard" and
|
msg = "as suggested by $@ null guard" and
|
||||||
guardSuggestsVarMaybeNull(e, v) and
|
guardSuggestsVarMaybeNull(e, v) and
|
||||||
node = v.getCfgNode() and
|
node = v.getCfgNode() and
|
||||||
not v instanceof SsaPhiNode and
|
not v instanceof SsaPhiDefinition and
|
||||||
not clearlyNotNull(v) and
|
not clearlyNotNull(v) and
|
||||||
// Comparisons in finally blocks are excluded since missing exception edges in the CFG could otherwise yield FPs.
|
// Comparisons in finally blocks are excluded since missing exception edges in the CFG could otherwise yield FPs.
|
||||||
not exists(TryStmt try | try.getFinally() = e.getEnclosingStmt().getEnclosingStmt*()) and
|
not exists(TryStmt try | try.getFinally() = e.getEnclosingStmt().getEnclosingStmt*()) and
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ module Sem implements Semantic<Location> {
|
|||||||
Expr getAUse() { result = super.getAUse() }
|
Expr getAUse() { result = super.getAUse() }
|
||||||
}
|
}
|
||||||
|
|
||||||
class SsaPhiNode extends SsaVariable instanceof SSA::SsaPhiNode {
|
class SsaPhiNode extends SsaVariable instanceof SSA::SsaPhiDefinition {
|
||||||
predicate hasInputFromBlock(SsaVariable inp, BasicBlock bb) { super.hasInputFromBlock(inp, bb) }
|
predicate hasInputFromBlock(SsaVariable inp, BasicBlock bb) { super.hasInputFromBlock(inp, bb) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ predicate eqFlowCond = U::eqFlowCond/5;
|
|||||||
* only other input to `phi` is a `null` value.
|
* only other input to `phi` is a `null` value.
|
||||||
*
|
*
|
||||||
* Note that the declared type of `phi` is `SsaVariable` instead of
|
* Note that the declared type of `phi` is `SsaVariable` instead of
|
||||||
* `SsaPhiNode` in order for the reflexive case of `nonNullSsaFwdStep*(..)` to
|
* `SsaPhiDefinition` in order for the reflexive case of `nonNullSsaFwdStep*(..)` to
|
||||||
* have non-`SsaPhiNode` results.
|
* have non-`SsaPhiDefinition` results.
|
||||||
*/
|
*/
|
||||||
private predicate nonNullSsaFwdStep(SsaVariable v, SsaVariable phi) {
|
private predicate nonNullSsaFwdStep(SsaVariable v, SsaVariable phi) {
|
||||||
exists(SsaExplicitWrite vnull, SsaPhiNode phi0 | phi0 = phi |
|
exists(SsaExplicitWrite vnull, SsaPhiDefinition phi0 | phi0 = phi |
|
||||||
2 = strictcount(phi0.getAPhiInput()) and
|
2 = strictcount(phi0.getAnInput()) and
|
||||||
vnull = phi0.getAPhiInput() and
|
vnull = phi0.getAnInput() and
|
||||||
v = phi0.getAPhiInput() and
|
v = phi0.getAnInput() and
|
||||||
not backEdge(phi0, v, _) and
|
not backEdge(phi0, v, _) and
|
||||||
vnull != v and
|
vnull != v and
|
||||||
vnull.getValue() instanceof NullLiteral
|
vnull.getValue() instanceof NullLiteral
|
||||||
|
|||||||
@@ -381,12 +381,20 @@ class SsaImplicitInit extends SsaVariable instanceof WriteDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** An SSA phi node. */
|
/**
|
||||||
class SsaPhiNode extends SsaVariable instanceof PhiNode {
|
* DEPRECATED: Use `SsaPhiDefinition` instead.
|
||||||
|
*
|
||||||
|
* An SSA phi node.
|
||||||
|
*/
|
||||||
|
deprecated class SsaPhiNode extends SsaVariable instanceof PhiNode {
|
||||||
override string toString() { result = "SSA phi(" + this.getSourceVariable() + ")" }
|
override string toString() { result = "SSA phi(" + this.getSourceVariable() + ")" }
|
||||||
|
|
||||||
/** Gets an input to the phi node defining the SSA variable. */
|
/**
|
||||||
SsaVariable getAPhiInput() { this.hasInputFromBlock(result, _) }
|
* DEPRECATED: Use `getAnInput()` instead.
|
||||||
|
*
|
||||||
|
* Gets an input to the phi node defining the SSA variable.
|
||||||
|
*/
|
||||||
|
deprecated SsaVariable getAPhiInput() { this.hasInputFromBlock(result, _) }
|
||||||
|
|
||||||
/** Gets an input to the phi node defining the SSA variable. */
|
/** Gets an input to the phi node defining the SSA variable. */
|
||||||
SsaVariable getAnInput() { this.hasInputFromBlock(result, _) }
|
SsaVariable getAnInput() { this.hasInputFromBlock(result, _) }
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ module Private {
|
|||||||
|
|
||||||
class SsaVariable = Ssa::SsaVariable;
|
class SsaVariable = Ssa::SsaVariable;
|
||||||
|
|
||||||
class SsaPhiNode = Ssa::SsaPhiNode;
|
class SsaPhiNode = Ssa::SsaPhiDefinition;
|
||||||
|
|
||||||
class Expr = J::Expr;
|
class Expr = J::Expr;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ module Private {
|
|||||||
|
|
||||||
class SsaVariable = Ssa::SsaVariable;
|
class SsaVariable = Ssa::SsaVariable;
|
||||||
|
|
||||||
class SsaPhiNode = Ssa::SsaPhiNode;
|
class SsaPhiNode = Ssa::SsaPhiDefinition;
|
||||||
|
|
||||||
class VarAccess = J::VarAccess;
|
class VarAccess = J::VarAccess;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ private import SsaReadPositionCommon
|
|||||||
|
|
||||||
class SsaVariable = Ssa::SsaVariable;
|
class SsaVariable = Ssa::SsaVariable;
|
||||||
|
|
||||||
class SsaPhiNode = Ssa::SsaPhiNode;
|
class SsaPhiNode = Ssa::SsaPhiDefinition;
|
||||||
|
|
||||||
class BasicBlock = BB::BasicBlock;
|
class BasicBlock = BB::BasicBlock;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import java
|
import java
|
||||||
import semmle.code.java.dataflow.SSA
|
import semmle.code.java.dataflow.SSA
|
||||||
|
|
||||||
from SsaPhiNode ssa, SsaSourceVariable v, SsaVariable phiInput
|
from SsaPhiDefinition ssa, SsaSourceVariable v, SsaDefinition phiInput
|
||||||
where ssa.getAPhiInput() = phiInput and ssa.getSourceVariable() = v
|
where ssa.getAnInput() = phiInput and ssa.getSourceVariable() = v
|
||||||
select v, ssa.getCfgNode(), phiInput.getCfgNode()
|
select v, ssa.getControlFlowNode(), phiInput.getControlFlowNode()
|
||||||
|
|||||||
Reference in New Issue
Block a user