Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c4f0868
Java: Move SSA entry defs to index -1.
aschackmull Oct 21, 2025
f2181ec
Java: Get rid of untracked SSA definitions.
aschackmull Oct 21, 2025
374c772
Java: Remove getAFirstUse in BaseSSA.
aschackmull Oct 21, 2025
79b2f21
SSA: Fix phi defs.
aschackmull Oct 27, 2025
289d337
SSA: Improve toString.
aschackmull Oct 27, 2025
551944b
Java: Add VariableWrite class.
aschackmull Oct 24, 2025
942dc2b
Java: Replace BaseSSA class wrappers with shared code.
aschackmull Oct 23, 2025
d5708fd
Java: Instantiate shared SSA wrappers for main SSA.
aschackmull Nov 5, 2025
154f077
Java: Simplify instantiation of Guards and ControlFlowReachability.
aschackmull Nov 6, 2025
99aa033
Java: Replace usages of isParameterDefinition.
aschackmull Nov 6, 2025
07e6356
Java: Replace getAFirstUse with top-level predicate.
aschackmull Nov 7, 2025
483b2d8
Java: Replace uses of SsaExplicitUpdate.
aschackmull Nov 7, 2025
06df5c0
Java: Introduce SsaCapturedDefinition and replace uses of getAnUltima…
aschackmull Nov 7, 2025
3e43c53
Java: Update some qldoc deprecation notices.
aschackmull Nov 7, 2025
35caede
Java: Replace SsaPhiNode with SsaPhiDefinition.
aschackmull Nov 7, 2025
f4b9efc
Java: Replace getAUse with getARead.
aschackmull Nov 7, 2025
8594ae0
Java: Replace remaining SsaImplicitInit.
aschackmull Nov 7, 2025
f0bd034
Java: Replace usages of SsaVariable.
aschackmull Nov 7, 2025
ee5d65e
Java: Update toString for implicit writes.
aschackmull Nov 7, 2025
5849d85
Java: Deprecate two more SSA classes.
aschackmull Nov 7, 2025
95ac61d
Java: Drop caching of deprecated predicates.
aschackmull Oct 27, 2025
e059ded
Java: Accept toString changes in qltest.
aschackmull Nov 6, 2025
109a5eb
Java: Accept qltest changes due to dropped UntrackedDef.
aschackmull Nov 6, 2025
437ca58
Java: Add change note.
aschackmull Nov 7, 2025
4a58a01
Java: Reinstate useless null check results for fields that are no lon…
aschackmull Nov 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions java/ql/lib/semmle/code/java/dataflow/SSA.qll
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,10 @@ class SsaVariable extends Definition {
/** Gets the `ControlFlowNode` at which this SSA variable is defined. */
pragma[nomagic]
ControlFlowNode getCfgNode() {
exists(BasicBlock bb, int i, int j |
exists(BasicBlock bb, int i |
this.definesAt(_, bb, i) and
// untracked definitions are inserted just before reads
(if this instanceof UntrackedDef then j = i + 1 else j = i) and
// phi nodes are inserted at position `-1`
result = bb.getNode(0.maximum(j))
result = bb.getNode(0.maximum(i))
)
}

Expand Down Expand Up @@ -246,8 +244,6 @@ class SsaImplicitUpdate extends SsaUpdate {
}

private string getKind() {
this instanceof UntrackedDef and result = "untracked"
or
this.hasExplicitQualifierUpdate() and
result = "explicit qualifier"
or
Expand Down Expand Up @@ -280,8 +276,6 @@ class SsaImplicitUpdate extends SsaUpdate {
* of its qualifiers is volatile.
*/
predicate assignsUnknownValue() {
this instanceof UntrackedDef
or
this.hasExplicitQualifierUpdate()
or
this.hasImplicitQualifierUpdate()
Expand Down
34 changes: 4 additions & 30 deletions java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,6 @@ private module TrackedVariablesImpl {

private import TrackedVariablesImpl

private predicate untrackedFieldWrite(BasicBlock bb, int i, SsaSourceVariable v) {
v =
any(SsaSourceField nf |
bb.getNode(i + 1) = nf.getAnAccess().(FieldRead).getControlFlowNode() and not trackField(nf)
)
}

/** Gets the definition point of a nested class in the parent scope. */
private ControlFlowNode parentDef(NestedClass nc) {
nc.(AnonymousClass).getClassInstanceExpr().getControlFlowNode() = result or
Expand Down Expand Up @@ -184,9 +177,6 @@ private module SsaInput implements SsaImplCommon::InputSig<Location, BasicBlock>
certainVariableUpdate(v, _, bb, i) and
certain = true
or
untrackedFieldWrite(bb, i, v) and
certain = true
or
hasEntryDef(v, bb) and
i = -1 and
certain = true
Expand All @@ -204,7 +194,10 @@ private module SsaInput implements SsaImplCommon::InputSig<Location, BasicBlock>
hasDominanceInformation(bb) and
(
exists(VarRead use |
v.getAnAccess() = use and bb.getNode(i) = use.getControlFlowNode() and certain = true
v instanceof TrackedVar and
v.getAnAccess() = use and
bb.getNode(i) = use.getControlFlowNode() and
certain = true
)
or
variableCapture(v, _, bb, i) and
Expand All @@ -223,16 +216,6 @@ final class UncertainWriteDefinition = Impl::UncertainWriteDefinition;

final class PhiNode = Impl::PhiNode;

class UntrackedDef extends Definition {
private VarRead read;

UntrackedDef() { ssaUntrackedDef(this, read) }

string toString() { result = read.toString() }

Location getLocation() { result = read.getLocation() }
}

cached
private module Cached {
/** Gets the destination variable of an update of a tracked variable. */
Expand All @@ -256,15 +239,6 @@ private module Cached {
)
}

cached
predicate ssaUntrackedDef(Definition def, VarRead read) {
exists(SsaSourceVariable v, BasicBlock bb, int i |
def.definesAt(v, bb, i) and
untrackedFieldWrite(bb, i, v) and
read.getControlFlowNode() = bb.getNode(i + 1)
)
}

/*
* The SSA construction for a field `f` relies on implicit update nodes at
* every call site that conceivably could reach an update of the field.
Expand Down