Commit 255c15b
Make control flow analysis of infinite FOR consistent with infinite while loops
An upcoming change in MaybeReachingVariableUse unit tests exposed an issue with FOR loops where `for(i=0; ; i++) {x=1;} foo(x)` would still create an edge (Branch.ON_FALSE) in the CFG from the FOR node to the `foo(x)` node after the block ends.
This behavior is incorrect because, with the Branch.ON_FALSE down edge from FOR to `foo(x)` the MaybeReachingVariableUse pass will consider the foo(x) use reachable to the def `x=1`, when in reality it is not reachable.
Inconsistency:
`for(;;) { x=1;} foo(x);` // considered not reachable use
`for(;true;) { x=1;} foo(x);` // considered reachable use
This CL fixes the above inconsistency.
PiperOrigin-RevId: 3224917361 parent 8e0c656 commit 255c15b
File tree
2 files changed
+55
-6
lines changed- src/com/google/javascript/jscomp
- test/com/google/javascript/jscomp
2 files changed
+55
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
453 | | - | |
| 453 | + | |
454 | 454 | | |
455 | 455 | | |
456 | 456 | | |
| |||
Lines changed: 54 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
| 158 | + | |
| 159 | + | |
160 | 160 | | |
161 | | - | |
162 | | - | |
| 161 | + | |
163 | 162 | | |
164 | 163 | | |
165 | 164 | | |
| |||
310 | 309 | | |
311 | 310 | | |
312 | 311 | | |
313 | | - | |
314 | 312 | | |
315 | 313 | | |
316 | 314 | | |
317 | 315 | | |
318 | 316 | | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
319 | 368 | | |
320 | 369 | | |
321 | 370 | | |
| |||
0 commit comments