Skip to content

Commit

Permalink
coverage: avoid double-counting entry line
Browse files Browse the repository at this point in the history
fix #29785
  • Loading branch information
vtjnash committed Jan 14, 2020
1 parent 7ad2ea5 commit 7cf6549
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6475,8 +6475,15 @@ static std::unique_ptr<Module> emit_function(
BB[label] = bb;
}

if (do_coverage(mod_is_user_mod))
if (do_coverage(mod_is_user_mod)) {
coverageVisitLine(ctx, ctx.file, toplineno);
if (linetable.size() >= 1) {
// avoid double-counting the entry line
const auto &info = linetable.at(1);
if (info.file == ctx.file && info.line == toplineno && info.is_user_code == mod_is_user_mod)
current_lineinfo.push_back(1);
}
}
if (do_malloc_log(mod_is_user_mod))
mallocVisitLine(ctx, ctx.file, toplineno);
find_next_stmt(0);
Expand Down
2 changes: 1 addition & 1 deletion test/testhelpers/coverage_file.info
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SF:<FILENAME>
DA:4,2
DA:4,1
DA:5,0
DA:7,1
DA:8,1
Expand Down

0 comments on commit 7cf6549

Please sign in to comment.