Nicholas Nethercote
84ac80f192
Reformat use declarations.
...
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Zalathar
63c04f05e6
coverage: Extract hole spans from HIR instead of MIR
...
This makes it possible to treat more kinds of nested item/code as holes,
instead of being restricted to closures.
2024-07-08 21:22:56 +10:00
Zalathar
617de8cfb5
coverage: Move span unexpansion into its own submodule
2024-06-30 17:44:19 +10:00
Zalathar
2d3e6c8804
coverage: Split span refinement into two separate steps
2024-06-16 13:47:32 +10:00
Zalathar
118f66c237
coverage: Split out a function for dividing coverage spans into buckets
2024-06-16 13:47:32 +10:00
Zalathar
88ade9c740
coverage: Eagerly convert coverage spans to a simpler form
2024-06-16 12:21:41 +10:00
Zalathar
bf74fb1d2f
coverage: Move most span processing back into coverage::spans
2024-06-16 12:21:41 +10:00
Zalathar
e102d2dbd6
coverage: More consistent variable names for span processing
2024-06-16 12:21:41 +10:00
Zalathar
2fa78f3a2a
coverage: Replace the old span refiner with a single function
...
As more and more of the span refiner's functionality has been pulled out into
separate early passes, it has finally reached the point where we can remove the
rest of the old `SpansRefiner` code, and replace it with a single
modestly-sized function.
2024-06-12 22:59:24 +10:00
Zalathar
c57a1d1baa
coverage: Remove hole-carving code from the main span refiner
...
Now that hole spans are handled by a separate earlier pass, this code never
sees hole spans, and therefore doesn't need to deal with them.
2024-06-04 13:51:08 +10:00
Zalathar
6d1557f268
coverage: Use hole spans to carve up coverage spans into separate buckets
...
This performs the same task as the hole-carving code in the main span refiner,
but in a separate earlier pass.
2024-06-04 13:51:08 +10:00
Zalathar
9c931c01f7
coverage: Return a nested vector from initial span extraction
...
This will allow the span extractor to produce multiple separate buckets,
instead of just one flat list of spans.
2024-06-04 13:11:45 +10:00
Nicholas Nethercote
d49d4ae192
Remove extern crate rustc_middle from rustc_mir_transform.
2024-05-13 08:20:18 +10:00
Zalathar
76d8d01604
coverage: Flatten BcbMappingKind into mappings::CodeMapping
...
Now that branch and MC/DC mappings have been split out into separate types and
vectors, this enum is no longer needed, since it only represents ordinary
"code" regions.
(We can revisit this decision if we ever add support for other region kinds,
such as skipped regions or expansion regions. But at that point, we might just
add new structs/vectors for those kinds as well.)
2024-05-04 11:26:05 +10:00
Zalathar
ba87e5bb3e
coverage: Split off mappings.rs from spans.rs and from_mir.rs
2024-04-30 13:17:21 +10:00
Zalathar
7d1c6af3dc
coverage: Prepare to split spans.rs into two files
2024-04-30 13:16:58 +10:00
Dorian Péron
ae8c023983
mcdc-coverage: Add decision_depth field in structs
...
Add decision_depth field to TVBitmapUpdate/CondBitmapUpdate statements
Add decision_depth field to BcbMappingKinds MCDCBranch and MCDCDecision
Add decision_depth field to MCDCBranchSpan and MCDCDecisionSpan
2024-04-29 09:13:40 +00:00
Zalathar
2b6adb06fb
coverage: Separate branch pairs from other mapping kinds
...
This clears the way for larger changes to how branches are handled by the
coverage instrumentor, in order to support branch coverage for more language
constructs.
2024-04-22 21:55:34 +10:00
Zalathar
97bf553682
coverage: Detach MC/DC branch spans from regular branch spans
...
MC/DC's reliance on the existing branch coverage types is making it much harder
to improve branch coverage.
2024-04-22 21:55:33 +10:00
zhuyunxing
cf6b6cb2b4
coverage. Generate Mappings of decisions and conditions for MC/DC
2024-04-19 17:09:26 +08:00
Maybe Waffle
398da593a5
Merge WithNumNodes into DirectedGraph
2024-04-14 15:46:40 +00:00
Zalathar
31d0b50178
coverage: Include recorded branch info in coverage instrumentation
2024-03-14 17:19:02 +11:00
Zalathar
44c8f55a6b
coverage: Rename is_closure to is_hole
...
When refining covspans, we don't specifically care which ones represent
closures; we just want to know which ones represent "holes" that should be
carved out of other spans and then discarded.
(Closures are currently the only source of hole spans, but in the future we
might want to also create hole spans for nested items and inactive `#[cfg(..)]`
regions.)
2024-02-23 19:56:00 +11:00
Zalathar
8bd33e332b
coverage: Remove some lingering references to pending_dups
2024-02-23 19:51:23 +11:00
Zalathar
3a83b279be
coverage: Simplify (non-closure) covspans truncating each other
2024-02-21 21:25:36 +11:00
Zalathar
c40261da11
coverage: Remove pending_dups from the span refiner
2024-02-21 21:25:36 +11:00
Zalathar
e67db4c3b8
coverage: Simplify code for adding prev to pending dups
...
If we only check for duplicate spans when `prev` is unmodified, we reduce the
number of situations that `update_pending_dups` needs to handle.
This could potentially change the coverage spans we produce in some unknown
corner cases, but none of our current coverage tests indicate any change.
2024-02-13 21:48:03 +11:00
Zalathar
499609d8a4
coverage: Move prev_original_span into PrevCovspan
...
Now that `prev` has its own dedicated struct, we can store the original span in
that struct, instead of in a separate field in the refiner.
2024-02-13 21:48:03 +11:00
Zalathar
a6183216d8
coverage: Split CoverageSpan into several distinct structs
...
This requires some extra boilerplate, but in exchange it becomes much easier to
see how each field and method is actually used.
2024-02-13 21:48:03 +11:00
Zalathar
5a569b1b80
coverage: Don't track curr_original_span explicitly
...
Now that we never mutate `curr.span`, we don't need to store its original span
separately.
2024-02-13 21:01:17 +11:00
Zalathar
412c86cf03
coverage: When merging spans, keep prev and merge curr into it
...
Swapping the direction of this merge produces the same results, but means that
we never need to mutate `curr`.
2024-02-13 21:01:17 +11:00
Zalathar
a246b6be1d
coverage: Make fn_sig_span optional, and note its quirks
2024-02-05 10:09:50 +11:00
Zalathar
fde1702db8
coverage: Hoist special handling of async function spans
...
This sidesteps the normal span refinement code in cases where we know that we
are only dealing with the special signature span that represents having called
an async function.
2024-02-05 10:09:50 +11:00
Zalathar
572d7e9e69
coverage: Flatten the functions for extracting/refining coverage spans
...
Consolidating this code into flatter functions reduces the amount of
pointer-chasing required to read and modify it.
2024-01-24 16:59:52 +11:00
Zalathar
124fff0777
coverage: Add enums to accommodate other kinds of coverage mappings
2024-01-11 16:43:12 +11:00
Zalathar
c5932182ad
coverage: Store extracted spans as a flat list of mappings
...
This is less elegant in some ways, since we no longer visit a BCB's spans as a
batch, but will make it much easier to add support for other kinds of coverage
mapping regions (e.g. branch regions or gap regions).
2024-01-11 16:43:01 +11:00
Zalathar
514e026853
coverage: Make the remaining fields of CoverageSpan non-public
...
The struct itself is already non-public, so having public fields doesn't
achieve anything.
2024-01-05 12:53:23 +11:00
Zalathar
cd5084388a
coverage: Split out SpanFromMir from CoverageSpan
...
This draws a clear distinction between the fields/methods that are needed by
initial span extraction and preprocessing, and those that are needed by the
main "refinement" loop.
2024-01-05 12:53:23 +11:00
Zalathar
d4d2f1428c
coverage: Hoist the splitting of visible macro invocations
2024-01-05 12:53:23 +11:00
Zalathar
cd3a9760e4
coverage: Hoist the removal of unwanted macro expansion spans
2024-01-05 12:53:23 +11:00
Zalathar
df0df5256b
coverage: Overhaul how "visible macros" are determined
2024-01-05 12:53:23 +11:00
Zalathar
e1a2babc06
coverage: Prepare mappings separately from injecting statements
...
These two tasks historically needed to be interleaved, but after various recent
changes (including #116046 and #116917 ) they can now be fully separated.
2023-12-30 22:34:15 +11:00
Zalathar
2a0290a802
coverage: Pass around &ExtractedHirInfo instead of individual fields
...
This reduces the risk of mixing up `fn_source_span` and `body_span`, and makes
it easier to pass along additional fields as needed.
2023-12-20 18:48:04 +11:00
Zalathar
dfa6441354
coverage: Skip instrumenting a function if no spans were extracted
2023-12-16 11:10:10 +11:00
Zalathar
cec814202a
coverage: Add #[track_caller] to the span generator's unwrap methods
...
This should make it easier to investigate unwrap failures in bug reports.
2023-12-08 22:49:12 +11:00
Zalathar
e0cd8057c8
coverage: Simplify the heuristic for ignoring async fn return spans
2023-12-08 22:49:11 +11:00
Zalathar
9a4321518c
coverage: Simplify code that pushes to refined_spans
2023-12-07 17:41:04 +11:00
Zalathar
9089d28780
coverage: Inline push_refined_span
2023-12-07 17:41:01 +11:00
Zalathar
ec0110be09
coverage: Merge refined spans in a separate final pass
...
This makes `push_refined_span` trivial, which will let us inline it and benefit
from partial borrows of `refined_spans`.
2023-12-07 17:31:49 +11:00
Zalathar
242bff3cda
coverage: Be more strict about what counts as a "visible macro"
2023-12-05 21:21:05 +11:00