diff --git a/cov/src/graph.rs b/cov/src/graph.rs index 62a15c3..d95596f 100644 --- a/cov/src/graph.rs +++ b/cov/src/graph.rs @@ -12,7 +12,7 @@ use petgraph::Direction; use petgraph::graph::{DiGraph, EdgeIndex, EdgeReference, NodeIndex}; use petgraph::visit::{Dfs, EdgeFiltered, EdgeRef, IntoNodeReferences}; -use std::{io, mem, usize}; +use std::{cmp, io, mem, usize}; use std::borrow::Cow; use std::collections::{BTreeMap, Bound, HashSet}; use std::collections::hash_map::{Entry, HashMap}; @@ -261,7 +261,7 @@ impl Graph { for (filename, line_number) in block.iter_lines() { let file = r.files.entry(filename).or_default(); let line = file.lines.entry(line_number).or_default(); - line.count += block_count; + line.count = cmp::max(line.count, block_count); line.attr |= block.attr; last_line = Some((filename, line_number)); } diff --git a/cov/test-data/branches.rustc/x.json b/cov/test-data/branches.rustc/x.json index 1bedd3c..6512e33 100644 --- a/cov/test-data/branches.rustc/x.json +++ b/cov/test-data/branches.rustc/x.json @@ -78,7 +78,7 @@ "branches": [] }, "8": { - "count": 2, + "count": 1, "attr": 0, "branches": [ { @@ -98,12 +98,12 @@ ] }, "9": { - "count": 2, + "count": 1, "attr": 0, "branches": [] }, "10": { - "count": 2, + "count": 1, "attr": 0, "branches": [ { diff --git a/cov/test-data/trivial.clang/x.json b/cov/test-data/trivial.clang/x.json index 73c0a3f..f3c0119 100644 --- a/cov/test-data/trivial.clang/x.json +++ b/cov/test-data/trivial.clang/x.json @@ -3,7 +3,7 @@ "x.cpp": { "lines": { "1": { - "count": 2, + "count": 1, "attr": 0, "branches": [] } diff --git a/cov/test-data/trivial.rustc/x.json b/cov/test-data/trivial.rustc/x.json index 167211e..df54df1 100644 --- a/cov/test-data/trivial.rustc/x.json +++ b/cov/test-data/trivial.rustc/x.json @@ -3,7 +3,7 @@ "x.rs": { "lines": { "1": { - "count": 2, + "count": 1, "attr": 0, "branches": [] }