Java: Remove old SSA consistency queries.

This commit is contained in:
Anders Schack-Mulligen
2025-10-27 12:55:43 +01:00
parent 47b26ddea4
commit 02a942554d
4 changed files with 0 additions and 122 deletions

View File

@@ -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

View File

@@ -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."

View File

@@ -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

View File

@@ -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