CLion News: 2020.1 Release, Five-Year IDE, and Online Q & A

Hello, Habr!

So much I want to tell today that itโ€™s even difficult to choose where to start. So first, I will try briefly about all the most important:

  1. CLion is 5 years old yesterday! In honor of the holiday, we mounted a small video story, a peculiar memory and a story about how interesting everything has been developing for us these 5 years. Immediately warn the story in English:


  2. Yesterday, the first big release of the product happened this year - CLion 2020.1 . In it, we supported the CUDA dialect, rewrote Dataflow Analysis to Clang, taught the IDE to work with the Clang-cl and IAR compilers, and also made many other improvements and corrections.
  3. Over the past few months, our team has become very sad without conferences and related exhibitions, where we are always happy to be at the company's stands and communicate a lot with our users and the community as a whole. Therefore, we decided to organize an online Q & A session with the team - CLion Ask Me Anything (AMA) session . The session will be held on May 7 in real time, a preliminary appointment is required. Join and ask any questions about the product!

Now let's talk more about all these events.

CLion - five!


Growing up children is always surprising and often unexpected for parents. The story is the same with the product - it seems that just yesterday we launched the early version and were counting down to release 1.0, but today we are already celebrating a round date. CLion now has more than 200 thousand monthly users, including teams from companies such as BMW, NASA, Tencent, Tesla and many others, and of course, cooperation with Google and Android Studio.

We are pleased to support many students around the world who, with CLion, are taking their first steps in software development. And very happy to know that a third of the ICPC teams in the final of 2019 also used CLion!

ICPC tools Final

The excitement with each new release, the responsibility to a huge number of our users, the cohesion of the team that does a great job - all this overwhelms us, and we are happy to share our first small anniversary with the entire Habr community! We hope you enjoyed the movie;)

CLion 2020.1


It may not be the largest on the scale of the past five-year period, but we definitely released an important release yesterday. Let's talk in order about the most important changes:

  • CUDA dialect support.
  • For embedded developers, IAR compiler support and plug-in for integration with PlatformIO.
  • Updated integration with Clang tools - DFA migration to Clangd, improved auto-completion, closer work with Clang-Tidy and ClangFormat.
  • For developers on Windows - support for the Clang-cl compiler and the default debugger.
  • Default parameter values โ€‹โ€‹in Change Signature refactoring.
  • More convenient startup and debugging configurations, including input redirection and IDE macro support.
  • Formatter updates, editor improvements, and more.

Cuda


CLion now supports the CUDA C / C ++ dialect. Support includes:

  • correct code parser (to exclude the "red" code and incorrect operation of the code analyzer);
  • highlighting and a variety of smart actions, such as navigation and viewing documentation;
    CUDA quick doc
  • updated wizard for creating new projects - now it includes a template for CUDA projects;

    CUDA new project
  • support for CUDA file extensions (.cu / .cuh);
  • special CMake targets for CUDA - the dialog for adding a new file will now offer to add it not only to suitable targets created by the usual CMake commands, but also specific to CUDA ( cuda_add_executable/ cuda_add_library);

    CUDA add to targets
  • and even auto-completion for angle brackets for kernel calls:

    CUDA completion

Note: for tests and screenshots, this CUDA project was used with GitHub: ClaraGenomicsAnalysis .

We were asked why we focused so much on CUDA, and not other specific areas, such as Qt. In short, of course, we would like to support all types of C / C ++ projects in our IDE. But in conditions of limited resources, you have to make a choice and rather focus on supporting the most universal capabilities. Dialects such as CUDA, if not supported โ€œout of the box,โ€ then lead to red code, code analyzer errors, and other problems with the basic capabilities of the IDE. Unlike Qt, where the general parser copes with the code and just lacks some specific features.

For Embedded Developers


We continue to support developers of embedded systems. Through collaboration with IAR Systems AB, we were able to obtain partnership licenses and add IAR compiler support to CLion. Previously, we could not correctly read information from the compiler and such projects did not load correctly in CLion. Now everything works!

Iar compiler

It is worth noting that to use the compiler, you need to use the MinGW toolchain. And here you can find some tips on how to use CMake with the IAR Embedded Workbench.

We will continue to work with IAR Systems AB, and hopefully one day CLion will also have support for their debugger.

From the very first CLion release, we talked with the creators of PlatformIO, a unique ecosystem for quickly starting projects for embedded systems. For example, she helped many to start the first project on Arduino. For the 2020.1 release, we have collected, albeit a fairly basic, but useful PlatformIO for CLion plugin . His most important opportunity is to create a project for PlatformIO based on CMake, just select this type of project in the Create New Projects Wizard:

PlatformIO plugin

The plugin automatically creates launch and debug configurations specific to PlatformIO, and also allows you to debug using the PIO Unified Debugger directly from CLion More information can be found in the official documentation . Try and write your wishes for further development - we are now just wondering where and how to develop this plugin further.

Updated Clang Tool Integration


As already known, we are now actively porting more and more features to the Clangd-based language engine. Firstly, to quickly get support for new language features and adapt IDE actions for them, and secondly, in some cases to improve editor performance (not everywhere, unfortunately, Clangd is such a universal tool).

