@@ -61,7 +61,7 @@ if( $^O eq "msys" )
61
61
}
62
62
63
63
# Constants
64
- our $lcov_version = ' LCOV version 1.11 pre (CVS $Revision: 1.126 $)' ;
64
+ our $lcov_version = ' LCOV version 1.11 pre (CVS $Revision: 1.127 $)' ;
65
65
our $lcov_url = " http://ltp.sourceforge.net/coverage/lcov.php" ;
66
66
our $gcov_tool = " gcov" ;
67
67
our $tool_name = basename($0 );
@@ -1894,9 +1894,14 @@ sub get_gcov_version()
1894
1894
my $version_string ;
1895
1895
my $result ;
1896
1896
1897
- open (GCOV_PIPE, " -|" , " $gcov_tool -v " )
1897
+ open (GCOV_PIPE, " -|" , " $gcov_tool --version " )
1898
1898
or die (" ERROR: cannot retrieve gcov version!\n " );
1899
1899
$version_string = <GCOV_PIPE>;
1900
+ # LLVM gcov keeps version information on the second line.
1901
+ # For example, gcov --version yields:
1902
+ # LLVM (http://llvm.org/):
1903
+ # LLVM version 3.4svn
1904
+ $version_string = <GCOV_PIPE> if ($version_string =~ / LLVM/ );
1900
1905
close (GCOV_PIPE);
1901
1906
1902
1907
# Remove version information in parenthesis to cope with the following:
@@ -1918,6 +1923,21 @@ sub get_gcov_version()
1918
1923
$result = $1 << 16 | $2 << 8;
1919
1924
}
1920
1925
}
1926
+ if ($version_string =~ / LLVM/ )
1927
+ {
1928
+ # Map LLVM versions to the version of GCC gcov which
1929
+ # they emulate
1930
+ if ($result >= 0x030400)
1931
+ {
1932
+ info(" Found LLVM gcov version 3.4, which emulates gcov version 4.2\n " );
1933
+ $result = 0x040200;
1934
+ }
1935
+ else
1936
+ {
1937
+ warn (" This version of LLVM's gcov is unknown. Assuming it emulates GCC gcov version 4.2.\n " );
1938
+ $result = 0x040200;
1939
+ }
1940
+ }
1921
1941
return ($result , $version_string );
1922
1942
}
1923
1943
@@ -3496,15 +3516,36 @@ sub get_gcov_capabilities()
3496
3516
{
3497
3517
my $help = ` $gcov_tool --help` ;
3498
3518
my %capabilities ;
3519
+ my %short_option_translations = (
3520
+ ' a' => ' all-blocks' ,
3521
+ ' b' => ' branch-probabilities' ,
3522
+ ' c' => ' branch-counts' ,
3523
+ ' f' => ' function-summaries' ,
3524
+ ' h' => ' help' ,
3525
+ ' l' => ' long-file-names' ,
3526
+ ' n' => ' no-output' ,
3527
+ ' o' => ' object-directory' ,
3528
+ ' p' => ' preserve-paths' ,
3529
+ ' u' => ' unconditional-branches' ,
3530
+ ' v' => ' version' ,
3531
+ );
3499
3532
3500
3533
foreach (split (/ \n / , $help )) {
3501
- next if (!/--(\S+)/);
3502
- next if ($1 eq ' help' );
3503
- next if ($1 eq ' version' );
3504
- next if ($1 eq ' object-directory' );
3534
+ my $capability ;
3535
+ if (/ --(\S +)/ ) {
3536
+ $capability = $1 ;
3537
+ } else {
3538
+ # If the line provides a short option, translate it.
3539
+ next if (!/^\s *-(\S)\s /);
3540
+ $capability = $short_option_translations {$1 };
3541
+ next if not defined ($capability );
3542
+ }
3543
+ next if ($capability eq ' help' );
3544
+ next if ($capability eq ' version' );
3545
+ next if ($capability eq ' object-directory' );
3505
3546
3506
- $capabilities {$1 } = 1;
3507
- debug(" gcov has capability '$1 '\n " );
3547
+ $capabilities {$capability } = 1;
3548
+ debug(" gcov has capability '$capability '\n " );
3508
3549
}
3509
3550
3510
3551
return \%capabilities ;
0 commit comments