@@ -97,10 +97,10 @@ predicate isDeadAssignment(string name, DataFlow::PropWrite assign1, DataFlow::P
9797}
9898
9999/**
100- * Holds if `assign` assigns a property `name` that may be accessed somewhere else in the same block,
100+ * Holds if `assign` assigns a property that may be accessed somewhere else in the same block,
101101 * `after` indicates if the access happens before or after the node for `assign`.
102102 */
103- predicate maybeAccessesAssignedPropInBlock ( DataFlow:: PropWrite assign , boolean after ) {
103+ predicate maybeAssignsAccessedPropInBlock ( DataFlow:: PropWrite assign , boolean after ) {
104104 (
105105 // early pruning - manual magic
106106 after = true and postDominatedPropWrite ( _, assign , _, false )
@@ -176,11 +176,13 @@ ControlFlowNode getANodeBeforeWrite(DataFlow::PropWrite write, ReachableBasicBlo
176176}
177177
178178/**
179- * Gets a successor inside `bb` in the control-flow graph that does not pass through an impure expression (except for writes to `name`).
180- * Stops after the first write to `name` that happens after `node`.
179+ * Gets a successor inside `bb` in the control-flow graph that does not pass through an impure expression (except for writes to the same property).
180+ * Stops after the first write to same property that happens after `node`.
181+ *
182+ * `node` always corresponds to the CFG node of a `DataFlow::PropWrite` with a known name.
181183 */
182184ControlFlowNode getAPureSuccessor ( ControlFlowNode node ) {
183- // stop at impure expressions (except writes to `name`)
185+ // stop at reads of `name` and at impure expressions (except writes to `name`)
184186 not (
185187 maybeAccessesProperty ( result , getPropertyWriteName ( node ) ) and
186188 not result =
@@ -197,10 +199,10 @@ ControlFlowNode getAPureSuccessor(ControlFlowNode node) {
197199 )
198200 or
199201 // recursive case
200- exists ( ControlFlowNode pred | pred = getAPureSuccessor ( node ) | result = pred .getASuccessor ( ) ) and
202+ result = getAPureSuccessor ( node ) .getASuccessor ( ) and
201203 // stop at basic-block boundaries
202204 not result instanceof BasicBlock and
203- // make sure we stop after the first write to `name` that comes after `node`.
205+ // make sure we stop after the first write to the same property that comes after `node`.
204206 (
205207 not result .getAPredecessor ( ) =
206208 any ( DataFlow:: PropWrite write | write .getPropertyName ( ) = getPropertyWriteName ( node ) )
@@ -250,9 +252,9 @@ predicate noPropAccessBetweenGlobal(
250252 |
251253 postDominatedPropWrite ( name , assign1 , assign2 , false ) and // early pruning
252254 write1 = assign1 .getWriteNode ( ) and
253- not maybeAccessesAssignedPropInBlock ( assign1 , true ) and
255+ not maybeAssignsAccessedPropInBlock ( assign1 , true ) and
254256 write2 = assign2 .getWriteNode ( ) and
255- not maybeAccessesAssignedPropInBlock ( assign2 , false ) and
257+ not maybeAssignsAccessedPropInBlock ( assign2 , false ) and
256258 write1 .getBasicBlock ( ) = block1 and
257259 write2 .getBasicBlock ( ) = block2 and
258260 not block1 = block2 and
0 commit comments