coverage: Pass a LocalFileId
to CoverageSpan::from_source_region
This commit is contained in:
parent
3c30fe3423
commit
925dfc8608
@ -1,5 +1,7 @@
|
|||||||
use rustc_middle::mir::coverage::{CounterId, CovTerm, ExpressionId, SourceRegion};
|
use rustc_middle::mir::coverage::{CounterId, CovTerm, ExpressionId, SourceRegion};
|
||||||
|
|
||||||
|
use crate::coverageinfo::mapgen::LocalFileId;
|
||||||
|
|
||||||
/// Must match the layout of `LLVMRustCounterKind`.
|
/// Must match the layout of `LLVMRustCounterKind`.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
@ -137,7 +139,11 @@ pub(crate) struct CoverageSpan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CoverageSpan {
|
impl CoverageSpan {
|
||||||
pub(crate) fn from_source_region(file_id: u32, code_region: &SourceRegion) -> Self {
|
pub(crate) fn from_source_region(
|
||||||
|
local_file_id: LocalFileId,
|
||||||
|
code_region: &SourceRegion,
|
||||||
|
) -> Self {
|
||||||
|
let file_id = local_file_id.as_u32();
|
||||||
let &SourceRegion { start_line, start_col, end_line, end_col } = code_region;
|
let &SourceRegion { start_line, start_col, end_line, end_col } = code_region;
|
||||||
// Internally, LLVM uses the high bit of `end_col` to distinguish between
|
// Internally, LLVM uses the high bit of `end_col` to distinguish between
|
||||||
// code regions and gap regions, so it can't be used by the column number.
|
// code regions and gap regions, so it can't be used by the column number.
|
||||||
|
@ -210,7 +210,7 @@ struct GlobalFileId {}
|
|||||||
/// An index into a function's list of global file IDs. That underlying list
|
/// An index into a function's list of global file IDs. That underlying list
|
||||||
/// of local-to-global mappings will be embedded in the function's record in
|
/// of local-to-global mappings will be embedded in the function's record in
|
||||||
/// the `__llvm_covfun` linker section.
|
/// the `__llvm_covfun` linker section.
|
||||||
struct LocalFileId {}
|
pub(crate) struct LocalFileId {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Holds a mapping from "local" (per-function) file IDs to "global" (per-CGU)
|
/// Holds a mapping from "local" (per-function) file IDs to "global" (per-CGU)
|
||||||
@ -280,7 +280,7 @@ fn encode_mappings_for_function(
|
|||||||
// form suitable for FFI.
|
// form suitable for FFI.
|
||||||
for (mapping_kind, region) in counter_regions {
|
for (mapping_kind, region) in counter_regions {
|
||||||
debug!("Adding counter {mapping_kind:?} to map for {region:?}");
|
debug!("Adding counter {mapping_kind:?} to map for {region:?}");
|
||||||
let span = ffi::CoverageSpan::from_source_region(local_file_id.as_u32(), region);
|
let span = ffi::CoverageSpan::from_source_region(local_file_id, region);
|
||||||
match mapping_kind {
|
match mapping_kind {
|
||||||
MappingKind::Code(term) => {
|
MappingKind::Code(term) => {
|
||||||
code_regions.push(ffi::CodeRegion { span, counter: ffi::Counter::from_term(term) });
|
code_regions.push(ffi::CodeRegion { span, counter: ffi::Counter::from_term(term) });
|
||||||
|
Loading…
Reference in New Issue
Block a user