CLion EAP 2020.2: Makefile Projects in CLion, Doctest Support, More Accurate Code Analysis Checks

Posted on by Anastasia Kazakova

Hi,

Last week we launched CLion 2020.2 EAP. The first EAP build included dozens of fixes across several areas, including performance improvements, unit testing tuning, VS toolchain debugger enhancements, an update in the PlatformIO plugin, and fully manageable GitHub Pull Requests right in the IDE. The second 2020.2 EAP build is now ready, and we’re sure you’re going to like it!

Build 202.5428.21 is available from our website, via the Toolbox App, or as a snap package (if you are using Ubuntu). A patch-update is ready for anyone using the previous 2020.2 EAP build:

DOWNLOAD CLION 2020.2 EAP

The changes implemented in this build are so enormous that we’ve had to split them up into three blog posts just to cover all the updates. We have three big things for you to preview in this build:

Simplify and loop conditions code analysis check

In this EAP build, we’ve updated two useful code inspections to work more accurately on C++ code.

Code can often be simplified but it’s not always easy to see how. CLion will show you! In 2020.2 EAP we implemented a massive overhaul of the Simplify code inspection – we moved it to our Clangd-based engine to increase its accuracy and have added more use cases for it to cover.

The inspection can now simplify these types of statements:

  • condition == true.
  • condition1? true : condition2.
  • if(condition1) return true; return condition2;
  • Statements for identical branches.

Simplify if(true) and while(false) is also possible. If you feel the inspection is too annoying in your code, turn this case off in the inspection’s options: Settings/Preferences | Editor | Inspections | C/C++ | General | Simplifiable statement.

This might sound like it should have been simple, but if you add macros and templates into the equation, things soon become more complicated.
Simplify quick-fix

The inspection is configured in Settings/Preferences | Editor | Inspections | C/C++ | General | Simplifiable statement.

Another incredibly useful inspection is the Loop condition is never updated, which detects situations where a loop condition is not updated inside the loop. Situations like these can cause an infinite loop, which is not usually the desired outcome. This code inspection now uses Data Flow Analysis (which was moved to our Clangd-based engine in v2020.1).

You might already know that there is a very similar inspection in Clang-Tidy – clang-tidy:bugprone-infinite-loop. However, it doesn’t work for loops with exit points and throws up false positives in cases with lambdas or references. CLion’s own inspection is based on DFA and is intended to be more reliable in all these scenarios. If this proves to be the case, we’ll later disable the Clang-Tidy check in the default inspection profiler (CPP-20575).
Loop conditions checks

Full release notes are available, as usual, as a list. And you are welcome to provide us with your feedback using our tracker or in the comments section below.

DOWNLOAD CLION 2020.2 EAP

Your CLion team
JetBrains
The Drive to Develop

Comments below can no longer be edited.

3 Responses to CLion EAP 2020.2: Makefile Projects in CLion, Doctest Support, More Accurate Code Analysis Checks

  1. Helge Penne says:

    June 16, 2020

    This EAP build (and the previous one) breaks clang-tidy error highlighting for us. Our files are littered with hundreds of false positives of the type:
    Clang-Tidy: ‘someSymbolOrOperator’ must resolve to a function declared within the ‘__llvm_libc’ namespace.

    There are such a huge number of these that error highlighting is no longer usable. We will probably need to avoid the EAPs until this is fixed.

    I can’t file a bug report for this at the moment, as your bug tracker website is no longer on our whitelist for some strange reason.

    • Anastasia Kazakova says:

      June 16, 2020

      This inspection is turned OFF in the CLion’s default config. So you are likely using some non-default settings which allow this check. Or you have Clang-tidy config enabled instead of CLion’s own settings. Check in Settings/Preferences | Editor | Inspections | C/C++ | General | Clang-Tidy | Prefer .clang-tidy files over IDE settings.
      We are considering how to make this situation easier detectable in CLion (for this particular warning or in general) https://youtrack.jetbrains.com/issue/CPP-20634

      • Helge Penne says:

        June 16, 2020

        Aha. The warnings seemed so strange and meaningless that I assumed this was some kind of bug. It might still might be (hard to tell as the clang-tidy doc for this warning isn’t really very helpful), but at least I am able to turn this warning off in our .clang-tidy configuration file.

Subscribe

Subscribe for updates