Clion logo

The CLion Blog

A Cross-Platform IDE for C and C++

Early Access Program News

CLion 2021.1 EAP: Branch Coverage, New MISRA Checks, and Remote Makefile projects

A new CLion 2021.1 EAP build (211.6305.15) is now available from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu). Note that if you are on macOS, there is a separate build for Apple Silicon (M1 chip).

DOWNLOAD CLION 2021.1 EAP

Here are the main highlights:

Branch Coverage

If you ever ask yourself how well your code is covered with tests, code coverage tools may help answer the question. Code coverage integration in CLion is available on all three platforms (Linux, macOS, and Windows) and with any toolchain (local, remote, or WSL), but only for CMake projects.

When you measure your code coverage, there are several criteria and approaches to how to do it. Previously, CLion was only able to measure Line Coverage (for GCC and gcov) and Statement Coverage (LLVM and llvm-cov). It showed how many lines/statements in your code (in %) were executed while running the tests.

But now, starting with this 2021.1 build, CLion can also show Branch Coverage. It takes into account all the branches of each control structure. For example, given an if statement, it can tell you if both the true and false branches have been executed.

In the CLion UI, this is displayed in the Code Coverage tool window, in the column next to the Line Coverage:

Branch Coverage results

Please note that branch coverage is supported for LLVM version 12.0.0 and higher and for any version of GCC. It’s enabled by default in Settings/Preferences | Build, Execution, Deployment | Coverage. However it does nothing if your LLVM is older than 12.0.0:

Coverage settings

It is also important to note that GCC and the gcov tool consider the compiler-generated branches when calculating branch coverage. This might affect the results if, for example, you use exception handling.

We’d like to thank zero9178, the author of the 3rd-party plugin C/C++ Coverage for CLion, who inspired us to add Branch Coverage to CLion.

Move execution point in disassembly view

The Set Execution Point action lets you jump to an arbitrary line of code in the editor during a debug session and set the execution point there, skipping all the other commands in between. It now works in the disassembly view, so you can move the execution point while stepping through the assembly code.

New MISRA C and C++ checks

We’re continuing to add MISRA C and C++ checks to CLion. A table with all supported checks can be found here. This time we added such fixes as:

  • The unary & operator shall not be overloaded
  • A pointer to a virtual base class shall only be cast to a pointer to a derived class by means of dynamic_cast
  • The statement forming the body of a switch, while, do … while or for statement shall be a compound statement
  • and a few others.

If you endeavor to comply with MISRA C or MISRA C++ guidelines in your project, please let us know if you find the CLion checks helpful. Thank you!

Initial support for Remote Makefile projects

CLion now comes with support for Makefile projects with remote toolchains. They previously didn’t work together, as the full remote mode was only supported for CMake projects. But starting with this 2021.1 EAP build, CLion can handle remote Makefile projects! There are still a few limitations for it, so read on before giving it a try.

Like before, you can work on a macOS, Linux, or Windows desktop targeting a remote Linux machine connected via SSH, and the project source code should be located on the local machine. The CLion instance runs locally and synchronizes the source code to the remote machine, where it performs compilation using host compilers. You can run and debug your application or unit tests on a remote machine from the locally running CLion.

To make it work for your Makefile project:

  1. Change the toolchain used by your Makefile project in Settings/Preferences | Build, Execution, Deployment | Makefile to a remote one configured in Settings/Preferences | Build, Execution, Deployment | Toolchains.
  2. Call Tools | Makefile | Clean and Reload Makefile Project.

CLion will synchronize the project with the remote machine and will reload it for you:

Remote Makefile

In the example above, we loaded an Mbed TLS project on our remote Linux machine from a Mac.

Known issues and limitations:

  • Remote Makefile projects are only supported when Makefile is present in the project directory. If, for example, a pre-configure step is required, CLion can’t automate it for now (CPP-16924).
  • The toolchain update in the settings doesn’t trigger an automatic project reload. This is something we plan to address in the future (CPP-18982).
  • We recommend using Tools | Makefile | Clean and Reload Makefile Project and not Tools | Makefile | Reload Makefile Project as there are some occasional issues with the command cache.
  • When uploading a Makefile project to a remote machine, CLion uses a directory containing the Makefile as a project root (CPP-23995). If you have Makefile located in a different subdirectory, you need to update the path mappings in the Deployment settings (Settings/Preferences | Build, Execution, Deployment | Deployment) – changing the local path to the correct project root.

A new Open Remote Host Terminal action

Sometimes when working with a remote project in CLion, you might want to open ssh to the remote host and execute some command in the project directory. Tools | Start SSH Session… can help you with that, but it won’t open the current project directory on a remote host by default. So we’ve added a new Tools | Open Remote Host Terminal action to do exactly that – it opens the project directory on the remote host if it exists. The remote host corresponds to the currently selected remote profile, or, if a local one is selected, the first remote profile found in the project:

Open Remote Host

The action works for both remote CMake and remote Makefile projects supported currently in CLion.

We’ve also improved performance for the CMake load step when a remote toolchain is used (CPP-17421). The full release notes are available here.

DOWNLOAD CLION 2021.1 EAP

Your CLion team
JetBrains
The Drive to Develop

Discover more