Skip to content

Commit 82310ca

Browse files
committed
Modify function end line assignment flow to avoid premature checking.
Signed-off-by: Henry Cox <[email protected]>
1 parent f1f5cfd commit 82310ca

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

lib/lcovutil.pm

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4131,6 +4131,7 @@ sub applyFilters
41314131
}
41324132
# derive function end line for C/C++ code if requested
41334133
# (not trying to handle python nested functions, etc)
4134+
DERIVE:
41344135
if (defined($lcovutil::derive_function_end_line) &&
41354136
$lcovutil::derive_function_end_line != 0 &&
41364137
defined($lcovutil::func_coverage) &&
@@ -4139,26 +4140,28 @@ sub applyFilters
41394140
# sort functions by start line number
41404141
my @functions = sort { $a->line() <=> $b->line() }
41414142
$traceInfo->func()->valuelist();
4142-
die("unexpectedly empty list of lines for $name")
4143-
unless (@lines);
4144-
my $currentLine = shift(@lines);
4143+
4144+
my $currentLine = @lines ? shift(@lines) : 0;
41454145
my $funcData = $traceInfo->testfnc();
41464146
FUNC: while (@functions) {
41474147
my $func = shift(@functions);
41484148
my $first = $func->line();
4149+
my $end = $func->end_line();
41494150
while ($first < $currentLine) {
41504151
if (@lines) {
41514152
$currentLine = shift @lines;
41524153
} else {
4153-
lcovutil::ignorable_error(
4154-
$lcovutil::ERROR_INCONSISTENT_DATA,
4155-
"\"$name\":$first: function " . $func->name() .
4156-
" found on line but no corresponding 'line' coverage data point. Cannot derive function end line."
4157-
);
4154+
if (!defined($end)) {
4155+
lcovutil::ignorable_error(
4156+
$lcovutil::ERROR_INCONSISTENT_DATA,
4157+
"\"$name\":$first: function " . $func->name() .
4158+
" found on line but no corresponding 'line' coverage data point. Cannot derive function end line."
4159+
);
4160+
}
41584161
next FUNC;
41594162
}
41604163
}
4161-
if (!defined($func->end_line())) {
4164+
if (!defined($end)) {
41624165
# where is the next function? Find the last 'line' coverpoint
41634166
# less than the start line of that function..
41644167
if (@lines) {

0 commit comments

Comments
 (0)