CLion starts 2018.2 EAP: Google Sanitizers, Gradle C++ projects, recompile a single file, and IDE performance improvements

Posted on by

Hi,

Today we have a bit of good news for you! CLion starts the 2018.2 Early Access Program. The first build (182.2371.31) is now available for download.



While we still continue fixing bugs in v2018.1 and publishing bug-fix updates for this version, we are now ready to start the EAP for v.2018.2, and we are looking forward to listening to your feedback here in the comments and in the tracker. Here are the main highlights of the changes in the first 2018.2 EAP build:

Read more details below and get the build from our site:

Download CLion 2018.2 EAP

Google Sanitizers

For our users to benefit from Dynamic analysis tools, we’ve previously added Valgrind Memcheck support to CLion. Now we are happy to announce Google Sanitizers support! Find the quick FAQ with details below.

How to run my code with sanitizers?

To detect addressability issues, memory leaks, data races, and uninitialized memory issues with Google Sanitizers, you need to manually provide the corresponding build options in your CMake script. For example, for Address Sanitizer you have to provide: -fsanitize=address . The corresponding CMake command will look similar to:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -O1 -fno-omit-frame-pointer -g")

How is CLion’s integration beneficial to me?

In case you use Clang >= 3.8.0 or GCC >= 5.0.0, when you run/debug your application or unit tests with sanitizers, CLion visualizes the sanitizers output in a “Sanitizer” tab in the run tool window. It allows you to review the list of errors and their traces in the IDE, navigate to sources, preview the sources or inspect the frame information:



Which sanitizers are supported and what are the options for each one?

CLion supports:

AddressSanitizer and LeakSanitizer (a list of supported platforms for ASAN is here)

ThreadSanitizer (a list of supported platforms for TSAN is here)

MemorySanitizer (a list of supported platforms for MSAN is here)

UndefinedBehaviorSanitizer (a list of supported platforms for UBSAN is here)

The documentation for all the sanitizers, including all the available settings and supported platforms can also be found on the official Google page. To pass settings to sanitizers in CLion use Settings/Preferences | Build, Execution, Deployment | Dynamic Analysis Tools | Sanitizers page:



Most sanitizers are supported on Linux and macOS, and if you are on Windows, you can try using them via the WSL toolchain.

Recompile a single file

While working on a project and implementing some local changes in a file, you might want to check them as soon as possible, at least to be sure that the compilation still works. To speed up your development cycles, CLion now has a new feature – Recompile, which can be used to rerun the compilation for a selected file (via Shift+Ctrl+F9 on Linux/Windows, ⇧⌘F9 on macOS, or via Run | Recompile menu option), without triggering the recompilation of the whole project.



How it works

This works for CMake and compilation database projects for now. Under the hood, in the first case, CLion calls the CMake target for the corresponding file, instead of a direct compiler call (which CLion actually never does, as it always delegates the build to CMake). In the simplest case, when current file belongs to the currently selected Run/Debug configuration, the build target from this configuration is used. Otherwise, CLion attempts to find a suitable configuration, prioritizing those with the same CMake profile (build type) as the currently selected one.

For compilation database in order to recompile CLion simply calls the compilation command from the compilation database json file (with some little changes to output options and fsyntax-only ).

Known limitations

Currently recompilation doesn’t work for MinGW – the fix in CMake is expected in one of the future CMake releases.

Check our webhelp for more details on how the recompilation in CLion happens.

Gradle C++ projects

Gradle is the first build system to join CLion in addition to CMake (if you don’t count Cargo for Rust projects, available via a plugin or a 3rd party Bazel support)! Note, that CLion currently supports only new Gradle C++ projects, the old style won’t work. Sample projects can be found on GitHub.

To open a Gradle C++ project in CLion, open the build.gradle file from the project sources:



Tell CLion to open this file as a project and provide the Gradle settings; you mainly need the Gradle JVM location (you can later change them under Settings/Preferences | Build, Execution, Deployment | Gradle):