In the 2020.1 release, we devoted a lot of time to the Clangd-based auto-completion fixes (it appeared in version 2019.3). And, having decided that the results of this approach are pretty good, they turned on the default mode in which the options for auto-completion are taken entirely from Clangd. You can enable the mixed mode of operation back in the settings:

Clangd completion

But we do not recommend doing this without good reason, since combining results from two different providers can cause problems with priorities. In addition, judging by our measurements, the new auto-completion based on Clangd is not slower, but often faster than the built-in one.

Clangd also moved data flow analysis (DFA) in this release. This analyzer deserves a separate article, because it can and does what compilers do not usually do (mainly because they do not need it, although theoretically it is possible to reproduce on their side) - analyzes how the data moves along the control flow graph and, Based on this knowledge, finds potential errors. For example, conditions that are always true or false, infinite recursions and loops, missing return expressions, unused values, parameters, and local variables:

DFA always true

Now it all works on Clangd. And we hope that this will improve the performance of code analyzes on your projects. Unfortunately, before, we often had to advise users to turn off DFA analysis specifically to improve editor performance. If this is your case, we suggest you turn the analyzer back on. We will be waiting for your feedback in our technical support and tracker .

To top it off, Clang tools should note improvements in support for Clang-Tidy and ClangFormat:

  • When a .clang-tidy configuration file is found in the project, CLion automatically disables the Clang-Tidy settings in the IDE and switches to using this configuration file. The behavior is driven by customization.
  • .clang-format CLion ClangFormat . ClangFormat, , CLion , .

Windows


If on Linux and macOS the CLion toolchain is quite simple to choose (we take either GCC or Clang), then on Windows there are many options that are not easy to figure out: Cygwin, MinGW / Mingw-w64, WSL, Visual Studio. At the same time, different compilers are often used within each toolchain. We have been asked for a long time about the possibility of using Clang on Windows. And in CLion 2020.1, it became possible to take Clang-cl (either from the official LLVM website, or together with Visual Studio tools) and use it within the Visual Studio toolchain:

Clang-cl

By the way, did you notice the debugger selected by default in this dialog? The same LLDB-based debugger for the Microsoft Visual C ++ toolchain that our team is developing and which we introduced last year is included in the new version by default! However, if you also want to use the support of Native Visualizers, you still need to explicitly enable it in the settings: Settings | Build, Execution, Deployment | Debugger Data Views | Enable NatVis renderers for LLDB.

Refactoring Change Signature


Among the many refactorings in CLion, Change Signature stands out (Ctrl + F6 on Windows and Linux, โŒ˜F6 on macOS). It allows you to change the function name, return type, list of parameters. At the same time, the IDE updates all uses of the function in order to preserve the correctness of the code. But what if you add a new parameter? Previously, CLion put a default value of type in all uses (if any) - 0for numbers, nullptrfor pointers. Now, from version 2020.1, it has become possible to specify the value that CLion will substitute for using the function directly in the refactoring dialog:

Change signature
If you do not specify anything, then the behavior will be as before.

Startup and Debug Configurations


The many small improvements to the startup and debugging configurations in CLion made them much more usable.

First, the Remote GDB Server and Embedded GDB Server configurations now work with custom targets, not just CMake targets. So now it is possible to debug on a remote machine or on a microcontroller not only in the case of a CMake-based project, but also for any other type of project for which you configured custom targets (by specifying the build and cleanup commands of the project).

Secondly, for configurations such as CMake, Custom Build, and Gradle Native Applications, you can now use macros and path variables. With their help, you can access many useful values:

IDE macros

And finally, the option to redirect program input has appeared in these types of configurations. In combination with Prompt / FilePrompt macros, it allows not only to redirect input to the program from a file, but also to show a dialog for selecting a file to enter at the start of the configuration:

Input redirection

Formatter Updates, Editor Improvements, and More


It is worth mentioning a few more small point improvements in different subsystems:

  • Separate naming settings for structure fields and class fields.
  • Ability to collapse code blocks highlighted with #pragma region/ #pragma endregion.
  • The documentation viewing window can now be not only called up by shortcut, but can also be seen simply by hovering over the symbol of interest.
  • The default font in the IDE is now JetBrains Mono , a new monospaced font from JetBrains designed specifically for developers to help optimize code readability.
  • The default light theme is now the same on all three platforms - IntelliJ Light.
  • Terminal sessions can be divided into several horizontally or vertically. Thus, several sessions can be seen simultaneously in one tab.
  • From the IntelliJ platform, improvements have also come in integration with version control systems .

CLion Ask Me Anything


An online Q&A session with developers from the CLion team is scheduled for May 7th. The session will be attended by team members responsible for the following subsystems:

  • C C++, Clangd, C++ CLion.
  • .
  • .
  • ( , ClangFormat).
  • .
  • .
  • .

The session is free, but pre- registration is required . We also ask you to think in advance and, if possible, leave questions for the team in the registration form. There will be an opportunity to ask questions during the session, through a special form (and I will moderate this and throw questions to colleagues), but questions asked in advance are more likely to receive detailed answers at the beginning of the session.

That's all for today. Read to the end? Thank you very much for your attention! Write questions, suggestions, exclamations in the comments - we are always happy to read and answer them!

CLion
The Drive to Develop Team

All Articles