Release CLion 2017.2: integration with Clang-Tidy, C ++ 17 in the wizard to create a new project, improving the performance of the IDE
Hi, Habr! Summer this year has been disappointing in places (for the CLion team in St. Petersburg for sure), but the new release of CLion 2017.2 , we hope, was a success! In this post we want to talk about new features, important bug fixes, and give you the opportunity to ask questions or ask some specific plans in the comments.
In short, the release of CLion 2017.2 is dedicated to:
Extending the capabilities of the code analyzer (this applies to both built-in and third-party tools - CLang-Tidy)
C ++ 17 in the wizard to create a new project
PCH support for MSVC (we will decipher all abbreviations below!)
Force Step Into in the debugger
Automatically creating the Google Test configurations for tags linked to gmock
Undone asynchronous CMake navigation and load actions
General performance improvements
And much more!
Ready to try now? Download the free 30-day version from our website and go! Need more details? Details below. By the way, you can try all the new features on a small demo project that we have specially prepared for this purpose.
Code analyzer
New quick-fixes and parser correctness improvements
CLion's Quick-fixes allow you to fix potential problems in a one-click code Alt+Enter . In this release we improved some of them. ')
For example, previously it was only possible to delete an unused variable. But, if the constructor of such a variable is nontrivial, then it may not be a completely correct fix. Now CLion offers two options - simply delete the variable or delete the variable and leave the initialization to save the code semantics:
Another improvement is related to type casting . CLion actively points out situations where explicit type casting is needed. But if earlier quick-fixes used only type casting in the C language style, now variants of type casting from C ++ are also static_cast : static_cast , dynamic_cast , reinterpret_cast , const_cast :
Throughout this release cycle, we were actively engaged in fixing bugs in the parser / resolver / code analyzer. There are many changes and they are located in a wide variety of areas:
this and more correct code analysis in the case of std::enable_if ,
and support for va_* macros (the analyzer previously mistakenly marked variables used only in these macros as unused),
and more correct work with functions that accept a package of parameters and still non-template arguments,
and correct work with nested template types in STL containers for GCC 5/6,
and many many others.
You should immediately make a reservation that the next release plan is slightly different. We are planning to rewrite a whole layer of code inside our language support instead of point fixes.
I will not go into much detail, but just to say that we, based on previous experience, analyzed where the most problems were, sorted out these areas from the bottom up and selected those problem areas that underlie the rest. And we will deal with them. By the way, a year ago we were already engaged in such alteration in overload resolution, and user feedback was very positive.
Clang-Tidy integration
In addition to the improvements in the built-in code analyzer, we decided to increase the number of various checks and quick-fixes due to the popular and rapidly developing tool based on Clang - Clang-Tidy . The biggest argument in his favor is the partial support of checks from the C ++ Core Guidelines , which are now actively promoted in the C ++ community of developers by Bjorn Straustrup and Herb Sutter. But this is not his only virtue!
An important argument is the ability to write your own checks and add them to Clang-Tidy.
What is the integration of Clang-Tidy into CLion? For an IDE user, checks from Clang-Tidy look the same as checks from the built-in code analyzer:
That is, errors are highlighted on the fly in the editor, Alt+Enter fixes are available for some checks (quick-fixes).
By default, we have not enabled all checks from Clang-Tidy. Which ones are turned on and which ones are turned off, you can look at our page on confluence . To change the configuration, you need to go to the settings in Settings / Preferences | Editor | Inspections | C / C ++ | General | Clang-Tidy and there use configuration options in the command line format:
For those who have already used Clang-Tidy on their projects, the line will be very familiar - this is the list of enabled / disabled checks that is passed to Clang-Tidy when started from the command line. For example, to include only checks from C ++ Core Guidelines, you need to write -*,cppcoreguidelines-* .
What about your own checks? Similar! Add them to Clang-Tidy, which is used in CLion, and they will automatically appear in the CLion editor. True, to be honest to the end, now there are a couple of subtleties that need to be considered:
Clang-Tidy must be taken from our repository, where the version with our changes is located in order to work correctly with CLion. As soon as our patches are accepted into LLVM (they are now on the review) and the changes get into the master, you can use the main LLVM branch. Learn more about where to look for our repository and which patches can be found on the blog .
The release did not have time to get the UI setting for changing Clang-Tidy, so for now you need to replace the built-in Clang-Tidy binary. But this will be corrected, we hope, in one of the next updates.
C ++ 17 in the wizard to create a new project
The history of this change began with the fact that we included CMake 3.8 in CLion 2017.2. Namely, in this version of CMake, it became possible to indicate the standard version of the language standard in the CMake files - set(CMAKE_CXX_STANDARD 17) - this line is generated by the CLion when creating a new project. And now in the wizard to create a new project in the drop-down list of C ++ standards, an additional item has appeared - C ++ 17.
PCH for MSVC
As I promised, decipher the used abbreviations. CLion's precompiled headers support (that is, the correct rezolv of characters from such files and their correct highlighting in the editor) appeared in the last release. But this does not apply to all compilers, but only for GCC and Clang. Microsoft Visual C ++ compiler (MSVC) has been supported in CLion experimentally also since last release. But it is in the case of MSVC that the use of PCH is necessary and widespread. So we added this support for this case. Some subtleties and limitations are described in the request in the tracker .
Debugger
We have truly Napoleon's debugging plans for CLion, but in this release our goal was to fix bugs and refine the current functionality.
So, after the release of CLion 2017.1, it became clear that it was not very convenient to use the usual Step Into action in order to get to the disassembler code when debugging. Often, users want the usual steps in the CLion debugger to skip all frames for which there is no source code. So now Step Into ( F7 ) works that way; and to get to the code on the disassembler, you should use Force Step Into ( Shift+Alt+F7 ).
Another important change in the debugger is an additional option in the Registry for viewing arrays during debugging . The fact is that to improve performance, CLion loads and shows not the entire array at once, but only a certain number of elements. The default is 50 items. To view the next 50, you must click Expand. And so every 50 items.
Now in Registry, the cidr.debugger.value.maxChildren option is cidr.debugger.value.maxChildren , which is equal to 50 by default and determines the number of elements that need to be loaded with each press of Expand:
With this option, you should be careful, because too large a value can lead to delays in calculating values during debugging.
Gmock and Google Test configuration
CLion supports Google Test and Catch unit testing frameworks. Support includes a built-in special window displaying test results (test runner). In order to get test results there, you need to use a special Google Test or Catch configuration when running tests. For Google Test it is created automatically for any tarket in CMake linked with gtest. And now for anyone linked with gmock.
Undo CMake Navigation and Download Actions
The focus of this release was IDE performance. For example, we have reduced the indexing time due to more optimal processing of compiler macros (compiler-predefined macros). There were other improvements in this direction.
In addition to the usual work on the performance of the IDE, we decided to transfer more management capabilities in the hands of users. To do this, we started doing some actions in the IDE to do asynchronous and cancelable, so that the user could not wait for actions that for some reason take a very long time, but quickly and painlessly cancel it.
The first such actions were reloading CMake and navigation actions ( Go to subclass and Go to overridden functions ). In the case of CMake, a button to cancel a working CMake command has been added to the corresponding tool window:
In order to display the result of the CMake command in this window, you can easily understand the completed command successfully or canceled, the corresponding text is automatically added to the end of the log ( [Finished] , [Reloading canceled] ).
As for the Go to subclass and Go to overridden functions navigation actions, they now work asynchronously, and to cancel them, simply click the mouse to any area outside the pop-up window with the results:
Interface Find in Path, improved support for version control systems and more
CLion is a product based on the IntelliJ platform, which means that the following changes apply to it:
Improved search user interface Find in Path
New features built-in VCS support, such as Git Revert, Reword and edit settings commit messages
Improvements in support for high resolution monitors (HiDPI)
Demonstration of new features of CLion 2017.2 in English from our developer lawyer (the author of the Catch framework itself):
If you are interested, download a 30-day free trial from the official website of the company, where in the price section you can also learn about the cost of a subscription.
Watch also for articles and updates in our English-language blog . We will be happy to answer any of your questions in the comments.