CLion 2017.2 released: Clang-Tidy, Force Step Into, better C++ support and performance improvements
Please welcome the new release of your favorite cross-platform C/C++ IDE – CLion 2017.2! Focusing on C++ correctness and performance improvements, it also brings Clang-Tidy integration to expand the number of code analysis checks, a better way to get disassembly view, and lots of bug fixes and other improvements.
Read on for details and get a free 30-day trial to evaluate all the new features and enhancements:
- Integration with Clang-Tidy
- C++ parser and code analysis improvements
- PCH support in case of Microsoft Visual C++ compiler
- C++17 in the New Project wizard
- Force Step Into for disassembly code and debugger fixes
- Google Test configurations for targets linked with gmock
- Non-project files notification
- Performance improvements
- Find in Path UI enhancements
- VCS changes: Git Revert, Reword, updated commit message settings and quick-fixes
Better code quality: Clang-Tidy integration
CLion has 30+ built-in code inspections to alert users to unused code, incompatible types, wrong declaration order, uninitialized variables and so forth. It also performs Data Flow Analysis to catch infinite recursion, endless loops, missing returns, and unreachable code. To expand the list of checks and help you ensure better code quality, we’ve integrated Clang-Tidy into CLion 2017.2.
In CLion Clang-Tidy checks are shown the same way as CLion’s own built-in code inspections, and quick-fixes are also available via
Clang-Tidy’s list of checks is long and impressive, and CLion got most of them enabled by default. To customize the list of checks and tweak it to your needs, as well as company policies and standards, go to Settings/Preferences | Editor | Inspections | C/C++ | General | Clang-Tidy settings and use the text-formed string in the Clang-Tidy command line format:
Enable C++ Core Guidelines or Clang Static Analyzer checks, try Modernize checks and many others. It’s even possible to add your own checks to Clang-Tidy and get them automatically in CLion. However, be sure to use JetBrains’ fork of Clang-Tidy (LLVM, Clang, Clang Tools)
until our patches for the output format and response files (patch 1, patch 2 part 1, patch 2 part 2) are accepted into LLVM master.
To read more about the integration and our plans for expanding it, see this blog post.
CLion 2017.2.2 EAP comes with an easier way to disable particular checks, as well as compatibility with Clang-Tidy from LLVM master. Read more.
More accurate C++ parser and enhanced quick-fixes
Looking ahead, we’re planning a major overhaul of CLion’s C++ parser. Starting from bottom to top, we will ensure it is correct on each level, unmasking hidden problems on the way. Some work has already been done.
At the same time, CLion 2017.2 brings dozens of fixes in various parts of the C++ parsing and resolving engine. From the user perspective, it means a reduced number of false-positive code analysis checks, more accurate navigation, refactorings, and other benefits.
If you are interested in the full list of fixes, please see our tracker.
In addition, CLion 2017.2 comes with a new quick-fix to preserve non-trivial constructor calls on an unused variable. It can be used for the cases when constructor still does some useful work:
Besides, when the cast is needed in C++ code, CLion now suggests C++ type casts (
const_cast) instead of C-style casts:
You can turn this behaviour off in Settings/Preferences | Editor | Code Style | C/C++ | Code Generation | C++, if necessary.
PCH for Microsoft Visual C++ compiler
If you use CLion’s experimental support for Microsoft Visual C++ compiler, you’ll be glad to learn that precompiled headers are now supported for this case (in addition to previously supported GCC and Clang). Note there are some limitations to keep in mind.
Easy start with C++17
C++17 will be officially signed later this year, but as we see, many C++ developers have already moved to it or at least plan to do so. That’s why we’ve added C++17 to the list of standards in the New Project wizard. This means CLion will automatically add
set(CMAKE_CXX_STANDARD 17) to the CMakeLists.txt generated for the new project.
Force Step Into for disassembly view
Disassembly view (for GDB) was recently added to CLion 2017.1, and now we’re adjusting its behavior based on your feedback. Some users have been facing the problem of getting into disassembly code unexpectedly, whereas they would prefer to simply skip all the frames without sources. That’s why we’ve relocated the functionality to the Force Step Into
Shift+Alt+F7 action, while the usual Step Into
F7 skips the frames without sources. We hope this makes the feature easier to use and more intuitive.
Besides, the name of the tab with the disassembly view was updated to show the name of the currently running configuration:
Note, that on macOS (when using GDB) Step Into still falls into disassembly view on
std function calls and in some other cases (CPP-10181).
To improve the debugging process in CLion, this release comes with some important enhancements and fixes.
To inspect elements of array with big indexes without constantly clicking Expand to the next 50 elements, you can adjust the value cidr.debugger.value.maxChildren in the Registry. (Open the Find Action dialog (
Shift+Ctrl+A on Linux/Windows,
⇧⌘A on macOS), type Registry, and then type cidr.debugger.value.maxChildren in the Registry to search for the setting.) However, remember that this change may lead to increased timeouts during array evaluation while debugging and may affect the IDE in general (beyond your current debug session or project).
Other fixes implemented in the GDB driver include:
- Command time out when trying to attach to a non-existent local process
- Incorrectly escaped backslashes in program arguments on Windows
Automatic Run/Debug configurations for Google Test
To perform unit tests with ease, CLion provides a built-in test runner that allows you to rerun tests/failed tests in one click, export results, navigate to the sources, and view the results in a tree view. To get the test results there, a special Run/Debug configuration should be used. For Google Test it can be created automatically by CLion for every target linked with gtest, and now with gmock.
Non-project files (files that do not belong to any CMake target) can now be identified easily in the editor, thanks to the the new file-wide notification:
For CLion it means that code insight features should be limited in such files, for example refactorings should not be performed.
It might be useful to know, that when you create new C++ class or C/C++ source or header file CLion suggests to add a new file to CMake target and suggests most probable options to select from. Use this feature to get all your new files included into CMake targets.
Our team is constantly working on performance improvements, doing our best to make the IDE responsive and effective. Thanks to many CPU snapshots, logs and sample projects that you’ve shared with us via tech support and the CLion tracker, we can identify the areas that can be improved and make the appropriate changes.
The first performance enhancement in CLion 2017.2 is cancelable actions. The idea is to use them where possible to prevent time-consuming operations from freezing the IDE. This time we’ve updated Go to subclass and Go to overridden functions actions, which build a list of options and can require quite a lot of time to finish. To cancel the action, simply click to the area out of the navigation popup:
Another time-consuming operation is CMake reload. You can now cancel it at any time, by simply clicking the Stop button in the CMake tool window. The output logs were updated to get the indication of successfully finished reload (to distinguish from a canceled run):
Among other performance-related changes:
- We’ve fixed laggy Enter and Backspace on some projects (for example, when the caret enters a new block, moves to a new line, or causes a code indent).
- We’ve shortened indexing time by optimizing the way compiler-predefined macros are parsed in CLion.
Find in Path UI enhancements
In version 2017.1, the Find in Path window turned into a convenient and compact popup with immediate preview. CLion 2017.2 brings several improvements to make the UI more functional:
- A left-side gutter is now available in the preview, with navigation icons, and markers for local changes.
- To make the preview even more compact, results from the same line are merged into one line in the preview panel.
Do more with new VCS features
Thanks to IntelliJ Platform, this release brings lots of improvements for Version Control Support:
- If you need to revert some commits, select them and run the Git command Revert from the Git Log view.
- To fix a typo in a commit message, or just to update it, use the Reword action (applicable to any commit that has not been pushed yet).
- To keep commit messages easy to read and expressive, use new Preferences/Settings | Version Control | Commit Dialog settings. Configure whether to have a blank line between subject and body, set maximum text length, and check the spelling in your comments.
- A quick-fix and the Reformat action are available in commit messages:
Your CLion Team
The Drive to Develop