What's New in CLion

CLion 2018.2 is turning into a more mature C/C++ IDE by adding support for new project models, an additional clangd-based language engine (in experimental mode), and support for Google Sanitizers and databases.

This release also makes the editor more responsive thanks to a host of performance improvements.

2018.2 (Jul 25)

C++ support

Clangd
Argument selection defects inspection

Clangd-based language engine

CLion 2018.2 introduces an experimental clangd-based language engine for showing code errors and warnings in the CLion editor, which works alongside CLion’s own language engine. It’s enabled by default on all platforms. Note that the clangd engine is used for code analysis only and doesn’t affect the rest of code insight features like completion or refactoring.

Learn more

Argument selection defects inspection

Is it possible to detect situations when the arguments of the same type are passed in the wrong order? It is if argument and parameter names are meaningful! Welcome a new inspection in CLion to alert you of this: argument selection defects.

Note, it works on top of the new clangd-based language engine, so you have to turn it on to enable the new inspection.

Learn more about the algorithm used

New Project Models

Gradle C++
Compilation Database

Gradle C++

New Gradle C++ projects can now be opened in CLion (see the new C++ plugins announcement). Use the build.gradle file or the directory containing this file to open a Gradle project in CLion. All IDE capabilities, including full code insight, are available for such projects in CLion.

Learn more

Compilation Database