and you are done! Your new Gradle C++ project is up and running in CLion (including the full C++ code insight support):



Known issues and limitations

A few limitations are present now:

As we’ve said, only new Gradle C++ projects are supported

For now, Create Project wizard can’t create Gradle projects

Non-correctly resolved code on Windows with MSVC (CPP-12936)

And other known issues linked to this parent one in our tracker.

Database plugin

Starting with this EAP build, CLion comes with the full database tools support. It’s enabled via Database Tools and SQL plugin by default and the functionality corresponds to the DataGrip IDE:



The plugin allows you to work in CLion with many known Databases (like MySQL, PostgreSQL, Oracle, and others): explore the content of the DB, read and modify data, get code completion, refactoring and other intelligent features for the SQL language, and execute queries – all this without ever leaving the CLion IDE. Read more details about the supported features in our webhelp.

Performance improvements

As we said before, we have a plan to continually improve performance and eliminate UI freezes. Some fixes have already been implemented in v2018.1, others are planned for v2018.2 and v.2018.3.

Indentation calculation on lexer

As a part of this plan, this EAP introduces a lexer-only indentation processor. This means code in your editor in CLion is formatted based on the lexer information. It’s obviously faster, especially for C++, than doing a full code parsing and resolve, but some issues are possible. Thus we kindly ask you to report them to us when detected.

If you experience big issues with the formatter on lexer and would like to switch back to a more accurate solution, please, use the cidr.indent.lexer.only.cpp setting in Registry:

In Find Action dialog ( Shift+Ctrl+A on Linux/Windows, ⇧⌘A on macOS) type Registry;

on Linux/Windows, on macOS) type Registry; open Registry, type cidr.indent.lexer.only.cpp to search for the setting and turn it off.

Note, this is still a work in progress.

Fixes for several typical UI freezes

This build comes with fixes for code completion cases (CPP-12036) and freezes related to the Search Everywhere action (CPP-11711).

External tools in CLion are capable of running any external scripts or executables. Configure them in Settings/Preferences | Tools | External Tools and call them independently via Tools | External Tools | or add a step to your Run/Debug configurations:



CLion 2018.2 EAP comes with a set of CMake specific macros available for configuring programs, arguments, and the working directory of your external tools:

CMakeCurrentBuildDir – Build directory for current CMake run configuration

CMakeCurrentBuildTypeName – Build type name for current CMake run configuration

CMakeCurrentExecutableName – CMake executable used for current run configuration

CMakeCurrentGenerationDir – Generation directory for current CMake run configuration

CMakeCurrentProductFile – Product file for current CMake run configuration

CMakeCurrentProgramArguments – Program arguments for current CMake run configuration

CMakeCurrentTargetName – Target name for current CMake run configuration

Other changes

There are more changes and fixes introduced in CLion 2018.2 that worth mentioning:

Valgrind Memcheck results can be exported to XML format-files and imported back when needed

CLion 2018.2 EAP supports and bundles CMake 3.11

C++ language support improvements: An analysis was added that can prevent returning a local variable from the function and getting crashes on the run time:

Several cases of incorrect “value escapes local scope” warning were fixed (CPP-5538, CPP-10621). Incorrect overload resolution of initializer lists when using templated functions were fixed (CPP-11767). Support was added for the GCC extension for templated user-defined string literal (CPP-12689).

CLion also got some valuable goodies from IntelliJ platform: MacBook Touch Bar support (more details) Improvements to VCS support (more details)



One last thing to mention is the Conan plugin for CLion. It allows you to configure Conan profiles and match CMake and Conan profiles. The work is in progress and your contribution is very welcome!

That’s it! Full release notes are available via the link. If you are interested in what else is planned for v2018.2 find the roadmap in the earlier blog post here. Download and try the build right now and share your feedback with us!

Download CLion 2018.2 EAP

Your CLion Team

JetBrains

The Drive to Develop