What's New in CLion

CLion 2021.3 supports a variety of toolchain setups and makes it easier to configure them. It makes development more productive with the improved rendering in the debugger and simplifies modern C++ code maintenance with in-editor type hints. Static analysis in this new release is able to catch a new batch of typical C++ pain points.

Toolchains

In CLion, a toolchain is a set of all the necessary tools required for building and running your application. CLion v2021.3 makes toolchains more flexible, easier to configure and customize.

Docker Toolchain

Docker Toolchain

Docker containers are one of the most popular and easiest ways to set up an environment and start working with it. Instead of using Remote toolchain for Docker in CLion, you can now use the native Docker toolchain. It avoids redundant source code synchronization, as the project folder is simply mounted to the container.

CLion also bundles the Docker plugin, which brings the Services tool window and many docker-specific actions to the IDE.

Custom Compiler

Custom Compiler

Suppose you are using a custom compiler or a compiler not yet known to CLion natively, which is often the case in embedded development. There is now a way to describe all the necessary information about the compiler to CLion and work with it as if it were natively supported.

Use Settings | Build, Execution, Deployment | Toolchains | Custom Defined Compiler to enable it and provide the *.yaml file that contains your custom compiler definition. Check out the sample configs prepared by the CLion team for you.

Learn more

Initialize toolchain environment via script

Initialize toolchain environment via script

In some cases the environment in which the compiler runs is initialized via script. It can initialize compiler environmental variables, customize the PATH variable, and more.

Use Settings | Build, Execution, Deployment | Toolchains and select Add environment | From file in CLion to source such a script for the toolchain you are using.

Bundled MinGW on Windows

Bundled MinGW on Windows

CLion now bundles the MinGW toolchain on Windows for quick setup, which you can rely on if you don’t have any other options installed on your machine. The exact version bundled is MinGW-w64 9.0 with languages=c,c++, posix threads, and sehcode exceptions.

Another improvement for MinGW users is a bundled 64 bit GDB v10.2 with Python support.

System toolchain on Windows

System toolchain on Windows

A new System toolchain on Windows, similar to the same toolchain type on Linux and macOS, allows configuring CMake, compiler, and debugger executables without selecting a predefined environment (like MinGW, Cygwin, WSL, or Visual Studio). This might be used for the ARM toolchain or other embedded toolchains on Windows.

CMake

CMake generators UI

CMake generators

A new UI for setting the CMake generator was added to the CMake Profile settings page (Settings | Build, Execution, Deployment | CMake). Users can use the default value for the toolchain selected or set any generator from the predefined list.

When the UI field is used, CMake options on the same page are updated automatically and vice versa.

Ninja generator

Ninja is one of the most popular and effective CMake generators currently used. CLion 2021.3 comes with Ninja v1.10.2 bundled.

For local toolchains (i.e. excluding Remote, Docker, WSL) and CMake v3.20 and higher, Ninja is now the default generator for newly created projects or projects opened in CLion for the first time.

CMake update

CLion now bundles CMake 3.21.1. CMake File API is used by default to query project information in CLion for CMake v3.20 and higher. Learn more.

CLion now supports CMake Presets v3.

Other project models

Makefile

Use the new Build directory option in Settings | Build, Execution, Deployment | Makefile to configure the directory where all make tasks are executed when the Makefile project is loaded in CLion. The configured directory is passed via -C option to the make call. Folders like autom4te.cache in the build directory are marked by CLion as excluded.

Gradle

While it’s still possible to use the Gradle project model for C++ projects in CLion, both Gradle and Gradle Native plugins in CLion are now unbundled. You can install them via Settings | Plugins.

Debugger enhancements

Improved types rendering

Improved types rendering

Heavily templated standard library types, or types with global and obvious namespace specifiers, can produce long entries in the variables view during debugging.

To improve the debugging experience, CLion now performs some additional processing to render types in the variables view in a more readable and friendlier way:

  • Strip auxiliary namespaces, global and function scope specifiers, and standard library ABI version namespaces.
  • Simplify standard library types by replacing standard library types with more readable aliases.
  • You can also remove types completely from the presentation. This can help focus on the variable values.
Improved frames view

Improved frames view