Compilation Database is a set of all compile options used to build the files in a project. If you manage to get one from your project (via your build system's options or separate tools like bear and intercept-build), you can now use the resulting json file to open your project in CLion. Code insight does work, though it’s not yet possible to build, run, or debug such projects.

Learn more

CMake support

Included files as project files
CMake macros

Included files as project files

You no longer need to list header files from your project root directory directly in CMake to get full code insight for such files in CLion. If you include the header or source file into any project file, CLion will automatically treat it as a project file as well, which means full code insight will work in there!

Learn more

CMake macros

When configuring an external tool in CLion, you can now use CMake-specific macros, which provide information about the current CMake run configuration: build directory, build type name, program arguments, or target name.

Dynamic analysis

Google Sanitizers
Valgrind Memcheck

Google Sanitizers

If you build your project with the -fsanitize option, CLion will visualize the sanitizers’ output in a “Sanitizer” tab in the run tool window. Use it to review the list of errors, navigate to sources in the editor, and do much more. Enjoy support for ASAN, TSAN, MSAN, and UBSAN in CLion.

Learn more

Valgrind Memcheck export/import

To keep an eye on your project’s memory issues and track the progress, you can now export Valgrind Memcheck results into XML files. Reimport them back with ease, whenever you need.

Recompile a single file

Recompile a single file

To speed up your development cycles, verify local changes quickly by recompiling a single file. Use CLion’s new action Run | Recompile (Shift+Ctrl+F9).

For now this only works for CMake (it calls the CMake target for the corresponding file, instead of a direct compiler call) and compilation database projects (it calls the compilation command from the json file).

Learn more

Database tools and SQL

Database tools and SQL

Version 2018.2 bundles the Database Tools and SQL plugin, which adds DataGrip’s functionality to CLion. This allows you to work with many known databases like MySQL, PostgreSQL, Oracle, and others.

Explore the content of a database, read and modify data, execute queries, and get full code insight for SQL too.

Learn more

IDE performance

Making the editor more responsive is currently one of our top priorities. CLion 2018.2 comes with the following improvements:

  • Lexer-only indentation processor allows CLion to format your code based on lexer information. Read more
  • Version 2018.2 brings fixes for UI freezes in:
    • completion use cases,
    • Search Everywhere,
    • navigation to Related symbol,
    • breadcrumbs,
    • and more.

Other improvements

Among other enhancements you’ll find:

  • Bundled LLDB 6.0 and CMake 3.12.
  • A host of fixes for LLDB and GDB.
  • Support for WSL background processes (starting with Windows 10 v1803).
  • MacBook Touch Bar support (read more).
  • Improved VCS support (read more).
2018.1 (Mar 28)

WSL

WSL config

Linux toolchain on Windows

If your project requires a Linux toolchain while being developed on Windows, you can now use Windows Subsystem for Linux (WSL) in CLion running on Windows.

Configure WSL and the corresponding toolchain under Settings | Build, Execution, Deployment | Toolchains, and then you’re ready to use it in CLion. Header search paths on WSL will be used, and the Linux binary will be created for you to run and debug on WSL.

Learn more
WSL Valgrind

Valgrind Memcheck on WSL

Valgrind Memcheck can detect dozens of memory errors and leaks and is now available for Windows users on WSL.

Turn on a WSL toolchain, make sure Valgrind is detected in settings (Settings | Build, Execution, Deployment | Valgrind), and then compile and run regular and test targets under Valgrind Memcheck to detect possible errors and leaks. View the results in a special tab in the Run tool window.

C++ support

if with initializer

C++17: If and switch with initializers

To avoid polluting an ambient scope or creating an artificial scope for initializers in if and switch operators, C++17 suggests adding an initializer to if and switch conditions. CLion now parses and resolves such statements correctly.

structured bindings

C++17: Structured bindings

C++17 introduced structured binding – a convenient and compact way of binding a list of identifiers to a set of objects. CLion’s C++ language engine now supports this feature and ensues accurate code analysis for it.

Ternary operator

Ternary operator

The ternary operator is now handled correctly in CLion’s code analysis. This means many false warnings and errors are no longer thrown, such as:

  • Red code in the ternary + new operator
  • False positive if std::out is used in the ternary operator
  • Incorrect resolve when initializing a reference from a ternary operator
Rename siblings

Rename and Change Signature for hierarchies

Refactoring hierarchies can be tricky, especially if you introduce a change in a derived function. To make it reliable we made sure that the Rename and Change Signature refactorings update functions in all inheritance branches, including sibling functions.

Clang-Tidy

Clang-Tidy settings

Clang-Tidy options and configs

Now you can provide options to some Clang-Tidy checks (e.g. modernize-use-nullptr) in CLion, under Settings | Editor | Inspections | C/C++ | General | Clang-Tidy.

If you prefer .clang-tidy config files instead of the IDE-provided settings (for example, because you store these config files in a VCS for the whole team to access and use in various IDEs), you can configure CLion to respect your existing per-directory configs.

Editor

Folding control statements

Code folding of the control statements

Now you can collapse/expand control statements (like if/else, do/while, for, or switch) with a code block that’s longer than one line, or with a code block inside braces. Just use Shift+Ctrl+Period / Ctrl+= You can also hover the mouse over the folded block to preview the content.

Message windows

Message toolwindow: new settings

With v2018.1, you can decide if build output is always necessary (and thus should be visible) or it’s only needed if some warnings or errors appear. Look in the Messages tool window settings for these options:

  • Always Show on Build (Default)
  • Auto-Hide and Show on Warning/Error
Learn more
Breadcrumbs

Breadcrumbs for C and C++

Keep track of your location in C and C++ code with the breadcrumbs – small markers at the bottom of the editor that help you navigate around your code. Right now CLion shows namespaces, classes, structures, functions, and lambdas there.

Learn more
Unwrap blocks

Unwrap/remove code blocks

To accurately and safely remove enclosing parts in complicated code with lots of nested statements, use Unwrap/Remove… action (Ctrl+Shift+Delete). It suggests the options depending on where your caret is and is capable of unwrapping if, else, for, while, do..while and for control statements.

CMake

CMake Install

CMake Install

If you have any CMake install targets in your project, you can call Install from the CLion’s Run menu now. The cmake install command will be executed.

Alternatively, you can add an Install step to any of your run configurations in CLion.

non-CMake prj

Open single file and non-CMake projects

While CLion still requires a CMake project to provide smart IDE features, you can now open a single file or folder in CLion which don’t have to be connected to any CMake project.

Follow the built-in notification to select and load a CMakeLists.txt file later. Call Tools | CMake | Unload CMake at any time to unbind your project from the current CMakeLists.txt.

Learn more
Create CMakeLists.txt from template

CMakeLists.txt file template

Create new file (Alt+Insert) now provides an option to create a CMakeLists.txt file.

The content of the generated file is defined by the template in Settings | Editor | File and Code Templates, so you can customize it based on your project’s or team’s needs.

Project scopes

Configure scopes

Predefined and custom scopes

CLion 2018.1 brings several predefined scopes which can help overview your project from different angles, like Project Source Files, Project Non-Source Files, and Changed files.

You can also configure custom scopes, for example a scope that only includes project header files.

Learn more
Switch scopes in Project View

Project view

By default, Project View opens the Project, which includes all project files including the generated folder (like cmake-build-debug) and other excluded folders. Later, you can select between other predefined or custom scopes.

Find in Path with Scopes

Find in Path

To narrow down your search and thus make it quicker and more efficient, use scopes in the Find in Path dialog. All custom scopes created earlier are available in the list.

VCS: Partial Git commits

Select code chunks to commit

Select code chunks to commit

Want to commit only the selected changes from files and leave others for later? Partial Git commits (git add -p) can help here, and now there is support for them provided by CLion here!

To include code chunks in a commit, use the check-boxes in the Diff pane of the Commit Changes dialog.

Add to changelist

Move a change to the changelist

While editing a file, you can see change markers in the left gutter. These not only let you overview the change and roll it back, but also move it to any existing changelist or create a new one and add the current code chunk to it.

Learn more

More languages – more power

Objective-C / Objective-C++ support

Work with files in Objective-C / Objective-C++ added to your CMake project and benefit from the following features (courtesy of AppCode) bundled into CLion:

  • Language syntax support
  • Objective-C inspections (except for the clang analyzer set)
  • Key-value coding support
  • Live and file templates
  • Code style/color schemes

Fortran and Rust plugins

Fortran plugin comes with FORTRAN 77 / 90 / 95 / 2003 and 2008 support. The capabilities include smart editor, navigation actions, code analysis and debugger.

Rust plugin comes with:

  • the Cargo build system on board,
  • updates to CLion’s New Project wizard
  • and a debugger.
Learn more

Other improvements

There are dozens of other useful enhancements in CLion 2018.1. Find out more in our blog.

  • Performance improvements: Important changes were introduced to make the editor more responsive. Incremental highlighting was implemented.
  • MSVC by default: No need to turn on Microsoft Visual C++ compiler support in Registry – now it works by default.
  • Color scheme improvements: CLion now bundles Monokai and GitHub schemes, and comes with lots of fixes to the existing schemes.
2017.3 (Nov 30)

C++ language engine

List initialization

List initialization is a standard way to initialize an object from braced-init-list since C++11. In CLion 2017.3 the support for this language feature was reworked, including fixes for many of the incorrect code analysis warnings. For example:

  • Failed resolve for the members of auto variables initialized with uniform initialization
  • Missing error for lambda capture initializer with multiple expressions
  • Invalid warnings when C99 union initializers are used
  • And others incorrect “too many arguments”, “too few arguments” and “no matching constructor” errors in the code with list initialization

Name lookup

Name lookup is a C++ standard procedure to associate a name with the declaration. This release fixes the situations when the procedure failed in CLion:

  • Resolving a name before the corresponding declaration from the same scope
  • Resolving a name imported via using in some cases
  • Resolving symbols brought into scope by the class inheritance
  • And others
__COUNTER__ support

__COUNTER__ support

CLion 2017.3 correctly increments __COUNTER__ macro value, that means invalid “duplicate declaration” errors are now removed. Quick Documentation (Ctrl+Q) popup in place of the __COUNTER__ macro usage will show the final substituted value.

Generate Definitions improvements

Generate Definitions

Generate Definitions (Ctrl+Shift+D) creates missing implementations for the functions. And now it respects function templates as well.

Besides, Generate function from usage (Alt+Enter) now respects template parameters.

MSVC extensions

Microsoft Visual C++ compiler extensions

While Microsoft Visual C++ compiler support is still experimental, CLion brings support for some specific MSVC extensions:

  • __alignof and __unaligned keywords,
  • pointer type attributes, like __ptr32 and __ptr64,
  • MSVC built-in data types,
  • and some additional format specifiers, like %I32 and %I64

Find a full list on the blog.

JUCE

JUCE support improvements

JUCE is widely used to develop multiplatform audio applications. CLion 2017.3 comes with multiple fixes to the JUCE library support to avoid various incorrect code analysis warnings and allow proper navigation through the code.

Besides this, with a fresh JUCE 5.2 update, you can use CLion/CMake exporter in Projucer and start developing your audio application with CLion even faster!

Watch the demo.

Intentions: Invert if

Invert if

One very common refactoring pattern is to invert the condition in the if clause and flip the if-else blocks. This can help simplify complex code that uses multiple nested if statements.

Follow this pattern with CLion support now – the corresponding intention will invert the if clause for you.

Profiling: Valgrind Memcheck

Valgrind Memcheck

CLion now comes with the memory profiling on Linux and macOS platforms – Valgrind Memcheck integration was introduced in v2017.3. It lets you run targets with Valgrind Memcheck and then get the results in a special tab in the Run tool window. Users can run both regular targets and unit tests targets with Memcheck.

Learn more

Unit testing: Boost.Test

Boost.Test

Boost.Test, the second most popular unit testing framework used by C++ developers on a regular basis, is now available in CLion along with Google Test and Catch/Catch 2. The support includes:

  • Special Boost.Test Run/Debug configurations
  • Results view in the built-in test runner
  • Ability to re-run all/one/all failed tests, export/import results
  • Ability to navigate to the test source code from the test results

UI: Run icons

Run icon

The left gutter in CLion is used to help with navigation through the code, VCS changes, and more. Now it also shows special run icons to Run, Debug or Run with Valgrind main functions and unit tests.

For unit tests, these icons also report the status of the tests: success or failure.

Learn more

Multiple Toolchains

The multiple toolchains support in v2017.3 means it is easier to set compiler configurations, different versions of CMake/compiler/debugger for different projects and configurations, and that there is a simplified switcher for toolchains on Windows. The new settings are as follows:

  • Configure Toolchains – then use them in CMake Profiles.
  • Select CMake Profile when selecting a configuration to Run or Debug.

Toolchains

In File | Settings | Build, Execution, Deployment | Toolchains you can now configure several toolchains, selecting various CMake executables, compilers, and debuggers. On Windows, create different toolchains for MinGW, Cygwin, and Microsoft Visual C++ compiler configurations.

Select from these toolchains later in CMake profiles to apply different toolchains to different configurations.

CMake profiles

CMake profiles

CMake profiles are created per project and can be used to easily switch between Debug/Release configurations, and to use different Toolchains in one project, etc.

Create CMake profiles in In File | Settings | Build, Execution, Deployment | CMake, set the build type, CMake options, environment, and other settings, select toolchains from the list of configured ones.

Toolchains compiler

Easy way to switch the compiler

To easily switch compilers on a project, or to use several different compilers for Running/Debugging different targets, use Toolchains. You can either rely on a compiler/Make detected by CMake or select a custom one.

Note, CMake options -DCMAKE_C_COMPILER and -DCMAKE_CXX_COMPILER take precedence over these compiler settings.

Build type switcher

Build type switcher

Select the necessary CMake Profile in the run configuration switcher on the toolbar. A typical case is Debug/Release build types configured via two different CMake Profiles.

The switcher is also available in the Run/Debug configuration switcher popup that opens via Shift+Alt+F10 for Run and Shift+Alt+F9 for Debug.

Color schemes

Color schemes

The color scheme settings for C/C++ were updated to distinguish function calls and function declarations. In In File | Settings | Editor | Color Scheme | C/C++ you can now find separate settings for these two options.

For example, you can make function declarations bold and keep function calls in regular font.

Other improvements

  • Debugger:
    • CLion now bundles GDB 8.0 with multiarch support
    • CLion now bundles LLDB 5.0
  • CMake 3.9 is now bundled into CLion
  • VCS improvements:
    • When switching between branches, the IDE preserves your workspace and automatically restores it when necessary.
    • When committing git patches from the IDE, the IDE reads the author and commit details provided by the git patches.
    • When using Tasks & Contexts, you can now shelve the changes related to your current task when you start a new task; unshelve the changes when you switch back.
    • And some more
  • Kotlin/Native, a brand new technology that compiles Kotlin directly to machine code, is now supported in CLion via plugins
2017.2 Jul 19

Clang-Tidy

Clang-Tidy: modernize

Clang-Tidy on board

Clang-Tidy is a powerful code analysis tool that provides dozens of valuable checks and quick-fixes. Now you can benefit from it in CLion – it works as you type, and shows messages the same way as CLion’s own built-in code inspections. Clang-tidy quick-fixes are similarly available via Alt+Enter.

Cpp Core Guidelines

C++ Core Guidelines, and more

Clang-Tidy incorporates lots of valuable checks. Among them are C++ Core Guidelines checks (use -*,cppcoreguidelines-* to run only these), modernize C++ code checks (-*,modernize-*), and many others.

Clang-Tidy: settings

Configure the checks you need

Make the IDE run only the checks you really need. To configure this easily, go to C/C++ code inspections settings Settings/Preferences | Editor | Inspections | C/C++ | General | Clang-Tidy). Clang-Tidy command line format is used in the text field. The default configuration can be found here.

