Skip to content

Commit 44374b5

Browse files
committed
Java: Drop caching of deprecated predicates.
1 parent 5a0fc12 commit 44374b5

File tree

1 file changed

+51
-58
lines changed
  • java/ql/lib/semmle/code/java/dataflow/internal

1 file changed

+51
-58
lines changed

java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,53 @@ final class UncertainWriteDefinition = Impl::UncertainWriteDefinition;
244244

245245
final class PhiNode = Impl::PhiNode;
246246

247+
predicate ssaExplicitUpdate(SsaUpdate def, VariableUpdate upd) {
248+
exists(SsaSourceVariable v, BasicBlock bb, int i |
249+
def.definesAt(v, bb, i) and
250+
certainVariableUpdate(v, upd.getControlFlowNode(), bb, i) and
251+
getDestVar(upd) = def.getSourceVariable()
252+
)
253+
}
254+
255+
deprecated predicate ssaUncertainImplicitUpdate(SsaImplicitUpdate def) {
256+
exists(SsaSourceVariable v, BasicBlock bb, int i |
257+
def.definesAt(v, bb, i) and
258+
uncertainVariableUpdate(v, _, bb, i)
259+
)
260+
}
261+
262+
predicate ssaImplicitInit(WriteDefinition def) {
263+
exists(SsaSourceVariable v, BasicBlock bb, int i |
264+
def.definesAt(v, bb, i) and
265+
hasEntryDef(v, bb) and
266+
i = -1
267+
)
268+
}
269+
270+
/**
271+
* Holds if the SSA definition of `v` at `def` reaches `redef` without crossing another
272+
* SSA definition of `v`.
273+
*/
274+
deprecated predicate ssaDefReachesUncertainDef(TrackedSsaDef def, SsaUncertainImplicitUpdate redef) {
275+
Impl::uncertainWriteDefinitionInput(redef, def)
276+
}
277+
278+
VarRead getAUse(Definition def) {
279+
exists(SsaSourceVariable v, BasicBlock bb, int i |
280+
Impl::ssaDefReachesRead(v, def, bb, i) and
281+
result.getControlFlowNode() = bb.getNode(i) and
282+
result = v.getAnAccess()
283+
)
284+
}
285+
286+
predicate ssaDefReachesEndOfBlock(BasicBlock bb, Definition def) {
287+
Impl::ssaDefReachesEndOfBlock(bb, def, _)
288+
}
289+
290+
deprecated predicate phiHasInputFromBlock(PhiNode phi, Definition inp, BasicBlock bb) {
291+
Impl::phiHasInputFromBlock(phi, inp, bb)
292+
}
293+
247294
cached
248295
private module Cached {
249296
/** Gets the destination variable of an update of a tracked variable. */
@@ -258,15 +305,6 @@ private module Cached {
258305
result.getAnAccess() = upd.(UnaryAssignExpr).getExpr()
259306
}
260307

261-
cached
262-
predicate ssaExplicitUpdate(SsaUpdate def, VariableUpdate upd) {
263-
exists(SsaSourceVariable v, BasicBlock bb, int i |
264-
def.definesAt(v, bb, i) and
265-
certainVariableUpdate(v, upd.getControlFlowNode(), bb, i) and
266-
getDestVar(upd) = def.getSourceVariable()
267-
)
268-
}
269-
270308
/*
271309
* The SSA construction for a field `f` relies on implicit update nodes at
272310
* every call site that conceivably could reach an update of the field.
@@ -486,26 +524,9 @@ private module Cached {
486524

487525
overlay[global]
488526
cached
489-
predicate defUpdatesNamedField(SsaImplicitWrite def, TrackedField f, Callable setter) {
490-
f = def.getSourceVariable() and
491-
updatesNamedField0(def.getControlFlowNode().asCall(), f, setter)
492-
}
493-
494-
cached
495-
deprecated predicate ssaUncertainImplicitUpdate(SsaImplicitUpdate def) {
496-
exists(SsaSourceVariable v, BasicBlock bb, int i |
497-
def.definesAt(v, bb, i) and
498-
uncertainVariableUpdate(v, _, bb, i)
499-
)
500-
}
501-
502-
cached
503-
predicate ssaImplicitInit(WriteDefinition def) {
504-
exists(SsaSourceVariable v, BasicBlock bb, int i |
505-
def.definesAt(v, bb, i) and
506-
hasEntryDef(v, bb) and
507-
i = -1
508-
)
527+
predicate defUpdatesNamedField(SsaImplicitWrite calldef, TrackedField f, Callable setter) {
528+
f = calldef.getSourceVariable() and
529+
updatesNamedField0(calldef.getControlFlowNode().asCall(), f, setter)
509530
}
510531

511532
/** Holds if `init` is a closure variable that captures the value of `capturedvar`. */
@@ -517,15 +538,6 @@ private module Cached {
517538
)
518539
}
519540

520-
/**
521-
* Holds if the SSA definition of `v` at `def` reaches `redef` without crossing another
522-
* SSA definition of `v`.
523-
*/
524-
cached
525-
deprecated predicate ssaDefReachesUncertainDef(TrackedSsaDef def, SsaUncertainImplicitUpdate redef) {
526-
Impl::uncertainWriteDefinitionInput(redef, def)
527-
}
528-
529541
/**
530542
* Holds if the value defined at `def` can reach `use` without passing through
531543
* any other uses, but possibly through phi nodes and uncertain implicit updates.
@@ -538,25 +550,6 @@ private module Cached {
538550
)
539551
}
540552

541-
cached
542-
VarRead getAUse(Definition def) {
543-
exists(SsaSourceVariable v, BasicBlock bb, int i |
544-
Impl::ssaDefReachesRead(v, def, bb, i) and
545-
result.getControlFlowNode() = bb.getNode(i) and
546-
result = v.getAnAccess()
547-
)
548-
}
549-
550-
cached
551-
predicate ssaDefReachesEndOfBlock(BasicBlock bb, Definition def) {
552-
Impl::ssaDefReachesEndOfBlock(bb, def, _)
553-
}
554-
555-
cached
556-
predicate phiHasInputFromBlock(PhiNode phi, Definition inp, BasicBlock bb) {
557-
Impl::phiHasInputFromBlock(phi, inp, bb)
558-
}
559-
560553
cached
561554
module DataFlowIntegration {
562555
import DataFlowIntegrationImpl
@@ -666,7 +659,7 @@ private module DataFlowIntegrationInput implements Impl::DataFlowIntegrationInpu
666659
}
667660
}
668661

669-
Expr getARead(Definition def) { result = getAUse(def) }
662+
Expr getARead(Definition def) { result = def.(SsaDefinition).getARead() }
670663

671664
predicate ssaDefHasSource(WriteDefinition def) { def instanceof SsaExplicitWrite }
672665

0 commit comments

Comments
 (0)