What's New in CLion

This year’s third update, CLion 2017.3 offers a more flexible way to configure toolchains, an ability to profile memory usage with Valgrind Memcheck, a more accurate C++ code analysis, support for Visual C++ compiler extensions, and integration with Boost.Test for testing your code.

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.

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. 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.
2017.1 Mar 29

Modern C++

C++14

CLion 2017.1 delivers support for the following C++14 features:

  • auto return type,
  • generic lambdas,
  • variable templates, and
  • generalized lambda captures.

See the full list of supported features per standard in CLion’s online documentation.

C++17 support

C++17

As the C++17 standard is just around the corner and the upcoming features are being finalized, CLion starts supporting C++17 with nested namespaces.

Make auto intention

Make auto intention

For the sake of code readability and accuracy, CLion now suggests to modernize your C++ code by converting variable type to auto.

As this feature should be used carefully across your code base, it’s implemented as a non-intrusive intention. Use it as you see fit.

Code analysis

General improvements

We continue to improve CLion’s parser and code analysis to make it even more accurate:

  • Hidden functions from the base class are no longer suggested in completion
  • Fixes for various false positives, for example in case of decltype(auto) in trailing return
  • Correct calculation for value category (that fixes many false 'expression is not assignable,' 'expression must be lvalue,' and 'expression must be rvalue' warnings)

Precompiled headers

Precompiled headers

CLion now locates the precompiled headers and headers included via -include option, in order to correctly resolve symbols from such files and correctly highlight the code, navigate through it, perform code refactorings, etc.

Learn more

Disassembly view for debugger

Disassembly view

While debugging with GDB, you can now step into disassembly code when the sources are not available. Read the assembly, which is properly highlighted in the editor, and step through it to investigate the problem.

Catch

Catch

Catch is a cross-platform unit testing framework for C++ known for its easy starting process and convenient and flexible test cases. Now you can use Catch with CLion and benefit from completion and the built-in test runner.

Microsoft Visual C++ compiler

Experimental support for the Microsoft Visual C++ compiler is here. Check it out to avoid difficulties with MinGW/MinGW-w64 or Cygwin configuration, and especially if you use Microsoft Visual C++ as a compiler for your cross-platform C++ project.

MSVC

Current support covers:

  • Auto-detection and support for C++ compiler from Visual Studio 2013, 2015 and 2017
  • Support for projects using CMake with NMake generator
  • Settings to configure architecture, platform, etc.
  • Navigation through the compiler errors in the Messages tool window

To switch on the support, use clion.enable.msvc option in the Registry.

Project model improvements

Project model is now more user-friendly:

  • For existing CMake projects, the project name in CLion is taken from CMake’s PROJECT_NAME on first opening
  • Escaped symbols in CMake files are now handled correctly
  • Obsolete not-modified run configurations, and run configurations for deleted targets, are now removed automatically

Find in Path

Run a text search across the whole project or any selected scope with Find in Path, now in a compact and more convenient popup window with immediate preview.

Find in path

VCS

Make auto intention

Log Viewer

Refine your search through the Git and Mercurial logs in the Log Viewer with these new options:

  • Ability to use regular expressions
  • Ability to match / ignore case

Configure which information to display in the log viewer to make it more compact or more detailed (for example, show / hide tag names).

Branches

Branches popup

The Branches popup has been redesigned and can now mark important branches as Favorites.

This gives you the ability to filter the branches and show only favorites in the corresponding popup.

Swift

Swift

Several important enhancements were added to the Swift plugin for CLion:

  • Create new Swift projects with ease using the new project template
  • Check possible issues in your code in Swift with SourceKit inspections and intentions available in the plugin
  • When using a type which doesn't exist yet, create it from usage via Alt+Enter

Other improvements

  • Zero latency typing has proved to remove many typing lags in IntelliJ-based IDEs and is now enabled by default
  • CMake 3.7 was bundled into CLion
  • Fixes for Dvorak layout in macOS, as well as Korean, Chinese and Japanese keyboard layouts on macOS are included
  • Settings Repository plugin is finally bundled into CLion
  • Go plugin was updated and now correlates with GoLand functionality