Skip to main content

llvm_profparser/
lib.rs

1use crate::instrumentation_profile::types::InstrumentationProfile;
2use std::path::Path;
3
4pub mod coverage;
5mod hash_table;
6pub mod instrumentation_profile;
7pub mod summary;
8pub mod util;
9
10pub use crate::instrumentation_profile::{parse, parse_bytes};
11pub use coverage::coverage_mapping::CoverageMapping;
12pub use coverage::reporting::*;
13pub use coverage::*;
14
15#[derive(Debug, Clone, Copy, Eq, PartialEq, Hash, Ord, PartialOrd)]
16pub enum ProfileFormat {
17    Binary,
18    CompactBinary,
19    ExtBinary,
20    Text,
21    Gcc,
22}
23
24pub fn merge_profiles<T>(files: &[T]) -> std::io::Result<InstrumentationProfile>
25where
26    T: AsRef<Path>,
27{
28    let Some((first, rest)) = files.split_first() else {
29        return Ok(InstrumentationProfile::default());
30    };
31
32    let mut base = parse(first)?;
33    for input in rest {
34        let profile = parse(input)?;
35        base.merge(&profile);
36    }
37    Ok(base)
38}