llvm_cov_json/types/file.rs
1use serde::Deserialize;
2
3use crate::{Branch, Expansion};
4
5use super::Summary;
6
7/// Summary of the regions metric.
8#[derive(Debug, PartialEq, Deserialize)]
9pub struct FileMetrics<'a> {
10 /// Absolute path to the file.
11 pub filename: &'a str,
12 /// Summary of all metrecis.
13 pub summary: Summary,
14 /// Branches in this file.
15 pub branches: Vec<Branch>,
16 /// The segments of the file. Each segment starts at some point in the source
17 /// file, and is "valid" until the next segment start is encountered.
18 pub segments: Vec<Segment>,
19 /// Expansion of this file. May be None, if the export of expansions have been disabled.
20 pub expansions: Option<Vec<Expansion<'a>>>,
21}
22
23/// Execution count information starting at a point (row and column) in a file.
24/// A sequence of CoverageSegments gives execution counts for a file in a format.
25/// See the [LLVM sourceode](https://github.com/llvm/llvm-project/blob/bd611264993f64decbce178d460caf1d1cb05f59/llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h#L448)
26/// for more information.
27#[derive(Debug, PartialEq, Deserialize)]
28pub struct Segment {
29 /// Source code line this segment starts.
30 line: u64,
31 /// Column this segment starts.
32 col: u64,
33 /// Number of times this segment was executed.
34 count: u64,
35 /// If false, the segment was not instrumented or skipped.
36 has_count: bool,
37 /// Whether this enters a new region.
38 /// TODO: Needs documentation.
39 is_region_entry: bool,
40 /// Whether this enters a gap region.
41 /// TODO: Needs documentation.
42 is_gap_region: bool,
43}