Apply suggestions from code review

Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
This commit is contained in:
Tom Hvitved
2025-02-10 13:09:31 +01:00
parent e955f58eb1
commit 6fbb1e2571
2 changed files with 9 additions and 2 deletions

View File

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

View File

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