mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Java: Remove old SSA consistency queries.
This commit is contained in:
@@ -1,27 +0,0 @@
|
|||||||
/**
|
|
||||||
* @name An SSA variable without a unique 'toString()'
|
|
||||||
* @description An ambiguous 'toString()' indicates overlap in the defining
|
|
||||||
* sub-classes of 'SsaVariable'.
|
|
||||||
* @kind problem
|
|
||||||
* @problem.severity error
|
|
||||||
* @id java/consistency/non-unique-ssa-tostring
|
|
||||||
* @tags consistency
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java
|
|
||||||
import semmle.code.java.dataflow.SSA
|
|
||||||
|
|
||||||
predicate noToString(SsaVariable v) { not exists(v.toString()) }
|
|
||||||
|
|
||||||
predicate multipleToString(SsaVariable v) { 1 < count(v.toString()) }
|
|
||||||
|
|
||||||
from SsaVariable ssa, ControlFlowNode n, Variable v, string problem
|
|
||||||
where
|
|
||||||
(
|
|
||||||
noToString(ssa) and problem = "SSA variable without 'toString()' for "
|
|
||||||
or
|
|
||||||
multipleToString(ssa) and problem = "SSA variable with multiple 'toString()' results for "
|
|
||||||
) and
|
|
||||||
n = ssa.getCfgNode() and
|
|
||||||
v = ssa.getSourceVariable().getVariable()
|
|
||||||
select n, problem + v
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* @name A phi node without two or more inputs
|
|
||||||
* @description A phi node should have at least two inputs.
|
|
||||||
* @kind problem
|
|
||||||
* @problem.severity error
|
|
||||||
* @id java/consistency/too-few-phi-inputs
|
|
||||||
* @tags consistency
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java
|
|
||||||
import semmle.code.java.dataflow.SSA
|
|
||||||
|
|
||||||
from SsaPhiNode phi, int inputs
|
|
||||||
where
|
|
||||||
inputs = count(SsaVariable v | v = phi.getAPhiInput()) and
|
|
||||||
inputs < 2
|
|
||||||
select phi, "Phi node for " + phi.getSourceVariable() + " has only " + inputs + " inputs."
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* @name An uncertain SSA update without a prior definition
|
|
||||||
* @description An uncertain SSA update may retain its previous value
|
|
||||||
* and should therefore have a prior definition.
|
|
||||||
* @kind problem
|
|
||||||
* @problem.severity error
|
|
||||||
* @id java/consistency/uncertain-ssa-update-without-prior-def
|
|
||||||
* @tags consistency
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java
|
|
||||||
import semmle.code.java.dataflow.SSA
|
|
||||||
|
|
||||||
predicate live(SsaVariable v) {
|
|
||||||
exists(v.getAUse())
|
|
||||||
or
|
|
||||||
exists(SsaPhiNode phi | live(phi) and phi.getAPhiInput() = v)
|
|
||||||
or
|
|
||||||
exists(SsaUncertainImplicitUpdate upd | live(upd) and upd.getPriorDef() = v)
|
|
||||||
}
|
|
||||||
|
|
||||||
from SsaUncertainImplicitUpdate upd
|
|
||||||
where
|
|
||||||
live(upd) and
|
|
||||||
not exists(upd.getPriorDef())
|
|
||||||
select upd, "No prior definition of " + upd
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
/**
|
|
||||||
* @name A variable use without a unique SSA variable
|
|
||||||
* @description Every variable use that is sufficiently trackable
|
|
||||||
* should have a unique associated SSA variable.
|
|
||||||
* @kind problem
|
|
||||||
* @problem.severity error
|
|
||||||
* @id java/consistency/use-without-unique-ssa-variable
|
|
||||||
* @tags consistency
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java
|
|
||||||
import semmle.code.java.dataflow.SSA
|
|
||||||
|
|
||||||
class SsaConvertibleReadAccess extends VarRead {
|
|
||||||
SsaConvertibleReadAccess() {
|
|
||||||
this.getEnclosingCallable().getBody().getBasicBlock().getASuccessor*() = this.getBasicBlock() and
|
|
||||||
(
|
|
||||||
not exists(this.getQualifier())
|
|
||||||
or
|
|
||||||
this.getVariable() instanceof LocalScopeVariable
|
|
||||||
or
|
|
||||||
this.getVariable().(Field).isStatic()
|
|
||||||
or
|
|
||||||
exists(Expr q | q = this.getQualifier() |
|
|
||||||
q instanceof ThisAccess or
|
|
||||||
q instanceof SuperAccess or
|
|
||||||
q instanceof SsaConvertibleReadAccess
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
predicate accessWithoutSourceVariable(SsaConvertibleReadAccess va) {
|
|
||||||
not exists(SsaSourceVariable v | v.getAnAccess() = va)
|
|
||||||
}
|
|
||||||
|
|
||||||
predicate readAccessWithoutSsaVariable(SsaConvertibleReadAccess va) {
|
|
||||||
not exists(SsaVariable v | v.getAUse() = va)
|
|
||||||
}
|
|
||||||
|
|
||||||
predicate readAccessWithAmbiguousSsaVariable(SsaConvertibleReadAccess va) {
|
|
||||||
1 < strictcount(SsaVariable v | v.getAUse() = va)
|
|
||||||
}
|
|
||||||
|
|
||||||
from SsaConvertibleReadAccess va, string problem
|
|
||||||
where
|
|
||||||
accessWithoutSourceVariable(va) and problem = "No source variable"
|
|
||||||
or
|
|
||||||
readAccessWithoutSsaVariable(va) and problem = "No SSA variable"
|
|
||||||
or
|
|
||||||
readAccessWithAmbiguousSsaVariable(va) and problem = "Multiple SSA variables"
|
|
||||||
select va, problem
|
|
||||||
Reference in New Issue
Block a user