Skip to content

Commit 75342b1

Browse files
authored
chore(coverage): remove SinglePathBranch kind, use Branch kind (#8619)
chore(coverage): remove SinglePathBranch kind, use Branch with first opcode
1 parent 4351742 commit 75342b1

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

crates/evm/coverage/src/analysis.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,11 @@ impl<'a> ContractVisitor<'a> {
236236
if has_statements(&true_body) {
237237
// Add the coverage item for branch 0 (true body).
238238
self.push_item_kind(
239-
CoverageItemKind::SinglePathBranch { branch_id },
239+
CoverageItemKind::Branch {
240+
branch_id,
241+
path_id: 0,
242+
is_first_opcode: true,
243+
},
240244
&true_body.src,
241245
);
242246
// Process the true body.
@@ -451,12 +455,8 @@ impl<'a> ContractVisitor<'a> {
451455
fn push_item_kind(&mut self, kind: CoverageItemKind, src: &ast::LowFidelitySourceLocation) {
452456
let item = CoverageItem { kind, loc: self.source_location_for(src), hits: 0 };
453457
// Push a line item if we haven't already
454-
if matches!(
455-
item.kind,
456-
CoverageItemKind::Statement |
457-
CoverageItemKind::Branch { .. } |
458-
CoverageItemKind::SinglePathBranch { .. }
459-
) && self.last_line < item.loc.line
458+
if matches!(item.kind, CoverageItemKind::Statement | CoverageItemKind::Branch { .. }) &&
459+
self.last_line < item.loc.line
460460
{
461461
self.items.push(CoverageItem {
462462
kind: CoverageItemKind::Line,

crates/evm/coverage/src/lib.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,11 +297,6 @@ pub enum CoverageItemKind {
297297
/// If true, then the branch anchor is the first opcode within the branch source range.
298298
is_first_opcode: bool,
299299
},
300-
/// A branch in the code.
301-
SinglePathBranch {
302-
/// The ID that identifies the branch.
303-
branch_id: usize,
304-
},
305300
/// A function in the code.
306301
Function {
307302
/// The name of the function.
@@ -331,9 +326,6 @@ impl Display for CoverageItem {
331326
CoverageItemKind::Branch { branch_id, path_id, .. } => {
332327
write!(f, "Branch (branch: {branch_id}, path: {path_id})")?;
333328
}
334-
CoverageItemKind::SinglePathBranch { branch_id } => {
335-
write!(f, "Branch (branch: {branch_id}, path: 0)")?;
336-
}
337329
CoverageItemKind::Function { name } => {
338330
write!(f, r#"Function "{name}""#)?;
339331
}
@@ -418,7 +410,7 @@ impl AddAssign<&CoverageItem> for CoverageSummary {
418410
self.statement_hits += 1;
419411
}
420412
}
421-
CoverageItemKind::Branch { .. } | CoverageItemKind::SinglePathBranch { .. } => {
413+
CoverageItemKind::Branch { .. } => {
422414
self.branch_count += 1;
423415
if item.hits > 0 {
424416
self.branch_hits += 1;

crates/forge/src/coverage.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,6 @@ impl<'a> CoverageReporter for LcovReporter<'a> {
116116
if hits == 0 { "-".to_string() } else { hits.to_string() }
117117
)?;
118118
}
119-
CoverageItemKind::SinglePathBranch { branch_id } => {
120-
writeln!(
121-
self.destination,
122-
"BRDA:{line},{branch_id},0,{}",
123-
if hits == 0 { "-".to_string() } else { hits.to_string() }
124-
)?;
125-
}
126119
// Statements are not in the LCOV format.
127120
// We don't add them in order to avoid doubling line hits.
128121
_ => {}

0 commit comments

Comments
 (0)