In the frames view in the debugger, in addition to type rendering improvements, CLion now improves functions presentation:

  • Removes return type, if any.
  • Hides function parameters.
  • Hides template arguments of enclosing types and the function itself, if any.
  • Renders the name of the function in bold to be easily distinguished from namespaces and enclosing types.
  • Can add the Module name to show in which binary the code is being executed at any moment.
  • Shows thread ID given by the OS on thread start in the thread list along with the thread name.
View as Array for pointers

View as Array for pointers

A new View as Array… action is now available for any pointer variable and adds a watchpoint that renders a pointer value as array. The action is available in the context menu in the variables view. All you need to do is specify the size of the array.

Customizable debugger presentation

Customizable debugger presentation

To control the presentation of the types, variables, and frames in the debugger, use the new settings in Settings | Build, Execution, Deployment | Debugger | Data Views | C/C++ (or just Data Views, without the separate C/C++ section if all other languages debuggers are disabled for you in CLion).

Alternatively, you can control the presentation from the context menu right in the Debug tool window.

More convenient Evaluate Expression

More convenient Evaluate Expression

As part of the ongoing debugger UI redesign, Evaluate expression is now integrated right in the Debug tool window. This makes it more discoverable and easy to use.

Parallel Stacks view

Parallel Stacks view

When debugging multithreaded applications, you have to track multiple threads at the same time. The new Parallel Stacks view is implemented as a separate tab in the Debug tool window and shows thread call stack information for all the threads. It allows checking the call paths and execution points of all running threads.

Enhanced Hex view

Hex view for numeric variables was improved and is no longer an experimental feature in CLion. Enable it in Settings | Build, Execution, Deployment | Debugger | Data Views | C/C++ or in the context menu in the variables view.

LLDB update

CLion 2021.3 comes with bundled LLDB v13.

RTOS thread views

FreeRTOS thread view

FreeRTOS thread view

FreeRTOS thread view was expanded by adding objects and heap views:

  • The Task table shows a list of tasks with status information.
  • The Queue table shows currently active queues, semaphores, and mutexes.
  • The Timer table lists the software timers.
  • The Heap Usage table shows the current heap usage and memory block allocation.
Zephyr RTOS thread view

Zephyr RTOS thread view

Zephyr RTOS is now supported. To enable the tasks view, similar to the one available for FreeRTOS, use Settings | Build, Execution, Deployment | Embedded Development | RTOS Integration and select Zephyr there.

Type hints

CLion 2021.3 adds type hints for deduced types to increase code readability. The new hints help with types for auto variables, in structured bindings, and for lambda return types.

You can disable or enable specific type hints in Settings | Editor | Inlay Hints | C/C++ or right from the hint’s context menu.

If the type hint includes the template instantiation, the template arguments can be collapsed by simply clicking on the angle brackets. Also, Ctrl+Click allows you to navigate to the declaration of the type you clicked on.

Enhanced Structure View

Enhanced Structure View

When exploring the structure of the file in the Structure tool window (Alt+7) or in the Structure pop-up (Ctrl+F12), you can distinguish functions with the same names more easily, as CLion now shows qualified names for the member functions there.

Static Analysis

Clang tools update

Clang tools update

LLVM tools in CLion were upgraded to v14.0.0. This improves the accuracy of the Clangd-based language engine and updates bundled Clang-Tidy and ClangFormat executables. For Clang-Tidy, this also means there are a few new checks you’ll be notified about when CLion is first launched after the update.

More MISRA checks

New MISRA checks were added to CLion’s built-in analyzer:

  • A function identifier shall either be used to call the function or it shall be preceded by &.
  • The loop-counter shall be modified by the value that stays constant for the duration of the loop.
  • There should be exactly one loop-counter in the for loop.
  • The loop-counter shall not be modified within condition or statement, and others.

The full list of MISRA C 2012 and MISRA C++ 2008 checks available in CLion can be found here.

Call-context sensitive analysis

Call-context sensitive analysis

CLion’s data flow analysis now treats different calls differently, and so has become more accurate. This specifically means that:

  • CLion analyzes each function for each call site separately.
  • Parameters and return values for different call sites are analyzed separately.

More powerful Lifetime analysis

