LLVM2LCOV(1) LCOV LLVM2LCOV(1)

# [NAME](#NAME)

llvm2lcov - llvm2lcov documentation

[**Manual section**](#Manual)

1

[**Manual group**](#Manual~2)

LCOV Tools

# [NAME](#NAME~2)

[**llvm2lcov**](#llvm2lcov)

Translate LLVM coverage data from **llvm-cov** profdata to LCOV format

# [SYNOPSIS](#SYNOPSIS)

```
llvm2lcov [--output filename] [--testname name] [options] json_file [json_file ...]
```

# [DESCRIPTION](#DESCRIPTION)

**llvm2lcov** traverses C/C++ coverage data in JSON format (generated by **llvm-cov export -format=text ...**) and translates it into LCOV **.info** format.

Note that LLVM supports two coverage data collection paths: the one described in this page - based on profile data - and a *gcov path* - similar to that supported by **gcc**. See the LLVM documentation for more details about the **gcov** support in LLVM.

# [MC/DC COVERAGE](#MC/DC_COVERAGE)

To generate MC/DC data:

- Use LLVM 18 or newer (LLVM 21+ recommended for cleaner MC/DC data)
- Enable MC/DC instrumentation in compile/link steps with **-fcoverage-mcdc**
- Pass the **--mcdc-coverage** flag to **llvm2lcov**

Note that LLVM does not support MC/DC metrics when using the **gcov** data collection path.

# [OPTIONS](#OPTIONS)

In addition to common options supported by other tools in the LCOV suite (*e.g.*, **--comment**, **--version-script**, **--ignore-error**, **--substitute**, **--exclude**, *etc.*), the tool provides the following options:

[**--output *filename*, -o *filename***](#output)

The LCOV data will be written to the specified file. If this option is not used, data is written to **llvm2lcov.info** in the current directory.

[**--testname *name*, -t *name***](#testname)

Coverage info will be associated with the testcase name provided. It is not necessary to provide a name.

[**--branch-coverage**](#branch)

Include branch coverage data in the output.

[**--mcdc-coverage**](#mcdc)

Include MC/DC data in the output. Requires LLVM 18 or higher with MC/DC instrumentation enabled during compilation.

See **[lcov(1)](/man/os/lcov/lcov.1) &lt;file://../man/lcov.1.html&gt;** and **[lcovrc(5)](/man/os/lcov/lcovrc.5) &lt;file://../man/lcovrc.5.html&gt;** for details of other options and configuration settings.

# [EXAMPLES](#EXAMPLES)

Basic workflow:

```
# 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 ...
```

(**...** indicates other tool options that you might be using - *e.g.*, for filtering and exclusion.)

Executing the same example via **gcov** looks like:

```
# 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 ...
```

# [AUTHOR](#AUTHOR)

Henry Cox &lt;&lt;henry.cox@mediatek.com&gt;&gt;

# [SEE ALSO](#SEE_ALSO)

**[lcov(1)](/man/os/lcov/lcov.1) &lt;file://../man/lcov.1.html&gt;**, **[genhtml(1)](/man/os/lcov/genhtml.1) &lt;file://../man/genhtml.1.html&gt;**, **[geninfo(1)](/man/os/lcov/geninfo.1) &lt;file://../man/geninfo.1.html&gt;**, **[lcovrc(5)](/man/os/lcov/lcovrc.5) &lt;file://../man/lcovrc.5.html&gt;**,

- LLVM documentation: &lt;https://llvm.org/docs/CoverageMappingFormat.html&gt;
- **llvm-cov** documentation: &lt;https://llvm.org/docs/CommandGuide/llvm-cov.html&gt;

# [Copyright](#Copyright)

2024-2026, LCOV Project

2026-07-07 2.5

---

Document: llvm2lcov(1) from lcov 2.5-r1 (Chainguard OS)
Source: https://github.com/linux-test-project/lcov
