Skip to content

Commit a6849bd

Browse files
committed
Keep largest function end line if DBs are inconsistent and the corresponding error is ignored.
See #316. Signed-off-by: Henry Cox <[email protected]>
1 parent 80bde0c commit a6849bd

File tree

2 files changed

+52
-14
lines changed

2 files changed

+52
-14
lines changed

lib/lcovutil.pm

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4120,20 +4120,27 @@ sub define_function
41204120
my $data;
41214121
if (exists($locationMap->{$start_line})) {
41224122
$data = $locationMap->{$start_line};
4123-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
4124-
"mismatched end line for $fnName at " .
4125-
$self->filename() . ":$start_line: "
4126-
.
4127-
(defined($data->end_line()) ?
4128-
$data->end_line() : 'undef') .
4129-
" -> "
4130-
.
4131-
(defined($end_line) ? $end_line : 'undef')
4132-
)
4133-
unless ((defined($end_line) &&
4134-
defined($data->end_line()) &&
4135-
$end_line == $data->end_line()) ||
4136-
(!defined($end_line) && !defined($data->end_line())));
4123+
unless ((defined($end_line) &&
4124+
defined($data->end_line()) &&
4125+
$end_line == $data->end_line()) ||
4126+
(!defined($end_line) && !defined($data->end_line()))
4127+
) {
4128+
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
4129+
"mismatched end line for $fnName at " .
4130+
$self->filename() . ":$start_line: "
4131+
.
4132+
(defined($data->end_line()) ?
4133+
$data->end_line() : 'undef') .
4134+
" -> "
4135+
.
4136+
(defined($end_line) ? $end_line :
4137+
'undef'));
4138+
# pick the highest end line if we didn't error out
4139+
$data->set_end_line($end_line)
4140+
if (defined($end_line) &&
4141+
(!defined($data->end_line()) ||
4142+
$end_line > $data->end_line()));
4143+
}
41374144
} else {
41384145
$data = FunctionEntry->new($fnName, $self, $start_line, $end_line);
41394146
$locationMap->{$start_line} = $data;

man/genhtml.1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2798,13 +2798,44 @@ Unexpected syntax found in .info file.
27982798
.PP
27992799

28002800
.IP inconsistent: 3
2801+
This error indicates that your coverage data is internally inconsistent: it makes two or more mutually exclusive claims. For example:
2802+
.RS
2803+
.IP \- 3
28012804
Files have been moved or repository history presented by
28022805
.B \-\-diff\-file
28032806
data is not consistent with coverage data; for example, an 'inserted' line has baseline coverage data. These issues are likely to be caused by inconsistent handling in the 'diff' data compared to the 'baseline' and 'current' coverage data (e.g., using different source versions to collect the data but incorrectly annotating those differences), or by inconsistent treatment in the 'annotate' script.
28042807
Consider using a
28052808
.B \-\-version\-script
28062809
to guard against version mismatches.
28072810
.PP
2811+
.IP \- 3
2812+
Two or more
2813+
.B gcov
2814+
data files or
2815+
.B lcov
2816+
".info" files report different end lines for the same function. This is likely due either to a gcc/gcov bug or to a source version mismatch.
2817+
.br
2818+
In this context, if the
2819+
.I "inconsistent"
2820+
error is ignored, then the tool will record the largest number as the function end line.
2821+
.PP
2822+
.IP \- 3
2823+
Two or more
2824+
.B gcov
2825+
data files or
2826+
.B lcov
2827+
".info" files report different start lines for the same function. This is likely due either to a gcc/gcov bug or to a source version mismatch.
2828+
.br
2829+
In this context, if the
2830+
.I "inconsistent"
2831+
error is ignored, then the tool will retain only the first function definition that it saw.
2832+
.PP
2833+
.PP \- 3
2834+
Negative number or zero line number encounted.
2835+
.br
2836+
If the error is ignored, the offending record is skipped.
2837+
.RE
2838+
.PP
28082839

28092840
.IP internal: 3
28102841
internal tool issue detected. Please report this bug along with a testcase.

0 commit comments

Comments
 (0)