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 a9363db
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,17 @@ 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 a9363db

Please sign in to comment.