The release of CLion 2017.3: significant improvements in C ++ support, integration with Valgrind Memcheck and Boost.Test, and more
Hi, Habr!
Our team has prepared a new year's gift for the Christmas tree for all C and C ++ developers - a new release of CLion 2017.3 ! In this post we will try to tell you how good it is, estimate further directions for product development and, of course, answer all your questions in the comments.
')
Briefly about the main improvements for those who do not want to read a lot:
C ++ language support
Improvements in parser subsystems such as list initialization and name lookup
Support for Microsoft Visual C ++ compiler-specific extensions
Macro support __COUNTER__
And not only!
New tools and frameworks
Valgrind memcheck
Boost.Test
CMake 3.9, GDB 8.0, LLDB 5.0
Significant processing and empowerment in customizing the compiler, environment, CMake, debugger, etc.
Ability to run almost arbitrary main functions, icons for starting main functions and tests
Ability to develop on Kotlin / Native at CLion
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
Global improvements
Practically everyone probably knows that we are writing our own parser for C ++. This causes a variety of discussions, both among our users (such discussions originate under any of our posts here on HabrĂŠ, reddit, etc.), and within the team. The more interesting for us at the same time is to improve the current solution, and to think about possible alternatives (by the way, we do not completely exclude one!). And lately, we have conceived to globally rework our solution, starting with the subsystems that lie at the bottom, and gradually rising to the top. The version of CLion 2017.3 touched on list initialization and name lookup .
In the case of list initialization , the fixes basically caused the CLion to no longer display incorrect warnings like âtoo many argumentsâ , âtoo few argumentsâ , âno matching constructorâ . And, on the contrary, shows them now where it is needed:
In addition, CLion can now correctly understand variables in the case of uniform initialization:
Another area of ââfix in this release is the name lookup . Properly associating a variable name with its declaration is one of the basic tasks of language support. Problems at this stage lead to incorrect code analyzer messages, incorrect code generation, etc. The main corrections were related to the correct rezolv order and rezolv of variables that are passed into view through the using construct or using type inheritance:
MSVC Extensions Support
If you have a Microsoft Visual C ++ compiler installed on your machine, then you can enable experimental support for MSVC in CLion and use this compiler instead of GCC and Clang. The experimental support was named for several reasons:
Initially, CLion did not support any special C ++ MSVC extensions.
In the case of MSVC, the debugger is not available in CLion
CLion 2017.3 includes fixes for the first item. Extensions such as __uuidof , __unaligned / __alignof , __ptr32 / 64 and others are __ptr32 . The full list is available in our blog .
Unfortunately, there are no concrete plans for the MSVC debugger yet (but there is an interesting discussion on various debuggers for MSVC and licenses for them).
Other useful C ++ support improvements.
A team dedicated to language support at CLion is growing! And therefore we gradually cover more and more significant requests from the tracker. We still managed to do this release:
Macro support __COUNTER__ . Its value is now fairly calculated, which means that CLion will no longer show, for example, an incorrect warning about a âduplicate declarationâ . And in the Quick Documentation window (Ctrl + Q on Linux / Windows, F1 on macOS) you can see the result of the macro substitution:
Definition generation (Shift + Ctrl + D on Linux / Windows, â§âD on macOS) for functions now works correctly in the case of function templates.
Added support for the popular refactoring template - inverting if-else blocks. This template is often used to simplify code that uses many nested if blocks.
For audio application developers
Separately, I would like to talk about improvements for those who are developing multi-platform audio applications. For such development there is a very famous library in C ++ - JUCE. In CLion 2017.3, we fixed several problems in language support that arose when using JUCE.
But the main news for JUCE users was the release of JUCE 5.2 , where the ability to export the project to CMake was added to the new version of Projucer. And that means to open it for further development in CLion! We even recorded a short demo in which we create a demo audio plugin, export it to CMake, open it in CLion, launch the plugin in Ableton Live and debug it through CLion!
Integration with Valgrind Memcheck
One of the most popular requests in our tracker is integration with profiling tools, in particular with Valgrind. In this release, we started with the key point - we added the ability to profile memory using Valgrind Memcheck.
Unlike Google Sanitizers, which are also often used for this task, Valgrind Memcheck supports many platforms (but, unfortunately, like Sanitizers, is not available on Windows). It does not require recompiling the program and works with an executable file compiled using both Clang and GCC. At the same time, the tool allows you to identify a whole range of problems in working with memory:
Memory leaks
Invalid memory access, for example, after calling free
Mismatch of allocate and free operations (malloc / free, new / delete)
Using uninitialized variables
Passing overlapping memory as parameters to memcpy functions
Transfer to memory allocation function of incorrect size, for example, negative
Now in CLion, you can run the configuration with Valgrind Memcheck and in the startup results window get information about potential problems, including a piece of stack corresponding to the problem, and a preview of the place in the code where the problem occurred. Settings allow you to set so-called suppression files (to disable analysis in libraries, for example) and options for running Valgrind Memcheck.
Improvements in unit testing
Integration with the framework for unit testing in CLion implies running tests in a built-in window displaying results (test runner). If Google Test and Catch were previously supported, now they have added Boost.Test :
By the way, in the left side column (âhitterâ) you can see new icons. They work for all three supported frameworks and are used to run tests - by clicking on them, you can choose to start, debug, or start from Valgrind Memcheck. And after the first run of tests, the icon changes appearance and begins to display the status of the test - passed or dropped. It is quite convenient if you want to open a file with recently launched tests and quickly understand what and how.
Similarly, using the icon in the left switch, you can run any main function for which there is a CMake target (without target, it is rather difficult to understand what exactly and how to start). But the Run configuration is not necessary to create - CLion creates it automatically when you click on the icon.
Tulchain, compiler, CMake settings
Already almost traditional autumn changes in the field of CMake and the configuration of tulcheins and configurations have not bypassed this release. The main thing:
Now it is possible to configure several toolchains in the IDE and select the right one for each project, or even use several different ones for different targets on the same project. This is especially true for users on Windows who want to switch between Cygwin / MinGW / MSVC environments easily and quickly:
Now you can easily switch the C and C ++ compiler, as well as Make. Now it can be done in the settings of the toolbar mentioned above.
Now it is possible to create several CMake profiles with the same build type (Debug, Release, etc.), but with different options, environment settings used by tulcheins (for example, compilers), etc.:
The CMake profile is no longer directly connected to the run / debug configuration being launched, but is selected independently:
New versions of debuggers and CMake
In CLion 2017.3, we have included updated versions of the following tools:
CMake updated to 3.9
GDB updated to 8.0
LLDB updated to 5.0
It is worth noting that GDB 8.0, which comes with CLion, is built with support for multiple architectures. And this means that with remote debugging between different platforms (for example, from Windows to Linux), it will not be necessary to reassemble GDB anymore, but it will be possible to use the built-in one.
Kotlin / Native
Surely many of you know that the company JetBrains has created and is actively developing a new programming language Kotlin , which this year on Google I / O was officially recognized as the language for developing Android applications. We also have the Kotlin / Native project, which allows us to compile Kotlin directly into native code of platforms such as iOS, Linux, Windows, macOS and WebAssembly.
You ask, and here CLion, IDE for cross-platform development in C and C ++? The fact is that Kotlin / Native integrates with technologies from the world of native development, like Clang and LLDB. And CLion, in turn, is considered by us as an IDE for native development, which already has support for C and C ++ as the main languages, as well as Python, Swift and Rust as additional (all within CMake so far). Therefore, it was quite natural to release a plugin for development at Kotlin / Native specifically for CLion. More details can be found on the Kotlin blog . And in the future we can expect the appearance of Kotlin / Native in our other tools.
This concludes the overview of the new features of CLion 2017.3. Of course, there are also updates in support of version control systems and other features that come from the IntelliJ platform. But I will not repeat myself and just refer to the blog post about IntelliJ IDEA 2017.3 here on HabrĂŠ .
Demonstration of new features of CLion 2017.3 in English from our developer lawyer:
If it becomes interesting, download a 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.