@@ -4131,6 +4131,7 @@ sub applyFilters
4131
4131
}
4132
4132
# derive function end line for C/C++ code if requested
4133
4133
# (not trying to handle python nested functions, etc)
4134
+ DERIVE:
4134
4135
if (defined ($lcovutil::derive_function_end_line ) &&
4135
4136
$lcovutil::derive_function_end_line != 0 &&
4136
4137
defined ($lcovutil::func_coverage ) &&
@@ -4139,26 +4140,28 @@ sub applyFilters
4139
4140
# sort functions by start line number
4140
4141
my @functions = sort { $a -> line() <=> $b -> line() }
4141
4142
$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;
4145
4145
my $funcData = $traceInfo -> testfnc();
4146
4146
FUNC: while (@functions ) {
4147
4147
my $func = shift (@functions );
4148
4148
my $first = $func -> line();
4149
+ my $end = $func -> end_line();
4149
4150
while ($first < $currentLine ) {
4150
4151
if (@lines ) {
4151
4152
$currentLine = shift @lines ;
4152
4153
} 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
+ }
4158
4161
next FUNC;
4159
4162
}
4160
4163
}
4161
- if (!defined ($func -> end_line() )) {
4164
+ if (!defined ($end )) {
4162
4165
# where is the next function? Find the last 'line' coverpoint
4163
4166
# less than the start line of that function..
4164
4167
if (@lines ) {
0 commit comments