@@ -4331,10 +4331,18 @@ sub new
4331
4331
4332
4332
sub cloneWithEndLine
4333
4333
{
4334
- my ($self , $withEnd ) = @_ ;
4335
- return
4336
- FunctionEntry-> new($self -> [NAME], $self -> [MAP], $self -> [FIRST],
4337
- $withEnd ? $self -> [LAST] : undef );
4334
+ my ($self , $withEnd , $cloneAliases ) = @_ ;
4335
+ my $fn = FunctionEntry-> new($self -> [NAME], $self -> [MAP], $self -> [FIRST],
4336
+ $withEnd ? $self -> [LAST] : undef );
4337
+ if ($cloneAliases ) {
4338
+ my $count = 0;
4339
+ while (my ($alias , $hit ) = each (%{$self -> aliases()})) {
4340
+ $fn -> [ALIASES]-> {$alias } = $hit ;
4341
+ $count += $hit ;
4342
+ }
4343
+ $fn -> [COUNT] = $count ;
4344
+ }
4345
+ return $fn ;
4338
4346
}
4339
4347
4340
4348
sub name
@@ -6775,7 +6783,7 @@ sub data
6775
6783
6776
6784
my $key = $lcovutil::case_insensitive ? lc ($file ) : $file ;
6777
6785
my $files = $self -> [FILES];
6778
- if (!defined ($files -> {$key })) {
6786
+ if (!exists ($files -> {$key })) {
6779
6787
if (defined $checkMatchingBasename ) {
6780
6788
# check if there is a file in the map that has the same basename
6781
6789
# as the lone we are looking for.
@@ -6802,6 +6810,13 @@ sub data
6802
6810
return $files -> {$key };
6803
6811
}
6804
6812
6813
+ sub contains
6814
+ {
6815
+ my ($self , $file ) = @_ ;
6816
+ my $key = $lcovutil::case_insensitive ? lc ($file ) : $file ;
6817
+ my $files = $self -> [FILES];
6818
+ return exists ($files -> {$key });
6819
+ }
6805
6820
6806
6821
sub remove
6807
6822
{
@@ -6966,8 +6981,9 @@ sub _deriveFunctionEndLines
6966
6981
my $traceInfo = shift ;
6967
6982
my $modified = 0;
6968
6983
6969
- my $start = Time::HiRes::gettimeofday();
6970
- my @lines = sort { $a <=> $b } $traceInfo -> sum()-> keylist();
6984
+ my $start = Time::HiRes::gettimeofday();
6985
+ my $lineData = $traceInfo -> sum();
6986
+ my @lines = sort { $a <=> $b } $lineData -> keylist();
6971
6987
# sort functions by start line number
6972
6988
# ignore lambdas - which we don't process correctly at the moment
6973
6989
# (would need to do syntactic search for the end line)
@@ -6980,6 +6996,12 @@ sub _deriveFunctionEndLines
6980
6996
my $func = shift (@functions );
6981
6997
my $first = $func -> line();
6982
6998
my $end = $func -> end_line();
6999
+ # unless (defined($lineData->value($first))) {
7000
+ # lcovutil::ignorable_error($lcovutil::ERROR_INCONSISTENT_DATA,
7001
+ # '"' . $func->filename() .
7002
+ # "\":$first: first line of function has no linecov.");
7003
+ # $lineData->append($first, $func->hit());
7004
+ # }
6983
7005
while ($first < $currentLine ) {
6984
7006
if (@lines ) {
6985
7007
$currentLine = shift @lines ;
@@ -7143,7 +7165,7 @@ sub _checkConsistency
7143
7165
my $hit = $lineData -> value($currentLine );
7144
7166
$lineHit = 1 if $hit ;
7145
7167
if ($hit && !$imHit ) {
7146
- # don't wan about the first line of a lambda:
7168
+ # don't warn about the first line of a lambda:
7147
7169
# - the decl may executed even if the lambda function itself is
7148
7170
# not called
7149
7171
# - if no other lines are hit, then then the function is not
@@ -8240,6 +8262,12 @@ sub _read_info
8240
8262
$skipCurrentFile = 1;
8241
8263
next ;
8242
8264
}
8265
+ # if ($self->contains($filename)) {
8266
+ # # we expect there to be only one entry for each source file in each section
8267
+ # lcovutil::ignorable_warning($lcovutil::ERROR_FORMAT,
8268
+ # "Duplicate entries for \"$filename\""
8269
+ # . ($testname ? " in testcase '$testname'" : '') . '.');
8270
+ # }
8243
8271
$filename = ReadCurrentSource::resolve_path($1 , 1);
8244
8272
# should this one be skipped?
8245
8273
$skipCurrentFile = skipCurrentFile($filename );
@@ -8272,20 +8300,18 @@ sub _read_info
8272
8300
($testdata , $sumcount , $funcdata ,
8273
8301
$checkdata , $testfncdata , $testbrdata ,
8274
8302
$sumbrcount , $mcdcCount , $testMcdc ) = $fileData -> get_info();
8275
- $functionMap =
8276
- defined ($testname ) ? FunctionMap-> new($filename ) : $funcdata ;
8277
8303
8278
8304
if (defined ($testname )) {
8279
- $testcount = $fileData -> test($testname );
8280
- $testfnccount = $fileData -> testfnc($testname );
8281
- $testbrcount = $fileData -> testbr($testname );
8305
+ $testcount = $fileData -> test($testname );
8306
+ $functionMap = $fileData -> testfnc($testname );
8282
8307
$testbrcount = $fileData -> testbr($testname );
8283
8308
$testcase_mcdc = $fileData -> testcase_mcdc($testname );
8284
8309
} else {
8285
8310
$testcount = CountData-> new($filename , 1);
8286
8311
$testfnccount = CountData-> new($filename , 0);
8287
8312
$testbrcount = BranchData-> new();
8288
8313
$testcase_mcdc = MCDC_Data-> new();
8314
+ $functionMap = FunctionMap-> new($filename );
8289
8315
}
8290
8316
next ;
8291
8317
}
0 commit comments