Skip to content

Commit bf634cd

Browse files
committed
Fix issue with overlapping basic blocks
1 parent e847460 commit bf634cd

2 files changed

Lines changed: 27 additions & 15 deletions

File tree

docs/man/lcov.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,10 @@ specified at a time.
10691069

10701070
File does not exist or is not readable.
10711071

1072+
``multiple``
1073+
1074+
Multiple basic blocks are defiend at the same start line. gcov reports usage counter only for the first one.
1075+
10721076
``negative``
10731077

10741078
negative 'hit' count found.

lib/lcovutil.pm

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ our @EXPORT_OK = qw($tool_name $tool_dir $lcov_version $lcov_url $VERSION
7878
%lcovErrors $ERROR_GCOV $ERROR_SOURCE $ERROR_GRAPH $ERROR_MISMATCH
7979
$ERROR_BRANCH $ERROR_EMPTY $ERROR_FORMAT $ERROR_VERSION $ERROR_UNUSED
8080
$ERROR_PACKAGE $ERROR_CORRUPT $ERROR_NEGATIVE $ERROR_COUNT $ERROR_PATH
81-
$ERROR_UNSUPPORTED $ERROR_DEPRECATED $ERROR_INCONSISTENT_DATA
81+
$ERROR_UNSUPPORTED $ERROR_DEPRECATED $ERROR_INCONSISTENT_DATA $ERROR_MULTIPLE_BASIC_BLOCKS
8282
$ERROR_CALLBACK $ERROR_RANGE $ERROR_UTILITY $ERROR_USAGE $ERROR_INTERNAL
8383
$ERROR_PARALLEL $ERROR_PARENT $ERROR_CHILD $ERROR_FORK
8484
$ERROR_EXCESSIVE_COUNT $ERROR_MISSING $ERROR_UNREACHABLE
@@ -150,6 +150,7 @@ our $ERROR_PARALLEL; # error in fork/join
150150
our $ERROR_DEPRECATED; # deprecated feature
151151
our $ERROR_CALLBACK; # callback produced an error
152152
our $ERROR_INCONSISTENT_DATA; # something wrong with .info
153+
our $ERROR_MULTIPLE_BASIC_BLOCKS;# source code line contains multiple blocks, e.g. functions
153154
our $ERROR_UNREACHABLE; # coverpoint hit in "unreachable" region
154155
our $ERROR_RANGE; # line number out of range
155156
our $ERROR_UTILITY; # some tool failed - e.g., 'find'
@@ -181,6 +182,7 @@ my @lcovErrs = (["annotate", \$ERROR_ANNOTATE_SCRIPT],
181182
["gcov", \$ERROR_GCOV],
182183
["graph", \$ERROR_GRAPH],
183184
["inconsistent", \$ERROR_INCONSISTENT_DATA],
185+
["multiple", \$ERROR_MULTIPLE_BASIC_BLOCKS],
184186
["internal", \$ERROR_INTERNAL],
185187
["mismatch", \$ERROR_MISMATCH],
186188
["missing", \$ERROR_MISSING],
@@ -5220,20 +5222,26 @@ sub define_function
52205222
$end_line == $data->end_line()) ||
52215223
(!defined($end_line) && !defined($data->end_line()))
52225224
) {
5223-
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
5224-
"mismatched end line for $fnName at " .
5225-
$self->filename() .
5226-
":$start_line: "
5227-
.
5228-
(defined($data->end_line()) ?
5229-
$data->end_line() : 'undef') .
5230-
" -> "
5231-
.
5232-
(defined($end_line) ? $end_line :
5233-
'undef') .
5234-
MessageContext::context())
5235-
unless
5236-
grep({ $fnName =~ $_ } @lcovutil::suppress_function_patterns);
5225+
if ($fnName ne $data->name()) {
5226+
lcovutil::ignorable_warning($lcovutil::ERROR_MULTIPLE_BASIC_BLOCKS,
5227+
"another block for $fnName overlaps with ".$data->name()." at " .
5228+
$self->filename() . ":$start_line" .
5229+
MessageContext::context());
5230+
} else {
5231+
lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
5232+
"mismatched end line for $fnName at " .
5233+
$self->filename() . ":$start_line: "
5234+
.
5235+
(defined($data->end_line()) ?
5236+
$data->end_line() : 'undef') .
5237+
" -> "
5238+
.
5239+
(defined($end_line) ? $end_line :
5240+
'undef') .
5241+
MessageContext::context())
5242+
unless
5243+
grep({ $fnName =~ $_ } @lcovutil::suppress_function_patterns);
5244+
}
52375245
# pick the highest end line if we didn't error out
52385246
$data->set_end_line($end_line)
52395247
if (defined($end_line) &&

0 commit comments

Comments
 (0)