Besides, from a context menu you can disable individual checks or suppress the check for a particular line via // NOLINT.

Add your own checks

Clang-Tidy is easily extendable, with a convenient API for writing new checks. Add your custom checks to Clang-Tidy, provide a path to the Clang-Tidy binary in Settings/Preferences | Languages & Frameworks | C/C++ and get your checks immediately in CLion.

For custom checks, please, be sure you are using Clang-Tidy version 6.0.0+ or any other version, but with patches from JetBrains applied (patch D35349, patch D34404).

C++ Support

Code analysis correctness

Focusing on correctness, CLion 2017.2 improves its C++ code analysis across the board. For example:

  • Fixes for incorrect code analysis in cases when std::enable_if is used
  • Fixes for the issues with resolving STL containers with nested template type for GCC5/6
  • Proper support for va_* macros was added
  • Correct handling of functions that take parameter pack arguments and non-template arguments
Unused var quick-fix

Unused variable quick-fix

Even when variable is unused, constructor might still have some side effects. A new quick-fix was added to preserve non-trivial constructor call on unused variable.

C++ type casts

C++ cast operators

CLion’s intentions and quick-fixes in C++ code suggest C++ type casts (static_cast, dynamic_cast, reinterpret_cast, const_cast) instead of C-style casts.

Learn more

