Early Access Program News

CLion 2019.3 EAP: Code Coverage and CMake Defaults

Hi,

A new CLion 2019.3 EAP (build 193.4932.12) is now available! Get it from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu). A patch-update for anyone using the previous EAP build will be available shortly.

DOWNLOAD CLION 2019.3 EAP

Key highlights:

Code Coverage

Code coverage in CLion relies on llvm-cov/gcov integration to perform and show you statements coverage measuring for your code. In general, statements coverage answers the question, "Was this statement executed during the configuration run?". The configuration can be either a unit tests run or a regular configuration run.

How to launch a configuration with coverage?

To get coverage measurement, you have to pass special coverage compile options. There are a few options depending on what compiler you use and what kind of results you expect:

  • -fprofile-arcs -ftest-coverage or an equivalent --coverage – for GCC (uses gcov) and Clang (uses llvm-cov gcov, gcov-style coverage, which means it will compatible with the gcov tool from version 4.2 of GCC)
  • -fprofile-instr-generate -fcoverage-mapping – for Clang (uses llvm-profdata merge / llvm-cov export, a clang’s instrumentation based profiling).

For example, if you use both GCC and Clang in your project, you may have something like this in your CMakeLists.txt:
coverage_cmake

Now you can run it using the run icon in the left gutter:
coverage_run

Or you can click the “Run … with Coverage” button coverage_icon in the Navigation Bar.

How to read the results

Coverage measurements are located in the Coverage tool window, which shows results per folder (% of files and % of lines covered) and per file (% of lines covered):
coverage_results

When rerunning the coverage analysis, CLion will ask you how you’d like the results presented:

  • Add to active suites – to enrich the current results.
  • Replace active suites – to start from scratch.
  • Do not apply collected coverage data – to simply ignore the current results.

Another way of exploring the results is to check the color indication in the left gutter in the editor.
coverage_indication_gutter

Click the gutter area to see how many times the line was hit.

Configuration and known issue

Coverage settings, including custom paths to gcov / llvm-cov / llvm-profdata tools and more, can be found in Settings/Preferences | Build, Execution, Deployment | Coverage:
coverage_settings

A few important known issues are worth mentioning:

  • Code coverage doesn’t work with Ninja generator (CPP-17864). We’ll do our best to address this issue before the release.
  • Code Coverage is not supported for the remote toolchain (CPP-17709).
  • Generate Coverage Report – an action you may be familiar with if you use IntelliJ IDEA – is not available yet (CPP-17710).

Other bugs and requests are linked to the parent ticket, CPP-9678. Please try the EAP build with code coverage support and share your feedback with us!

CMake defaults

If you have to work with a lot of new projects in CLion, you may want to simplify the process of configuring CMake Profiles, for example by configuring a common pattern for the CMake generation folder.

Starting with this EAP, you can configure one or several default CMake Profiles which will be used for all your new CLion projects! Use File | Other Settings | Settings/Preferences for New Projects…:
cmake_settings

You can set the default:

  • Generator used in CMake
  • Options passed to CMake
  • Toolchain
  • Build type
  • Environment
  • Generation path
  • Build options

When a new project is started, these default CMake Profiles will be used. Note that currently, this doesn’t apply when File | New CMake Project from Sources is used (CPP-17686).

That’s it for today! The full release notes are available here.

DOWNLOAD CLION 2019.3 EAP

Your CLion Team
JetBrains
The Drive to Develop

image description

Discover more