LLVM2LCOV(1)
π LLVM2LCOV(1) β the LCOV tools girlies β¨
okay so first things first, this is a page from the LCOV Tools manual group, and it lives in Manual section 1. The tool itself is llvm2lcov, and if you only remember one thing about it, remember this: it translates LLVM coverage data from llvm-cov profdata into LCOV format. that's the whole vibe. π
πΈ NAME πΈ
llvm2lcov β literally just the docs for llvm2lcov, bestie. and like, what does it do? it translates LLVM coverage data from llvm-cov profdata to LCOV format. iconic behavior honestly. π
β¨ SYNOPSIS β¨
llvm2lcov [--output filename] [--testname name] [options] json_file [json_file ...]
π¦ DESCRIPTION π¦
so llvm2lcov goes wandering through your C/C++ coverage data in JSON format (the kind that comes out of llvm-cov export -format=text ...) and translates all of it into LCOV .info format. slay. that's the job. π
okay but real talk, heads up: LLVM has two coverage data collection paths, and they are not the same thing, no cap:
- the one this page is about β the profile data path
- a gcov path β basically the same kind of thing
gccsupports
if you wanna know more about the gcov support in LLVM, go check the LLVM documentation. iykyk. π
π MC/DC COVERAGE π
want MC/DC data? bet. here's the recipe:
- Use LLVM 18 or newer (LLVM 21+ recommended for cleaner MC/DC data) β newer is giving cleaner vibes, trust.
- Enable MC/DC instrumentation in your compile/link steps with
-fcoverage-mcdc - Pass the
--mcdc-coverageflag tollvm2lcov
β οΈ also important: LLVM does not support MC/DC metrics when using the gcov data collection path. so don't try it. it's not happening. π
π§ OPTIONS π§
on top of all the common options the other tools in the LCOV suite support (think --comment, --version-script, --ignore-error, --substitute, --exclude, etc. β you know the ones), this tool also serves these:
--output filename,-o filenameβ your LCOV data gets written to the file you name here. skip this option and it'll just drop it inllvm2lcov.infoin whatever your current directory is. default behavior, cute. π--testname name,-t nameβ associates your coverage info with the testcase name you give it. and honestly? it's not necessary to provide a name. no pressure bestie, optional. π--branch-coverageβ include branch coverage data in the output. go off. πΏ--mcdc-coverageβ include MC/DC data in the output. requires LLVM 18 or higher, with MC/DC instrumentation enabled during compilation. don't forget that part. π₯
for the deets on the other options and configuration settings, go look at lcov(1) and lcovrc(5). they got you. π«Ά
β EXAMPLES β
basic workflow β the full glow-up pipeline:
# Compile with coverage instrumentation (including MC/DC)
$ clang++ -o myExe -fprofile-inst-generate -fcoverage-mapping \
-fcoverage-mcdc myCode.cpp
# Run your testcases
$ ./myExe ...
# Convert profile data
$ llvm-profdata merge -o myExe.profdata --sparse *.profraw
# Export coverage data in JSON format
$ llvm-cov export -format=text -instr-profile=myExe.profdata \
./myExe > myExe.json
# Convert to LCOV format
$ llvm2lcov --output myExe.info --test-name myTestcase \
--mcdc-coverage --branch-coverage myExe.json ...
# Generate HTML coverage report
$ genhtml -o html_report myExe.info ...
(those ... are just other tool options you might be using β like for filtering and exclusion. not me forgetting them, they're literally placeholders π
)
and doing the same example via gcov? it looks like this:
# Compile with gcov instrumentation
$ clang++ -o myExe --coverage myCode.cpp
# Run your testcases
$ ./myExe ...
# Convert to LCOV format
# Note that the '--gcov-tool' option appears *twice*: once to name
# the tool and once to pass a tool option. See the lcov man page
# for more information.
$ lcov --capture -d . --branch-coverage -o myExe.info --gcov-tool llvm-cov --gcov-tool gcov ...
# Generate HTML coverage report
$ genhtml -o html_report myExe.info ...
π yes,--gcov-toolshows up twice β once to name the tool and once to pass a tool option. that's not a typo, that's the assignment. thelcovman page has more if you need it.
π AUTHOR π
Henry Cox <<henry.cox@mediatek.com>> β the main character who wrote this. we stan. π
π₯ SEE ALSO π₯
lcov(1)genhtml(1)geninfo(1)lcovrc(5)- LLVM documentation:
https://llvm.org/docs/CoverageMappingFormat.html llvm-covdocumentation:https://llvm.org/docs/CommandGuide/llvm-cov.html
π COPYRIGHT π
Copyright 2024-2026, LCOV Project. all rights reserved, respectfully. π
and that's the whole page bestie β¨ this was version 2.6, dated 2026-10-03, and yes it's the LLVM2LCOV(1) page β go forth and get those coverage numbers up, you absolute legend π¦
π¦ where this page comes from
- arch rolling: lcov 2.6-1 Β· GPL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms