coverage: Attach an optional FunctionCoverageInfo
to mir::Body
This allows coverage information to be attached to the function as a whole when appropriate, instead of being smuggled through coverage statements in the function's basic blocks. As an example, this patch moves the `function_source_hash` value out of individual `CoverageKind::Counter` statements and into the per-function info. When synthesizing unused functions for coverage purposes, the absence of this info is taken to indicate that a function was not eligible for coverage and should not be synthesized.
This commit is contained in:
parent
6d7160ce97
commit
c479bc7f3b
7 changed files with 74 additions and 54 deletions
|
@ -211,6 +211,10 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
|
|||
self.make_mir_coverage_kind(intermediate_expression),
|
||||
);
|
||||
}
|
||||
|
||||
self.mir_body.function_coverage_info = Some(Box::new(FunctionCoverageInfo {
|
||||
function_source_hash: self.function_source_hash,
|
||||
}));
|
||||
}
|
||||
|
||||
/// Injects a single [`StatementKind::Coverage`] for each BCB that has one
|
||||
|
@ -323,9 +327,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
|
|||
|
||||
fn make_mir_coverage_kind(&self, counter_kind: &BcbCounter) -> CoverageKind {
|
||||
match *counter_kind {
|
||||
BcbCounter::Counter { id } => {
|
||||
CoverageKind::Counter { function_source_hash: self.function_source_hash, id }
|
||||
}
|
||||
BcbCounter::Counter { id } => CoverageKind::Counter { id },
|
||||
BcbCounter::Expression { id, lhs, op, rhs } => {
|
||||
CoverageKind::Expression { id, lhs, op, rhs }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue