Skip to content

Commit

Permalink
Fix .gcda parsing for C++ templates
Browse files Browse the repository at this point in the history
  • Loading branch information
culhatsker committed Mar 22, 2024
1 parent cc77ce3 commit 79d996f
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,20 @@ pub fn parse_gcov_gz(gcov_path: &Path) -> Result<Vec<(String, CovResult)>, Parse
let mut lines = BTreeMap::new();
let mut branches = BTreeMap::new();
for mut line in file.lines.drain(..) {
lines.insert(line.line_number, line.count);
lines
.entry(line.line_number)
.and_modify(|v| *v += line.count)
.or_insert(line.count);
if !line.branches.is_empty() {
branches.insert(
line.line_number,
line.branches.drain(..).map(|b| b.count > 0).collect(),
);
let values: Vec<bool> = line.branches.drain(..).map(|b| b.count > 0).collect();
branches
.entry(line.line_number)
.and_modify(|v: &mut Vec<bool>| {
v.iter_mut()
.zip(values.iter())
.for_each(|(val, newval)| *val &= newval)
})
.or_insert(values);
}
}
if lines.is_empty() {
Expand Down

0 comments on commit 79d996f

Please sign in to comment.