C++17 in the New Project wizard

C++17 in the New Project wizard

C++17 is now available in the list of standards in the New Project wizard. CLion will automatically add set(CMAKE_CXX_STANDARD 17) to the CMakeLists.txt generated for new projects.

PCH for Microsoft Visual C++ compiler

Precompiled headers are now supported for MSVC as well. Learn more

Debug

Force Step Into

Force Step Into

The Disassembly view is shown in CLion when sources are not available when debugging with GDB. To get into disassembly code, now you need to use a special action, Force Step Into (Shift+Alt+F7). The usual Step Into (F7) will simply skip all frames without sources.

Long arrays

Inspecting big arrays

To reduce timeouts during array evaluation while debugging, CLion uses a limit of 50 array elements shown by default. If you need elements with big indexes and clicking expand is not an option, then simply increase the value cidr.debugger.value.maxChildren in the Registry.

Keep in mind that this may lead to increased timeouts as well.

GDB driver fixes

CLion 2017.2 fixes several annoying issues with GDB driver:

  • Command time out when trying to attach to a non-existent local process
  • Incorrectly escaped backslashes in program arguments on Windows

Performance improvements

Indexing times were improved in some cases. And after optimizing the parsing of the compiler predefined macros in CLion, some performance improvement during the reindexing was achieved as well. Besides, in some cases it’s just about giving users more control:

