@@ -815,7 +815,7 @@ sub save_profile($)
815
815
sub set_extensions
816
816
{
817
817
my ($type , $str ) = @_ ;
818
- die (" unknown language '$type '" ) unless exits ($languageExtensions {$type });
818
+ die (" unknown language '$type '" ) unless exists ($languageExtensions {$type });
819
819
$languageExtensions {$type } = join (' |' , split ($split_char , $str ));
820
820
}
821
821
@@ -5063,6 +5063,12 @@ sub filename
5063
5063
return $_ [0]-> [FILENAME];
5064
5064
}
5065
5065
5066
+ sub numLines
5067
+ {
5068
+ my $self = shift ;
5069
+ return scalar (@{$self -> [SOURCE]});
5070
+ }
5071
+
5066
5072
sub getLine
5067
5073
{
5068
5074
my ($self , $line ) = @_ ;
@@ -5816,8 +5822,11 @@ sub _filterFile
5816
5822
++$remove -> [0]; # one line where we skip
5817
5823
$remove -> [1] += ($brdata -> totals())[0];
5818
5824
lcovutil::info(2,
5819
- " filter BRDA '" .
5820
- $srcReader -> getLine($line ) .
5825
+ " filter BRDA '"
5826
+ .
5827
+ ($line < $srcReader -> numLines() ?
5828
+ $srcReader -> getLine($line ) :
5829
+ ' <-->' ) .
5821
5830
" ' $source_file :$line \n " );
5822
5831
# now remove this branch everywhere...
5823
5832
foreach my $tn ($testbrdata -> keylist()) {
@@ -5882,7 +5891,7 @@ sub _filterFile
5882
5891
lcovutil::info(2,
5883
5892
" filter DA "
5884
5893
.
5885
- (defined ( $ srcReader-> getLine( $line ) ) ?
5894
+ ($line < $ srcReader-> numLines( ) ?
5886
5895
(" '" . $srcReader -> getLine($line ) . " '" ) :
5887
5896
" " ) .
5888
5897
" $source_file :$line \n " );
@@ -6486,10 +6495,13 @@ sub applyFilters
6486
6495
sub is_language
6487
6496
{
6488
6497
my ($lang , $filename ) = @_ ;
6498
+ my $idx = index ($filename , ' .' );
6499
+ my $ext = $idx == -1 ? ' ' : substr ($filename , $idx + 1);
6489
6500
foreach my $l (split (' \|' , $lang )) {
6490
6501
die (" unknown language '$l '" )
6491
6502
unless exists ($lcovutil::languageExtensions {$l });
6492
- return 1 if $filename =~ / \. ($lcovutil::languageExtensions {$l })$ / ;
6503
+ my $extensions = $lcovutil::languageExtensions {$l };
6504
+ return 1 if ($ext =~ / ($extensions )/ );
6493
6505
}
6494
6506
return 0;
6495
6507
}
@@ -6585,7 +6597,7 @@ sub _read_info
6585
6597
# The hack is to put branches into a hash keyed by branch ID - and
6586
6598
# merge elements with the same key if we run into them in the multiple
6587
6599
# times in the same 'file' data (within an SF entry).
6588
- my %branchRenumber ; # line -> block -> branch -> branchentry
6600
+ my %nextBranchId ; # line -> integer ID
6589
6601
my ($currentBranchLine , $skipBranch );
6590
6602
my $functionMap ;
6591
6603
my %excludedFunction ;
@@ -6618,7 +6630,7 @@ sub _read_info
6618
6630
}
6619
6631
6620
6632
# Retrieve data for new entry
6621
- %branchRenumber = ();
6633
+ %nextBranchId = ();
6622
6634
%excludedFunction = ();
6623
6635
6624
6636
if ($verify_checksum ) {
@@ -6815,8 +6827,6 @@ sub _read_info
6815
6827
my $comma = rindex ($d , ' ,' );
6816
6828
my $taken = substr ($d , $comma + 1);
6817
6829
my $expr = substr ($d , 0, $comma );
6818
- # hold line, block, expr etc - to process when we get to end of file
6819
- # (for parallelism support...)
6820
6830
6821
6831
# Notes:
6822
6832
# - there may be other branches on the same line (..the next
@@ -6837,43 +6847,20 @@ sub _read_info
6837
6847
# generate an CNF or truth-table like entry corresponding
6838
6848
# to the branch.
6839
6849
6840
- if (!is_language(' c' , $filename )) {
6841
- # At least at present, Verilog/SystemVerilog/VHDL,
6842
- # java, python, etc don't need branch number fixing
6843
- my $key = " $line ,$block " ;
6844
- my $branch =
6845
- exists ($branchRenumber {$key }) ?
6846
- $branchRenumber {$key } :
6847
- 0;
6848
- $branchRenumber {$key } = $branch + 1;
6849
-
6850
- my $br =
6851
- BranchBlock-> new($branch , $taken , $expr , $is_exception );
6852
- $fileData -> sumbr()-> append($line , $block , $br , $filename );
6853
-
6854
- # Add test-specific counts
6855
- if (defined ($testname )) {
6856
- $fileData -> testbr($testname )
6857
- -> append($line , $block , $br , $filename );
6858
- }
6859
- } else {
6860
- # only C code might need renumbering - but this
6861
- # is an artifact of some very old geninfo code,
6862
- # so any new data files will be OK
6863
- $branchRenumber {$line } = {}
6864
- unless exists ($branchRenumber {$line });
6865
- $branchRenumber {$line }-> {$block } = {}
6866
- unless exists ($branchRenumber {$line }-> {$block });
6867
- my $table = $branchRenumber {$line }-> {$block };
6868
-
6869
- my $entry =
6870
- BranchBlock-> new($expr , $taken , $expr , $is_exception );
6871
- if (exists ($table -> {$expr })) {
6872
- # merge
6873
- $table -> {$expr }-> merge($entry , $filename , $line );
6874
- } else {
6875
- $table -> {$expr } = $entry ;
6876
- }
6850
+ my $key = " $line ,$block " ;
6851
+ my $branch =
6852
+ exists ($nextBranchId {$key }) ? $nextBranchId {$key } :
6853
+ 0;
6854
+ $nextBranchId {$key } = $branch + 1;
6855
+
6856
+ my $br =
6857
+ BranchBlock-> new($branch , $taken , $expr , $is_exception );
6858
+ $fileData -> sumbr()-> append($line , $block , $br , $filename );
6859
+
6860
+ # Add test-specific counts
6861
+ if (defined ($testname )) {
6862
+ $fileData -> testbr($testname )
6863
+ -> append($line , $block , $br , $filename );
6877
6864
}
6878
6865
last ;
6879
6866
};
@@ -6888,36 +6875,6 @@ sub _read_info
6888
6875
$fileData -> version($version )
6889
6876
if (defined ($version ) && $version ne " " );
6890
6877
}
6891
- if (is_language(' c' , $filename )) {
6892
- # RTL code was added directly - no issue with
6893
- # duplicate data entries in geninfo result
6894
- my $testcaseBranchData = $fileData -> testbr($testname )
6895
- if defined ($testname );
6896
- while (my ($line , $l_data ) = each (%branchRenumber )) {
6897
- foreach my $block (sort { $a <=> $b }
6898
- keys (%$l_data )
6899
- ) {
6900
- my $bdata = $l_data -> {$block };
6901
- my $branchId = 0;
6902
- foreach my $b_id (sort { $a <=> $b }
6903
- keys (%$bdata )
6904
- ) {
6905
- my $br = $bdata -> {$b_id };
6906
- my $b =
6907
- BranchBlock-> new($branchId , $br -> data(),
6908
- undef , $br -> is_exception());
6909
- $fileData -> sumbr()
6910
- -> append($line , $block , $b , $filename );
6911
-
6912
- if (defined ($testcaseBranchData )) {
6913
- $testcaseBranchData -> append($line ,
6914
- $block , $b , $filename );
6915
- }
6916
- ++$branchId ;
6917
- }
6918
- }
6919
- }
6920
- } # end "if (! rtl)"
6921
6878
if ($lcovutil::func_coverage ) {
6922
6879
6923
6880
if ($funcdata != $functionMap ) {
@@ -6996,6 +6953,10 @@ sub write_info_file($$$)
6996
6953
{
6997
6954
my ($self , $filename , $do_checksum ) = @_ ;
6998
6955
6956
+ if ($self -> empty()) {
6957
+ lcovutil::ignorable_error($lcovutil::ERROR_EMPTY ,
6958
+ " coverage DB is empty" );
6959
+ }
6999
6960
my $file = InOutFile-> out($filename );
7000
6961
my $hdl = $file -> hdl();
7001
6962
$self -> write_info($hdl , $do_checksum );
0 commit comments