[−][src]Struct rustc_mir::transform::instrument_coverage::Instrumentor

struct Instrumentor<'a, 'tcx> {
    pass_name: &'a str,
    tcx: TyCtxt<'tcx>,
    mir_body: &'a mut Body<'tcx>,
    hir_body: &'tcx Body<'tcx>,
    dominators: Option<Dominators<BasicBlock>>,
    basic_coverage_blocks: Option<BasicCoverageBlocks>,
    function_source_hash: Option<u64>,
    next_counter_id: u32,
    num_expressions: u32,
}

Fields

pass_name: &'a strtcx: TyCtxt<'tcx>mir_body: &'a mut Body<'tcx>hir_body: &'tcx Body<'tcx>dominators: Option<Dominators<BasicBlock>>basic_coverage_blocks: Option<BasicCoverageBlocks>function_source_hash: Option<u64>next_counter_id: u32num_expressions: u32

Implementations

impl<'a, 'tcx> Instrumentor<'a, 'tcx>[src]

fn new(
    pass_name: &'a str,
    tcx: TyCtxt<'tcx>,
    mir_body: &'a mut Body<'tcx>
) -> Self
[src]

fn next_counter(&mut self) -> CounterValueReference[src]

Counter IDs start from one and go up.

fn next_expression(&mut self) -> InjectedExpressionIndex[src]

Expression IDs start from u32::MAX and go down because a CounterExpression can reference (add or subtract counts) of both Counter regions and CounterExpression regions. The counter expression operand IDs must be unique across both types.

fn dominators(&self) -> &Dominators<BasicBlock>[src]

fn basic_coverage_blocks(&self) -> &BasicCoverageBlocks[src]

fn function_source_hash(&mut self) -> u64[src]

fn inject_counters(&mut self)[src]

fn make_counter(&mut self) -> CoverageKind[src]

fn make_expression(
    &mut self,
    lhs: ExpressionOperandId,
    op: Op,
    rhs: ExpressionOperandId
) -> CoverageKind
[src]

fn inject_statement(
    &mut self,
    file_name: Symbol,
    source_file: &Lrc<SourceFile>,
    coverage_kind: CoverageKind,
    span: Span,
    block: BasicBlock
)
[src]

fn span_viewables(
    &self,
    coverage_spans: &Vec<CoverageSpan>
) -> Vec<SpanViewable>
[src]

Converts the computed BasicCoverageBlocks into SpanViewables.

fn bcb_from_coverage_span(
    &self,
    coverage_span: &CoverageSpan
) -> &BasicCoverageBlock
[src]

fn body_span(&self) -> Span[src]

fn extract_spans(&self, bcb: &'a BasicCoverageBlock) -> Vec<CoverageSpan>[src]

fn coverage_spans(&self) -> Vec<CoverageSpan>[src]

Generate a minimal set of CoverageSpans, each representing a contiguous code region to be counted.

The basic steps are:

  1. Extract an initial set of spans from the Statements and Terminators of each BasicCoverageBlock.

  2. Sort the spans by span.lo() (starting position). Spans that start at the same position are sorted with longer spans before shorter spans; and equal spans are sorted (deterministically) based on "dominator" relationship (if any).

  3. Traverse the spans in sorted order to identify spans that can be dropped (for instance, if another span or spans are already counting the same code region), or should be merged into a broader combined span (because it represents a contiguous, non-branching, and uninterrupted region of source code).

    Closures are exposed in their enclosing functions as Assign Rvalues, and since closures have their own MIR, their Span in their enclosing function should be left "uncovered".

Note the resulting vector of CoverageSpans does may not be fully sorted (and does not need to be).

Auto Trait Implementations

impl<'a, 'tcx> !RefUnwindSafe for Instrumentor<'a, 'tcx>

impl<'a, 'tcx> !Send for Instrumentor<'a, 'tcx>

impl<'a, 'tcx> !Sync for Instrumentor<'a, 'tcx>

impl<'a, 'tcx> Unpin for Instrumentor<'a, 'tcx> where
    'tcx: 'a, 

impl<'a, 'tcx> !UnwindSafe for Instrumentor<'a, 'tcx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized, 
[src]

impl<T> Borrow<T> for T where
    T: ?Sized, 
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]