Skip to main content

rustc_codegen_llvm/coverageinfo/
ffi.rs

1/// Must match the layout of `LLVMRustCounterKind`.
2#[derive(#[automatically_derived]
impl ::core::marker::Copy for CounterKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CounterKind {
    #[inline]
    fn clone(&self) -> CounterKind { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CounterKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                CounterKind::Zero => "Zero",
                CounterKind::CounterValueReference => "CounterValueReference",
                CounterKind::Expression => "Expression",
            })
    }
}Debug)]
3#[repr(C)]
4pub(crate) enum CounterKind {
5    Zero = 0,
6    CounterValueReference = 1,
7    Expression = 2,
8}
9
10/// A reference to an instance of an abstract "counter" that will yield a value in a coverage
11/// report. Note that `id` has different interpretations, depending on the `kind`:
12///   * For `CounterKind::Zero`, `id` is assumed to be `0`
13///   * For `CounterKind::CounterValueReference`,  `id` matches the `counter_id` of the injected
14///     instrumentation counter (the `index` argument to the LLVM intrinsic
15///     `instrprof.increment()`)
16///   * For `CounterKind::Expression`, `id` is the index into the coverage map's array of
17///     counter expressions.
18///
19/// Corresponds to struct `llvm::coverage::Counter`.
20///
21/// Must match the layout of `LLVMRustCounter`.
22#[derive(#[automatically_derived]
impl ::core::marker::Copy for Counter { }Copy, #[automatically_derived]
impl ::core::clone::Clone for Counter {
    #[inline]
    fn clone(&self) -> Counter {
        let _: ::core::clone::AssertParamIsClone<CounterKind>;
        let _: ::core::clone::AssertParamIsClone<u32>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for Counter {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "Counter",
            "kind", &self.kind, "id", &&self.id)
    }
}Debug)]
23#[repr(C)]
24pub(crate) struct Counter {
25    // Important: The layout (order and types of fields) must match its C++ counterpart.
26    pub(crate) kind: CounterKind,
27    pub(crate) id: u32,
28}
29
30impl Counter {
31    /// A `Counter` of kind `Zero`. For this counter kind, the `id` is not used.
32    pub(crate) const ZERO: Self = Self { kind: CounterKind::Zero, id: 0 };
33}
34
35/// Corresponds to enum `llvm::coverage::CounterExpression::ExprKind`.
36///
37/// Must match the layout of `LLVMRustCounterExprKind`.
38#[derive(#[automatically_derived]
impl ::core::marker::Copy for ExprKind { }Copy, #[automatically_derived]
impl ::core::clone::Clone for ExprKind {
    #[inline]
    fn clone(&self) -> ExprKind { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ExprKind {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f,
            match self {
                ExprKind::Subtract => "Subtract",
                ExprKind::Add => "Add",
            })
    }
}Debug)]
39#[repr(C)]
40pub(crate) enum ExprKind {
41    Subtract = 0,
42    Add = 1,
43}
44
45/// Corresponds to struct `llvm::coverage::CounterExpression`.
46///
47/// Must match the layout of `LLVMRustCounterExpression`.
48#[derive(#[automatically_derived]
impl ::core::marker::Copy for CounterExpression { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CounterExpression {
    #[inline]
    fn clone(&self) -> CounterExpression {
        let _: ::core::clone::AssertParamIsClone<ExprKind>;
        let _: ::core::clone::AssertParamIsClone<Counter>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CounterExpression {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f,
            "CounterExpression", "kind", &self.kind, "lhs", &self.lhs, "rhs",
            &&self.rhs)
    }
}Debug)]
49#[repr(C)]
50pub(crate) struct CounterExpression {
51    pub(crate) kind: ExprKind,
52    pub(crate) lhs: Counter,
53    pub(crate) rhs: Counter,
54}
55
56/// A span of source code coordinates to be embedded in coverage metadata.
57///
58/// Must match the layout of `LLVMRustCoverageSpan`.
59#[derive(#[automatically_derived]
impl ::core::clone::Clone for CoverageSpan {
    #[inline]
    fn clone(&self) -> CoverageSpan {
        CoverageSpan {
            file_id: ::core::clone::Clone::clone(&self.file_id),
            start_line: ::core::clone::Clone::clone(&self.start_line),
            start_col: ::core::clone::Clone::clone(&self.start_col),
            end_line: ::core::clone::Clone::clone(&self.end_line),
            end_col: ::core::clone::Clone::clone(&self.end_col),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CoverageSpan {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field5_finish(f, "CoverageSpan",
            "file_id", &self.file_id, "start_line", &self.start_line,
            "start_col", &self.start_col, "end_line", &self.end_line,
            "end_col", &&self.end_col)
    }
}Debug)]
60#[repr(C)]
61pub(crate) struct CoverageSpan {
62    /// Local index into the function's local-to-global file ID table.
63    /// The value at that index is itself an index into the coverage filename
64    /// table in the CGU's `__llvm_covmap` section.
65    pub(crate) file_id: u32,
66
67    /// 1-based starting line of the source code span.
68    pub(crate) start_line: u32,
69    /// 1-based starting column of the source code span.
70    pub(crate) start_col: u32,
71    /// 1-based ending line of the source code span.
72    pub(crate) end_line: u32,
73    /// 1-based ending column of the source code span. High bit must be unset.
74    pub(crate) end_col: u32,
75}
76
77/// Must match the layout of `LLVMRustCoverageCodeRegion`.
78#[derive(#[automatically_derived]
impl ::core::clone::Clone for CodeRegion {
    #[inline]
    fn clone(&self) -> CodeRegion {
        CodeRegion {
            cov_span: ::core::clone::Clone::clone(&self.cov_span),
            counter: ::core::clone::Clone::clone(&self.counter),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CodeRegion {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f, "CodeRegion",
            "cov_span", &self.cov_span, "counter", &&self.counter)
    }
}Debug)]
79#[repr(C)]
80pub(crate) struct CodeRegion {
81    pub(crate) cov_span: CoverageSpan,
82    pub(crate) counter: Counter,
83}
84
85/// Must match the layout of `LLVMRustCoverageExpansionRegion`.
86#[derive(#[automatically_derived]
impl ::core::clone::Clone for ExpansionRegion {
    #[inline]
    fn clone(&self) -> ExpansionRegion {
        ExpansionRegion {
            cov_span: ::core::clone::Clone::clone(&self.cov_span),
            expanded_file_id: ::core::clone::Clone::clone(&self.expanded_file_id),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ExpansionRegion {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "ExpansionRegion", "cov_span", &self.cov_span, "expanded_file_id",
            &&self.expanded_file_id)
    }
}Debug)]
87#[repr(C)]
88pub(crate) struct ExpansionRegion {
89    pub(crate) cov_span: CoverageSpan,
90    pub(crate) expanded_file_id: u32,
91}
92
93/// Must match the layout of `LLVMRustCoverageBranchRegion`.
94#[derive(#[automatically_derived]
impl ::core::clone::Clone for BranchRegion {
    #[inline]
    fn clone(&self) -> BranchRegion {
        BranchRegion {
            cov_span: ::core::clone::Clone::clone(&self.cov_span),
            true_counter: ::core::clone::Clone::clone(&self.true_counter),
            false_counter: ::core::clone::Clone::clone(&self.false_counter),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for BranchRegion {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field3_finish(f, "BranchRegion",
            "cov_span", &self.cov_span, "true_counter", &self.true_counter,
            "false_counter", &&self.false_counter)
    }
}Debug)]
95#[repr(C)]
96pub(crate) struct BranchRegion {
97    pub(crate) cov_span: CoverageSpan,
98    pub(crate) true_counter: Counter,
99    pub(crate) false_counter: Counter,
100}