Skip to content

Commit 7cf6549

Browse files
committed
coverage: avoid double-counting entry line
fix #29785
1 parent 7ad2ea5 commit 7cf6549

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/codegen.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6475,8 +6475,15 @@ static std::unique_ptr<Module> emit_function(
64756475
BB[label] = bb;
64766476
}
64776477

6478-
if (do_coverage(mod_is_user_mod))
6478+
if (do_coverage(mod_is_user_mod)) {
64796479
coverageVisitLine(ctx, ctx.file, toplineno);
6480+
if (linetable.size() >= 1) {
6481+
// avoid double-counting the entry line
6482+
const auto &info = linetable.at(1);
6483+
if (info.file == ctx.file && info.line == toplineno && info.is_user_code == mod_is_user_mod)
6484+
current_lineinfo.push_back(1);
6485+
}
6486+
}
64806487
if (do_malloc_log(mod_is_user_mod))
64816488
mallocVisitLine(ctx, ctx.file, toplineno);
64826489
find_next_stmt(0);

test/testhelpers/coverage_file.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
SF:<FILENAME>
2-
DA:4,2
2+
DA:4,1
33
DA:5,0
44
DA:7,1
55
DA:8,1

0 commit comments

Comments
 (0)