The release of CLion 2018.1: new features from C ++ 17, support for WSL, CMake Install, a plugin for Rust and much more
Hi, Habr!
Here comes the first release of CLion this year - 2018.1 ! In this post we will tell you what we managed to realize during these months and what plans we have for the next release.
First, very briefly about the main thing. This release includes: ')
C ++ language support
C ++ 17 feature support: structured binding
C ++ 17 feature support: if and switch statements with initializers
Many bug fixes and improvements
Ability to use Clang-Tidy configuration files in CLion, as well as configure options for checks from Clang-Tidy in the CLion interface
Improvements for Windows users
Microsoft Visual C ++ compiler is enabled by default.
WSL subsystem support
CMake and not only
Call from IDE CMake Install
Templates for creating CMakeLists.txt files
Ability to open a file or folder without a CMake project model
Experimental hex view support in the debugger
Editor improvements:
“Bread Crumbs” (breadcrumbs) for C / C ++
Action unwrap
Minimizing control structures
Support for new languages in CLion: Objective-C / Objective-C ++, Rust, Fortran
You can now download the free 30-day version from our website and try new features. For this, we even prepared a special small demo project . And below we will talk about improvements in more detail.
C ++ language support
Spoilers! We are looking at different alternative language engine options (there are both our developments, and clang, and much more interesting), we conduct tests, comparisons, performance measurements, and analysis of the possibilities for expansion. In the meantime, all this is in the process, we continue to improve the current language engine.
First, we fixed dozens of different problems in the parser and code analyzer. Many users at the Early Access Program stage noticed improvements, so we believe that all this was not in vain. In particular, many problems and false errors in the code analyzer have been fixed for the case of a ternary operator .
Secondly, the Rename and Change Signature refactorings now more reliably update hierarchies. For example, if you rename a function in a descendant class, then CLion will not only offer to update the base class, but also go through other classes inherited from this base class:
Such cascading changes are simply necessary for the code to remain correct after refactoring.
And most importantly, added support for two great features of C ++ 17 :
Structured binding
If and switch statements with initializers
Clang-Tidy Support Improvements
Last year (in version 2017.2) we added integration with the Clang-Tidy code analysis tool to CLion. It provides dozens of different checks, including the Clang Analyzer, C ++ Core Guidelines, Modernize, and Google groups. In this release, we updated the baited version of the tool, slightly changed the set of checks included by default, and most importantly:
Added the ability to use the .clang-tidy configuration files instead of the IDE settings - this can be useful if you want to save the Clang-Tidy settings in the version control system and / or share them with the whole team (where not everyone uses CLion). It also allows you to run Clang-Tidy from both the IDE and the console on the same set of checks, without worrying about passing the same parameters in both cases.
Some Clang-Tidy checks allow you to specify options that affect the behavior of the scan. For example, modernize-use-nullptr allows you to specify which constants to replace with nullptr . This can now be done in the settings of CLion (Editor | Inspections | C / C ++ | General | Clang-Tidy).
WSL and other changes to the toolchain on Windows
For starters, the Microsoft Visual C ++ compiler is now enabled by default. That is, if you have it installed, you can immediately use it in CLion (do not, as before, go and enable the setting in the Registry).
But the most notable change is the support for Windows Subsystem for Linux (WSL) . This subsystem on Windows 10 provides a Linux environment built into Windows, and allows you to build, run, and debug Linux applications on Windows.
CLion is now able to work with such a toolchain, and even allows you to run the application with Valgrind Memcheck , a tool for finding memory leaks, incorrect memory access, using uninitialized variables, etc.
Thus, WSL provides a unique opportunity to run applications that are not available on Windows (such as the same Valgrind).
By the way, if we talk about the tools for analyzing memory errors, now our team is integrating Google Sanitizers. We hope that the results will be available in 2018.2.
It should be noted that WSL integration is implemented via ssh, since this is the first step towards full support for remote development in CLion. We hope to show its first prototype already in 2018.2. In the meantime, you can try WSL - a link to the script for quick setup of WSL, as well as details of the work can be found in the blog .
CMake & non-CMake
We began the process of separating the CMake design model from the CLion. The first results can already be seen in the release of 2018.1. Namely, CLion now allows you to open a file or an entire folder that does not have CMake files. Of course, many smart functions for working with the code will be disabled (since all the information about the project CLion takes from the design model), but what remains is enough for the initial acquaintance with the code, reading individual files, etc.
In CLion 2018.1, it is possible to call CMake Install . The corresponding action is available from the Run menu or in possible steps in the Run / Debug configuration (there Install can be added, for example, right after the build, but before starting the configuration). When you call Install, the cmake install command is run and, accordingly, all the targers for which this command is defined are installed.
By the way, now you can create a CMakeLists.txt file from the menu of creating a new file (Create new file - Alt + Insert on Windows / Linux, ⌘N on macOS):
The advantage is that the file will be created according to a template that can be customized for your needs in the Editor | File and Code Templates.
Hex view in debugger
Yes, we know, you asked for this opportunity for a very long time, and embedded-development doesn’t even imagine an IDE without such an opportunity ... In CLion 2018.1 hex view it is experimental and is available under the key in the register:
Go to the Find Action dialog (Shift + Ctrl + A on Linux / Windows, ⇧⌘A on macOS), write “Registry” there, open the Registry.
There we look for cidr.debugger.value.numberFormatting.hex (just enter hex and the search will start) and turn on the option.
Now go to the IDE settings: Build, Execution, Deployment | Debugger | Data Views | C / C ++ and turn on the hex view there.
The hex view will be displayed as in the debugger window:
so in the editor itself, in the Inline Variables View:
Why is it so difficult, why experimental support? Let's just say, the implementation still causes us doubts, and I want to do better. Besides, hex is available only for integer types, and there is no binary view.
Editor improvements
Although CLion is written mainly in Java and Kotlin, like the entire IntelliJ platform, we have a small part of the development in C ++. So, we, of course, try our product for our own tasks. And let it be desirable that there was more dogfooding in our work, but even now the results are visible. In this release, there were several editor improvements based on our own use of the product (not to mention various bug fixes).
“Breadcrumbs” (breadcrumbs) for C and C ++ have been added for namespaces, classes, structures, functions and lambs. This is such a convenient way to read and navigate through the code — at the bottom of the editor, small markers of where the cursor is now are shown, and you can click on this hierarchy of markers to rise to a higher level (for example, from a function to the class in which it is defined):
The unwrap / remove platform feature is now implemented in CLion, for C / C ++ code. With it, you can remove those code blocks that include this (where the cursor is). This is especially useful to remove the ambient ternary operator, function call, or, for example, the if..else block containing the current expression:
This version also added minimization of if / else, do / while, for, switch (Shift + Ctrl + Period / Ctrl + =) control structures on Windows / Linux and ⇧⌘. / + On macOS). And options to customize the collapse of the message box when building a project.
More than IDE for C / C ++
In CLion, in addition to C / C ++, for some time already, there is built-in support for Python (similar to PyCharm Community Edition), support for JavaScript, XML, HTML, CSS and other web technologies, as well as a plugin for Swift. Since the end of last year, Kotlin / Native support has appeared (via the plugin). And in version 2018.1, we added native support for Objective-C / Objective-C ++ (see the list of features here ), and also added a plugin for Fortran to the repository and updated the plugin for Rust . About the latter in more detail. This is the same plugin that is available in IntelliJ IDEA, but:
He now knows how to work with Cargo in CLion (previously there was only CMake)
In CLion (and for now only in it), the plugin has a debugger for Rust
More details about plugins for Fortran and Rust, see here .
And finally, a demonstration of the new features of CLion 2018.1 in English from our developer lawyer:
That's all! Interested? Then download the 30-day free trial from the company's official website, where in the price section you can also find out 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.