Cancelable go to actions

Cancelable asynchronous Go to actions

Go to subclass and Go to overridden functions actions may take significant time as they build a list of available options to navigate to. To improve IDE performance and responsiveness, we’ve made it possible to cancel these navigation actions – simply click to the area out of the navigation popup window and it’s done!

Cancelable CMake reload

Cancelable CMake reload

To save time, it’s now possible to cancel CMake reload in order to introduce additional changes or just to postpone this time-consuming operation. To that end we’ve added a Stop button to the CMake tool window.

To distinguish cancelled and finished CMake runs, CLion now displays [Finished] in every output tab for each CMake configuration being reloaded and finished.

Find in path UI

The Find in Path popup introduced in 2017.1 has received some UI enhancements.

Find in Path: left gutter

Left gutter in preview

The Preview panel now has a full-featured left-side gutter with navigation icons, and markers for local changes.

Find in Path: Merged results

Merged results

For your convenience, search results from the same lines are now merged together in the Preview panel.

VCS

VCS: Git Revert

Revert

Git Revert is now available in the Git Log view and works for any number of selected commits.

VCS: Reword

Reword

To change the commit message for a commit that has not been pushed yet, use the new Reword action.

Commit messages settings

Commit Dialog settings

To keep the commit messages easy to read and expressive, take care of their formatting. Updated settings allow you to control blank lines between subject and body, maximum text length, and check spelling. They are located under Version Control | Commit Dialog.

VCS: quick-fixes

Quick-fixes for commit messages

CLion now offers quick-fixes for commit messages, such as reformat or wrap lines.

Other improvements

  • CMake 3.8 is now bundled into CLion.
  • Google Test Run/Debug configurations are generated automatically for targets linked with gmock (similar to what was previously done for gtest).
  • On Windows displays, CLion gets its own scale factor and the UI is scaled accordingly.