CLion’s lifetime analysis (based on Herb Sutter’s Lifetime Safety proposal) was enhanced and it can now capture cases like dangling iterator and modified owner (as owners passed by non-const reference are assumed to be modified).

VCS

VCS

Sometimes, you may have several commits that are ready to ship while others are still a work in progress. In such cases, you may want to push only the ones you are confident about. The new Push All up to Here action allows you to push commits up to the one you have selected in the Log tab of the Git tool window.

Other enhancements

  • CLion’s auto import now uses "" instead of <> for header files belonging to the project. This default behavior can be changed by turning off Settings | Editor | General | Auto Import | C/C++ | Auto import local files with quotes.
  • To improve CLion performance for projects on WSL, the Clangd-based language engine is now run directly on WSL in such cases.

What's New in CLion 2021.2

The C++ ecosystem is evolving, and so is our cross-platform C/C++ IDE. CLion 2021.2 can help you by protecting your code from typical C++ memory safety issues, simplifying your build configurations, and making debugging easier and more effective.

CMake support

CMake 3.20 is supported and bundled in CLion 2021.2. This version includes CMake Presets, major updates to the CMake File API, support for C++23 compiler modes, and many updates for CUDA developers.

CMake Presets

CMake Presets

Store your project build configuration in new and universal CMake Presets, and CLion will automatically detect and import the necessary CMake Build Presets.

It will notify you and suggest reloading the presets if any changes are introduced to them, either in the editor or externally.

You can manage the imported presets in Settings | Build, Execution, Deployment | CMake.

Learn more

New CMake project templates

New CMake project templates

Additional templates for creating new CMake projects are available in the New Project wizard. They cover C and C++ libraries and executables, CUDA libraries and executables, and Qt projects.

You can find and edit the templates in Settings | Editor | File and Code Templates | Other.

CMake target in configurations

CMake targets as Before Launch tasks

In the Before Launch section of the Run/Debug configuration, users can now specify CMake Target tasks, both built-in and user-specified. These tasks will be performed before starting the selected target.

Makefile projects

GNU Autotools

Support for GNU Autotools

CLion now automatically detects GNU Autotools, Kbuild, and PERL MakeMaker projects. When these projects are loaded as Makefile projects, CLion automatically detects preconfiguration scripts and executes them to get the Makefile and load the project from it.

Preconfiguration step

Preconfiguration step

CLion 2021.2 detects whether the project has any configure.ac or configure scripts required to create its Makefile. On project load, CLion executes these preconfiguration steps automatically by using the command set in Settings | Build, Execution, Deployment | Makefile settings.

Load Makefile Project

Load Makefile Project action

If you open a project in CLion without loading the Makefile project model, you can still load it later. This might happen if your project requires some custom preconfiguration steps and no final Makefile is available until those steps are finished. To load it, call the context menu on the project's top-level Makefile and select Load Makefile Project.

Debugger update

Natvis support

Windows: better Natvis support

When you use the Microsoft Visual C++ toolchain on Windows, CLion provides its own LLDB-based debugger. Data rendering in this debugger was improved in v2021.2:

  • Natvis customization features such as Inheritable attribute, format specifiers, and CustomListItems are now supported.
  • Built-in renderers were improved by adding one-line colored summaries for all structures not covered by Natvis, enabling formatting for wide/Unicode strings, and showing the [Raw View] for Natvis-generated values.

Learn more

Minidumps

Windows: minidumps debug

Postmortem debugging with core dumps is now supported on Windows. Use the Run | Open Core Dump action to start a core dump debug session.

External Console

Windows: Run in external console

Instead of the internal console used by CLion, on Windows, it’s now possible to switch to the cmd.exe console to run and debug applications. Use the Run in external console checkbox in Run/Debug configuration to change the behavior.

Relaxed breakpoints

Relaxed breakpoints

There are cases with breakpoints when path mappings are too complex to fill them in in the debug configuration, or when the -fdebug-prefix-map option is set in the debugger. In these situations, it's now possible to use just the file name instead of its absolute path during debugging sessions.

Breakpoints in disassembly view

Breakpoints in disassembly view

While stepping through assembly code, you can now add/remove breakpoints on instruction lines. For non-default configuration of these address breakpoints, use the right-click context menu menu.

Preview tab for Debugger

Preview tab for Debugger

