CLion EAP 2020.2: Makefile Projects in CLion, Doctest Support, More Accurate Code Analysis Checks
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:
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:
- Part 0: Simplify and loop condition checks are now more accurate (this blog post).
- Part 1: The prototype Makefile project support is now public!
- Part 2: Doctest joins Google Test, Boost.Test and Catch(2) in the list of supported frameworks.
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.
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).
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.
Your CLion team
JetBrains
The Drive to Develop