Early Access Program News

CLion starts 2017.2 EAP with Clang-Tidy integration

Hi everyone,

CLion_20172EAP@2x_splash
Great news – CLion 2017.2 EAP starts now!
We had a lot of work planned for this iteration, and especially one thing that was nearly ready for 2017.1 but got postponed in the end as it required more thoughtful development and testing. Today as a part of the 2017.2 EAP (build 172.1572.3), we give you Clang-Tidy integration!


Download CLion 2017.2 EAP

As usual, you can install it side by side with your current stable CLion version, with no active subscription required.

Please note that EAP builds have been moved to the site for easier search. The confluence page is now obsolete.

Clang-Tidy

Why Clang-Tidy?

As you may know, CLion has its own code analysis tool on board. It runs on the fly, showing warnings as you type and suggesting quick-fixes for detected issues. Built-in code inspections provide checks for unused code, the order of declarations, incompatible types, redundant casts, and many other issues. So why do we need Clang-Tidy? Here are some important reasons:

  • Clang-Tidy is a great tool that provides dozens of valuable checks. Some of them overlap with the CLion’s inspections, while other are unique. The tool also provides quick-fixes in addition to checks.
  • Clang-Tidy is easily extendable, with a convenient API for writing new checks.
  • The list of Clang-Tidy checks now includes checks for the C++ Core Guidelines, which we want CLion users to benefit from.

How it works

Clang-Tidy is now seamlessly integrated into CLion, meaning it simply works as you type in the CLion editor. Clang-Tidy warnings are shown the same way as CLion’s own built-in code inspections. Similarly you can use Alt+Enter to apply Clang-Tidy quick-fixes where available:
ct_modernize

CLion uses its own Clang-Tidy fork, which we are going to make public later. We’ve improved the output format and implemented support for response files passed through the command line. These changes are subject to backporting to Clang-Tidy master (the patches will be prepared soon). When either of the above is done, users will be able to create their own custom Clang-Tidy-based checks in CLion.

Clang-Tidy integration works on all platforms including Linux, Windows and macOS. As for compilers, currently it works for GCC and Clang; MSVC, which is supported in experimental mode for now, has not yet been tested with Clang-Tidy.

ct_google

Settings

Clang-Tidy checks are enabled by default in this EAP build, and are shown as warnings in the editor. Not all the checks are enabled, however; find the default configuration description here. You can customize them in Settings/Preferences | Editor | Inspections | C/C++ | General | Clang-Tidy:

  • Switch on/off Clang-Tidy checks as a whole.
  • Set a severity level (Warning by default) for all the checks at once.
  • Configure the list of checks to enable / disable in text form, by using the Clang-Tidy command line format.

For example, let’s run only C++ Core Guidelines checks on the project. Pass the following line in the settings: -*,cppcoreguidelines-*:
ct-settings

This will result in only C++ Core Guidelines checks running on the project:
ct_cppcoreguide

For Clang Static Analyzer checks, use: -*,clang-analyzer-*. For modernize checks, use: -*,modernize-*. And so on.

The full list of Clang-Tidy checks can be found on their site. CLion’s default configuration is described at our confluence page.

Future plans, known issues and your feedback

There are many things that are not yet there for Clang-Tidy integration:

  • A UI for configuring Clang-Tidy checks is still up for discussion.
  • There is a noticeable delay after a quick-fix is applied and before the warning disappears (CPP-9204).
  • Because the current .clang-tidy formats and options are not supported, the checks that use them are turned off by default.
  • There may be possible bugs in Clang-Tidy itself.

We hope to address the biggest problems in time for the 2017.2 release. Your feedback, typical usage scenarios and probable issues with Clang-Tidy integration would be very helpful! Please share them in our tracker or in the comment section below.

Upd. CLion 2017.2 with Clang-Tidy integration was released. Check the blog post for more details.

And more

Other important changes include:

  • Previously only targets linked with gtest were automatically producing Google Test Run/Debug configurations in CLion. Now gmock is working in the same way as well (CPP-6146).
  • In case there is an unused variable, CLion will suggest you to remove it. In addition, starting from this build new quick-fix was added to preserve non-trivial constructor call on unused variable:
    unused_constr_quick_fix
  • A bug with Rename refactoring renaming another variable with the same name is fixed now (CPP-7251). This also covers the case when name stays in generalized lambda capture (CPP-9286).

Full release notes are available here.


Download CLion 2017.2 EAP

Your CLion Team
The Drive to Develop

image description

Discover more