coverage: Store coverage source regions as Span until codegen

This commit is contained in:
Zalathar
2024-11-24 18:50:08 +11:00
parent 87fe7def12
commit b9fb1a69d2
13 changed files with 199 additions and 226 deletions

View File

@@ -3,9 +3,9 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_index::bit_set::BitSet;
use rustc_middle::mir::coverage::{
CounterId, CovTerm, Expression, ExpressionId, FunctionCoverageInfo, Mapping, MappingKind, Op,
SourceRegion,
};
use rustc_middle::ty::Instance;
use rustc_span::Span;
use tracing::{debug, instrument};
use crate::coverageinfo::ffi::{Counter, CounterExpression, ExprKind};
@@ -220,16 +220,16 @@ impl<'tcx> FunctionCoverage<'tcx> {
})
}
/// Converts this function's coverage mappings into an intermediate form
/// that will be used by `mapgen` when preparing for FFI.
pub(crate) fn counter_regions(
/// Yields all this function's coverage mappings, after simplifying away
/// unused counters and counter expressions.
pub(crate) fn mapping_spans(
&self,
) -> impl Iterator<Item = (MappingKind, &SourceRegion)> + ExactSizeIterator {
) -> impl Iterator<Item = (MappingKind, Span)> + ExactSizeIterator + Captures<'_> {
self.function_coverage_info.mappings.iter().map(move |mapping| {
let Mapping { kind, source_region } = mapping;
let &Mapping { ref kind, span } = mapping;
let kind =
kind.map_terms(|term| if self.is_zero_term(term) { CovTerm::Zero } else { term });
(kind, source_region)
(kind, span)
})
}