Skip to content

Commit aaf066a

Browse files
committed
llvm2lcov: translate from 'llvm-cov' JSON to LCOV format.
Primary use is to support MC/DC - which is not currently supported by 'llvm-cov export -format=lcov' or 'llvm-cov gcov'. Signed-off-by: Henry Cox <[email protected]>
1 parent 2d450cd commit aaf066a

File tree

14 files changed

+764
-39
lines changed

14 files changed

+764
-39
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ FILES := README Makefile lcovrc \
6666
DIST_CONTENT := CONTRIBUTING COPYING README Makefile lcovrc \
6767
bin example lib man rpm scripts tests
6868

69-
EXES = lcov genhtml geninfo genpng gendesc perl2lcov py2lcov xml2lcov xml2lcovutil.py
69+
EXES = \
70+
lcov genhtml geninfo genpng gendesc \
71+
perl2lcov py2lcov xml2lcov xml2lcovutil.py \
72+
llvm2lcov
7073
# there may be both public and non-public user scripts - so lets not show
7174
# any of their names
7275
SCRIPTS = $(shell ls scripts | grep -v -E '([\#\~]|\.orig|\.bak|\.BAK)' )

README

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-------------------------------------------------
22
- README file for the LTP GCOV extension (LCOV) -
3-
- Last changes: 2024-11-12
3+
- Last changes: 2024-11-20
44
-------------------------------------------------
55

66
Description
@@ -59,6 +59,7 @@ Further README contents
5959
bin/genhtml - Tool for creating HTML output from LCOV data
6060
bin/gendesc - Tool for creating description files as used by genhtml
6161
bin/perl2lcov - Tool to translate Perl Devel::Cover data to lcov format
62+
bin/llvm2lcov - Tool to translate LLVM 'llvm-cov' JSON data to LCOV format
6263
bin/py2lcov - Tool to translate Python Coverage.py to lcov format
6364
bin/xml2lcov - Tool to translate Cobertura-like XML coverage data
6465
to lcov format
@@ -437,9 +438,18 @@ New features and capabilities fall into 7 major categories:
437438

438439
Related options: --parallel, --memory, --profile
439440

440-
g) Language support
441+
g) Language/tool support
441442

442-
Added 'py2lcov', 'perl2lcov' and 'xml2lcov' scripts.
443+
Added 'llvm2lcov', 'py2lcov', 'perl2lcov' and 'xml2lcov' scripts.
444+
445+
- llvm2lcov:
446+
447+
translates JSON coverage data generated by 'llvm-cov export -format=text ...'
448+
to lcov format.
449+
450+
See "llvm2lcov --help" for brief instruction on how to use the
451+
translator. Note tha llvm2lcov uses a similar set of command line
452+
and configuration file options as lcov, genhtml, and geninfo.
443453

444454
- py2lcov:
445455

bin/geninfo

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,17 +2392,8 @@ sub read_intermediate_text($$)
23922392
sub read_intermediate_json($$$)
23932393
{
23942394
my ($gcov_filename, $data, $basedir_ref) = @_;
2395-
my $text;
2396-
2397-
{
2398-
# intermediate JSON contains the demangled name
2399-
my $f = InOutFile->in($gcov_filename);
2400-
my $h = $f->hdl();
2401-
my @lines = <$h>;
2402-
$text = join("\n", @lines);
2403-
}
2404-
2405-
my $json = JsonSupport::decode($text); # imported from lcovutil.pm
2395+
# intermediate JSON contains the demangled name
2396+
my $json = JsonSupport::load($gcov_filename); # imported from lcovutil.pm
24062397
if (!defined($json) ||
24072398
!exists($json->{"files"}) ||
24082399
ref($json->{"files"} ne "ARRAY")) {

0 commit comments

Comments
 (0)