To avoid cluttering the editor with many tabs during stepping, consider enabling the preview tab. In CLion 2021.2 it works during debug sessions and allows you to view files in a single tab one by one, without opening each file in a new tab.

Remote LLDB

Remote LLDB and LLDB 12

To improve debugging with LLDB, LLDB v12.0 is now bundled. Remote debugging of any arbitrary executable from CLion is now possible with LLDB (in addition to GDB). Use the new Remote Debug configuration to provide arguments to connect to the remote host. On a remote host, you'll need to launch lldb-server/debugserver. Check out our web help for more details.

FreeRTOS thread view

FreeRTOS thread view

If you debug applications with FreeRTOS in CLion, a view with the task lists is now available. You can switch to the task you are interested in to explore task variables and more.

Learn more

Code Analysis

Diagnose common cases of dangling pointers and escaping from a local scope by using static analysis. This capability is made possible by the Lifetime Safety proposal that CLion has partially implemented. GSL annotations are also supported to let you mark your code and make local analysis more accurate.

Cling interpreter

Cling

Cling is an interactive C++ interpreter built on top of Clang and LLVM. It allows you to run code without building the project, which can be especially useful for prototyping and learning C++.

Install Cling on your system and benefit from its integration with CLion:

  • Start a new Cling session.
  • Send included headers or selection to Cling.
  • Send the current line to the Cling session via the code intention.

Learn more

Remote and WSL

Profiling in remote mode and on WSL

Profiling is now possible in remote mode and on WSL. In both cases, the Perf backend is required. Find the instructions in our web help on how to install the Perf tool for your particular kernel release.

You'll also need to configure the path to the Perf tool in CLion Settings | Build, Execution, Deployment | Dynamic Analysis Tools | Perf.

Docker

Remote development in Docker

For Docker containers with mapped volumes, remote development without source synchronization is now available in CLion. This mode removes the code duplication and the initial project upload step. Learn how to configure this mode in Docker and in CLion.

WSL configuration

WSL configuration

WSL configuration in CLion has become much easier, as you no longer need an SSH server inside a WSL distribution to work with WSL in CLion. CLion now uses a dedicated WSL API.

CLion now supports WSL whether it's installed from the Microsoft Store or a custom distribution.

Text search in Local History

Local History

Text search through file revisions in Local History appeared in CLion 2021.2, helping you locate the point you want to roll back to more easily.

VCS

Pre-commit actions

Changes to pre-commit checks

In v2021.2, we expanded the list of possible pre-commit actions with the ability to execute tests. Tick the Run Tests checkbox and select the configuration to run.

We also added the ability to customize the Analyze code and Cleanup options by clicking Choose profile next to them.

Unified Show Diff

CLion shows the difference between the initial and changed files in the editor by default, no matter where you invoke the Show Diff action. If you prefer to track changes in a separate window, simply drag the desired file outside the editor.

GPG signature

CLion 2021.2 offers a way to secure your commits. To enable Git commit signing with GPG, go to Settings | Version Control | Git, click Configure GPG Key, and then select it from the drop-down list.

Toolbox App

Toolbox update

Do you use the Toolbox App to manage CLion installations and updates? Now you won't miss any critical product updates from it. Your IDE will alert you if there is a new version available for download and give you the option to upgrade right from CLion.

Localized UI

You can now enjoy the CLion UI in Chinese, Korean, and Japanese. The fully localized UIs are available as non-bundled language pack plugins, which can be installed in CLion from Settings | Plugins.

Other enhancements

Some other useful improvements and enhancements in CLion 2021.2 include:

  • If you want certain operations to be performed on Save, you can now configure them all in one place, in Settings | Tools | Actions on Save.
  • It is now easier to reorganize tool windows. Hover over the top of the tool window you want to move, then drag it to where you want it and drop it there.
  • IntelliJ Rust introduced a new name resolution engine and initial WSL support. The plugin is now also capable of expanding certain procedural macros. Learn more

What's New in CLion 2021.1

CLion 2021.1 is enhancing the code analysis experience by upgrading Data Flow Analysis to global mode, expanding MISRA support, and integrating with Clazy for Qt projects. In the debugger, GDB and LLDB have reached feature parity for Core Dump debugging. And finally, remote mode has a wider range of abilities and works consistently across several project models.

