Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Anders Schack-Mulligen <[email protected]>
  • Loading branch information
hvitved and aschackmull authored Feb 10, 2025
1 parent f8c0c6f commit b093ae9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion java/ql/lib/semmle/code/java/dataflow/SSA.qll
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,14 @@ class SsaVariable extends Definition {
SsaSourceVariable getSourceVariable() { result = super.getSourceVariable() }

/** Gets the `ControlFlowNode` at which this SSA variable is defined. */
pragma[nomagic]
ControlFlowNode getCfgNode() {
exists(BasicBlock bb, int i, int j |
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(max([j, 0]))
result = bb.getNode(0.maximum(j))
)
}

Expand Down
8 changes: 7 additions & 1 deletion java/ql/lib/semmle/code/java/dataflow/internal/SsaImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,16 @@ private module Cached {
)
}

bindingset[call, f]
pragma[inline_late]
private predicate updatesNamedField0(Call call, TrackedField f, Callable setter) {
updatesNamedField(call, f, setter)
}

cached
predicate defUpdatesNamedField(SsaImplicitUpdate def, TrackedField f, Callable setter) {
f = def.getSourceVariable() and
updatesNamedField(def.getCfgNode().asCall(), f, setter)
updatesNamedField0(def.getCfgNode().asCall(), f, setter)
}

cached
Expand Down

0 comments on commit b093ae9

Please sign in to comment.