Don't omit self from uninitialized writes

We can safely create uninitialized writes for `self` variables, because
they appear at index -1 in the entry block of a method, and are
immediately overwritten by a write to `self` at index 0. As a result,
they are not live and will be pruned from the CFG.
This commit is contained in:
Harry Maclean
2021-10-14 13:48:42 +01:00
parent 446eb13471
commit 647485acde

View File

@@ -7,8 +7,7 @@ private import CfgNodes::ExprNodes
/** Holds if `v` is uninitialized at index `i` in entry block `bb`. */
predicate uninitializedWrite(EntryBasicBlock bb, int i, LocalVariable v) {
v.getDeclaringScope() = bb.getScope() and
i = -1 and
not v instanceof SelfVariable
i = -1
}
/** Holds if `bb` contains a caputured read of variable `v`. */