Data Flow Analysis

Data flow analysis (DFA) tracks the flow of data in your code and detects potential issues based on that analysis. In addition to the local DFA (which works within a single function), CLion 2021.1 includes global DFA (which takes a whole translation unit of a program as a single unit for analysis). Global DFA not only enriches the already existing checks but also adds several new unique inspections.

Enhancing local checks with global DFA

The list of current DFA-based inspections that benefit from global DFA includes:

  • Dangling pointers – detects pointers that may point to already deleted memory.
  • Null dereference – detects dereferencing pointers that may contain nullptr.
  • Endless loops and Infinite recursion.
  • Constant conditions – detects possible conditions that are always true or false.
  • Unreachable code and Unused values.
  • Escape analysis – detects variables containing references to local variables that escape their scope.

New global DFA checks

A few new inspections have been added that only make sense when analyzing globally – running DFA on a whole translation unit of a program:

  • Constant function result – reports functions whose return value appears to always be the same constant.
  • Constant parameter – reports functions where a parameter appears to always be the same constant.
  • Unreachable function calls – detects functions whose call sites are never executed.

Performance improvements

CLion 2021.1 also optimizes many steps in DFA. The performance measurements on Postgres, Eigen, and Clangd projects, among others, show that the overall performance is good and that some characteristics have improved (such as the number of files where DFA execution was terminated by CLion because of a timeout).

Learn more

Dynamic analysis

Branch coverage

Branch coverage

In addition to line coverage, CLion 2021.1 can now also calculate Branch Coverage. This method takes into account all the branches of each control structure. Run your CMake application or tests with coverage and check out the new column that’s been added to the Coverage tool window.

Branch coverage is enabled by default and can be adjusted in Settings | Build, Execution, Deployment | Coverage, but it only works with GCC/gcov or version 12.0.0 and higher of LLVM/llvm-cov.

Dynamic analysis in Remote mode

Dynamic analysis in Remote mode

In order to reach feature consistency across all toolchains, project models, and configurations, CLion 2021.1 makes it possible for Google Sanitizers, Valgrind Memcheck, and Code Coverage to work with remote toolchains.

MISRA C and C++ checks

CLion 2021.1 adds more checks from MISRA C 2012 and MISRA C++ 2008. The full list is maintained on our confluence page and allows you to easily track the progress.

Postfix completion for C and C++

Postfix code completion for C and C++ lets you add code around an expression you’ve just typed. It can wrap an expression with a frequently used language construct, or pass the expression as the first argument of a free function.

Postfix template

Wrap the expression with language construct

Postfix templates can help you with common language constructs. Type an expression then a dot, and then add the postfix template abbreviation and press the expansion key, or select the required template from the completion list that appears. The expanded template will wrap the given expression. Find the full list of templates in Settings | Editor | General | Postfix Completion.

Postfix function parameter

Pass the expression to a free function

Use postfix code completion to pass the expression you’ve just typed to a free function as the first argument. Type an expression, then a dot, and select a free function from the completion list that appears.

Enhancements for Makefile projects

Initial support for Remote Makefile projects

Initial support for Remote Makefile projects

CLion 2021.1 allows you to work with Makefile projects on a remote machine. Change the toolchain in the Makefile settings to a remote one, then reload the project and it will synchronize with the remote machine. Compile, run, and debug your application remotely from your locally running CLion.

Check out known issues and limitations.

Makefile Language plugin

Makefile Language plugin

The Makefile Language plugin (previously 3rd-party) is now maintained by the CLion team and comes bundled in CLion. The plugin provides make syntax highlighting, quick documentation, Find Usages for targets, and a variety of navigation and code completion actions for Makefile.

Enhancements for CMake projects

Share CMake Profiles in VCS

Share CMake Profiles in VCS

CMake Profile settings in CLion are now stored in a cmake.xml file in the .idea directory and can be shared in the VCS along with the project. Simply select the Share option in Settings | Build, Execution, Deployment | CMake.

CLion 2021.1 bundles CMake 3.19. In addition to the other changes it introduces, this is the first CMake version to support Apple Silicon (M1 chip).

CMake 3.19 features for CUDA are now supported in CLion, which includes autocompletion for a few new CMake variables.

