Commit 88140bc
authored
Scoverage: fix broken warnings related to tail recursion and infinite loop detection (#25941)
Fixes a bunch of warnings broken by scoverage related to tail recursion
and infinite loops detection. Warnings were broken by:
- Coverage modifying the trees to inject instrumentation, breaking
assumptions by the loop detection and tail recursion phases.
- Coverage modifying the spans of the trees when instrumenting them,
which breaks the positions at which warnings are reported.
The solution by phases affected:
**`InstrumentCoverage`** - phase that instruments the trees to inject
coverage probes:
- Do not instrument literal booleans in `if` conditions - they are
getting in the way of rewriting `if` statements with literal conditions
into their respective `then` or `else` branches.
- Preserve the spans of the trees when instrumenting them, so that
warnings are reported at the original position of the code.
**`CheckLoopingImplicits`** - phase that detects infinite loops in
initializers:
- Ignore coverage probes as ones not capable of leading to an infinite
loop.
- Strip the coverage instrumentation from RHS of defs before analyzing
them for loops.
**`TailRec`** - phase that rewrites tail recursive calls into loops:
- Modified `isInfiniteRecCall` - the method that detects infinite loops
in tail recursive calls - to allow coverage probes as ones not capable
of breaking an infinite loop.
- In `transform`, modify the default getter index in recursive call
argument position to peel through the coverage instrumentation to
recover the original default-getter parameter index.
## How much have you relied on LLM-based tools in this contribution?
Moderately, for codebase analysis and tracing.
## How was the solution tested?
`sbt "testCompilation --enable-coverage-phase"`1 parent 7e96767 commit 88140bc
6 files changed
Lines changed: 94 additions & 115 deletions
File tree
- compiler
- src/dotty/tools/dotc/transform
- test/dotc
- tests/coverage/pos
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
105 | 107 | | |
106 | 108 | | |
107 | 109 | | |
108 | | - | |
| 110 | + | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
Lines changed: 37 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
341 | 341 | | |
342 | 342 | | |
343 | 343 | | |
344 | | - | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
345 | 349 | | |
346 | 350 | | |
347 | 351 | | |
| |||
366 | 370 | | |
367 | 371 | | |
368 | 372 | | |
369 | | - | |
| 373 | + | |
370 | 374 | | |
371 | 375 | | |
372 | 376 | | |
| |||
400 | 404 | | |
401 | 405 | | |
402 | 406 | | |
403 | | - | |
| 407 | + | |
404 | 408 | | |
405 | 409 | | |
406 | 410 | | |
| |||
750 | 754 | | |
751 | 755 | | |
752 | 756 | | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
753 | 784 | | |
754 | 785 | | |
755 | 786 | | |
| |||
762 | 793 | | |
763 | 794 | | |
764 | 795 | | |
765 | | - | |
766 | | - | |
| 796 | + | |
| 797 | + | |
767 | 798 | | |
768 | 799 | | |
769 | 800 | | |
770 | 801 | | |
771 | 802 | | |
772 | 803 | | |
773 | 804 | | |
774 | | - | |
| 805 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
198 | 199 | | |
199 | 200 | | |
200 | 201 | | |
| |||
325 | 326 | | |
326 | 327 | | |
327 | 328 | | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
328 | 350 | | |
329 | 351 | | |
330 | | - | |
331 | | - | |
332 | | - | |
| 352 | + | |
| 353 | + | |
333 | 354 | | |
334 | 355 | | |
335 | 356 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | 18 | | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | | - | |
28 | 25 | | |
29 | 26 | | |
30 | 27 | | |
31 | 28 | | |
32 | 29 | | |
33 | 30 | | |
34 | | - | |
35 | 31 | | |
36 | | - | |
37 | | - | |
38 | 32 | | |
39 | 33 | | |
40 | 34 | | |
41 | 35 | | |
42 | 36 | | |
43 | | - | |
44 | 37 | | |
45 | 38 | | |
46 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
229 | 229 | | |
230 | 230 | | |
231 | 231 | | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | 232 | | |
250 | 233 | | |
251 | 234 | | |
| |||
256 | 239 | | |
257 | 240 | | |
258 | 241 | | |
259 | | - | |
| 242 | + | |
260 | 243 | | |
261 | 244 | | |
262 | 245 | | |
| |||
273 | 256 | | |
274 | 257 | | |
275 | 258 | | |
276 | | - | |
| 259 | + | |
277 | 260 | | |
278 | 261 | | |
279 | 262 | | |
| |||
290 | 273 | | |
291 | 274 | | |
292 | 275 | | |
293 | | - | |
| 276 | + | |
294 | 277 | | |
295 | 278 | | |
296 | 279 | | |
| |||
307 | 290 | | |
308 | 291 | | |
309 | 292 | | |
310 | | - | |
| 293 | + | |
311 | 294 | | |
312 | 295 | | |
313 | 296 | | |
| |||
324 | 307 | | |
325 | 308 | | |
326 | 309 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
| 310 | + | |
345 | 311 | | |
346 | 312 | | |
347 | 313 | | |
| |||
358 | 324 | | |
359 | 325 | | |
360 | 326 | | |
361 | | - | |
| 327 | + | |
362 | 328 | | |
363 | 329 | | |
364 | 330 | | |
| |||
375 | 341 | | |
376 | 342 | | |
377 | 343 | | |
378 | | - | |
| 344 | + | |
379 | 345 | | |
380 | 346 | | |
381 | 347 | | |
| |||
392 | 358 | | |
393 | 359 | | |
394 | 360 | | |
395 | | - | |
| 361 | + | |
396 | 362 | | |
397 | 363 | | |
398 | 364 | | |
| |||
409 | 375 | | |
410 | 376 | | |
411 | 377 | | |
412 | | - | |
| 378 | + | |
413 | 379 | | |
414 | 380 | | |
415 | 381 | | |
| |||
426 | 392 | | |
427 | 393 | | |
428 | 394 | | |
429 | | - | |
| 395 | + | |
430 | 396 | | |
431 | 397 | | |
432 | 398 | | |
| |||
443 | 409 | | |
444 | 410 | | |
445 | 411 | | |
446 | | - | |
| 412 | + | |
447 | 413 | | |
448 | 414 | | |
449 | 415 | | |
| |||
460 | 426 | | |
461 | 427 | | |
462 | 428 | | |
463 | | - | |
| 429 | + | |
464 | 430 | | |
465 | 431 | | |
466 | 432 | | |
| |||
477 | 443 | | |
478 | 444 | | |
479 | 445 | | |
480 | | - | |
| 446 | + | |
481 | 447 | | |
482 | 448 | | |
483 | 449 | | |
| |||
494 | 460 | | |
495 | 461 | | |
496 | 462 | | |
497 | | - | |
| 463 | + | |
498 | 464 | | |
499 | 465 | | |
500 | 466 | | |
| |||
511 | 477 | | |
512 | 478 | | |
513 | 479 | | |
514 | | - | |
| 480 | + | |
515 | 481 | | |
516 | 482 | | |
517 | 483 | | |
| |||
0 commit comments