Enhancements for Qt projects

Clazy integration

Clazy integration

Clazy, a Qt-oriented static code analyzer, is now integrated into CLion’s Clangd-based engine. CLion currently uses version 1.8. Checks are displayed in the editor and quick-fixes are also available.

Users can configure CLion’s severity level and the level of the Clazy checks in Settings | Editor | Inspections | C/C++ | General | Clazy.

QtCreator keymap

QtCreator keymap

For those used to the key bindings in QtCreator, CLion now bundles the QtCreator keymap. You can switch to it in Settings or via a Quick Switch Scheme action (Ctrl+`).

Debugger

Set Execution Point in disassembly

Set Execution Point in disassembly

The Set Execution Point action lets you jump to an arbitrary line of code in the editor during a debug session and set the execution point there, skipping all the other commands in between. It now works in the disassembly view, so you can move the execution point while stepping through the assembly code.

Core dumps debugging

Core dumps debugging

When debugging core dumps in CLion 2021.1, users can now set sysroot in the corresponding run configuration. This will help localize library symbols when debugging core dumps from binaries built on other systems.

Explicitly setting symbol files when debugging a core dump for non-symbolized binary with LLDB now also provides necessary information about the symbols to CLion. With this fix, GDB and LLDB have reached feature parity for core dump debugging in CLion!

Remote terminal

Remote terminal

A new Tools | Open Remote Host Terminal action opens the project directory on the remote host if it exists. The remote host corresponds to the remote profile that is currently selected, or if a local one is selected, the first remote profile found in the project.

Project view

External Sources

Source files located outside of the project root are now grouped under the External Sources node in the Project tree. This helps prevent the top-level crowding of these files.

VCS

Profile for pre-commit inspections

Profile for pre-commit inspections

CLion can inspect your code before you commit it to help you make sure there are no bugs. Choose a code inspection profile before committing changes to VCS – click the gear icon to display the commit options, select the Analyze code checkbox, click Choose profile, and select the desired profile.

Git commit templates

You can create a custom commit message template in Git and CLion will display this text as an initial commit message.

Save to Shelf

A new Save to Shelf action allows you to copy your changes to the Shelf while keeping them in the local changes. You can access this action by pressing Ctrl+Shift+A and typing ‘Save to Shelf’.

Learn more about other VCS improvements across all IntelliJ-based products.

Rust plugin update

Rust plugin update

IntelliJ Rust now provides a structured view for the compiler’s build output. The tab opens automatically in the Build tool window when you call a Cargo command that includes a build step. This new feature works with Cargo versions 1.48.0 or later.

Another significant update is the new Change Signature refactoring. It helps you modify a function/method signature, affecting all references. You can quickly change a function’s name or return type, reorder or add/remove parameters, and add an async or unsafe prefix.

The Rename refactoring now gives renaming suggestions for elements like structs, functions, and local variables when you change a name in the editor.

Conditional compilation support has been improved. Find Usages is now available for Cargo features, and completion works for the feature argument in the cfg and cfg_attr attributes. Also, if there are nested attributes inside cfg_attr, the plugin takes that into account during name resolution and code analysis.

Code With Me

Code With Me

Code With Me, a new JetBrains service for collaborative development and pair programming, is now bundled with CLion.

Set the required level of access to your project and share the link with your guests. Your peers do not even need to have an IDE of their own installed to collaborate with you. Embedded audio and video calls, along with chat messaging, will help teams discuss the code, share their knowledge, and cooperate more efficiently.

To learn more about the availability of Code With Me with your current JetBrains license, check out the pricing page.

Space integration

The Space plugin is now available for CLion. You can connect to your organization in JetBrains Space via Get from VCS, located right on the welcome screen. Once logged in, you can view and clone project repositories, review your teammates’ code, and write Space Automation scripts.

Other enhancements

  • CLion will now automatically apply the high-contrast theme when you launch the IDE for the first time if you are using the high-contrast mode on Windows.
  • With the new typography settings, fine-tune the weight of your main and bold font styles in Settings | Editor | Fonts.
  • Whenever several tabs that split the editor vertically are open, you can double-click any of them to maximize the editor window for that specific tab. To bring the window back to its original size, simply double-click it again.