ReSharper has just started an Early Access Program for v2019.1 and there are plenty of great things we plan to add or improve. The ReSharper C++ team has started this year putting the pedal to the metal on performance optimizations in Unreal Engine 4 codebases. The changes include faster cold startup times, better memory utilization, and new settings to tweak ReSharper’s indexing behavior.
Depending on the CPU in your workstation, you may expect cold startup to become 5.5 to 6 times faster. This is the time between opening the solution and getting access to the full functionality of ReSharper C++.
A number of things have contributed to these speedups:
Algorithmic improvements in code indexing.
Skipping plugins and third-party code when indexing an Unreal Engine 4 project by default.
Faster cache serialization.
The options that affect code indexing in Unreal Engine 4 solutions are grouped under a new options page at ReSharper | Options | Code Editing | C++ | Unreal Engine.
Clear the Index third party code and Index plugins checkboxes if you want to skip source files under “Plugins” and “ThirdParty” folders from indexing, or Index Unreal Engine source files to skip the indexing of the engine code altogether.
Note that ReSharper C++ indexes engine code in the background by default. This was already implemented in 2018.3, so here’s just a friendly reminder that you can start working with your game logic code long before the engine code is fully processed. If you turn off background indexing using the Enable background indexing checkbox, this will result in a faster but more intrusive initial indexing.
Let’s make a test!
The following performance test proves the numbers we’ve mentioned above. Using Unreal Engine v4.20.3 and the “Shooter Game” project from the Epic Games Library, we measured the cold startup time for parsing game code and Unreal Engine code, respectively:
Intel i7-8700k: ReSharper C++ cold start time
Game code: 30 sec
Unreal Engine code: 23 min 00 sec
Total time: 23 min 30 sec
Game code: 30 sec (no change)
Unreal Engine code: 3 min 39 sec (6.3 times faster than before)
Total time: 4 min 12 sec (5.59 times faster)
AMD Threadripper 1950x: ReSharper C++ cold start time
Game code: 1 min
Unreal Engine code: 29 min 30 sec
Total time: 30 min 30 sec
Game code: 50 sec
(1.2 times faster than before)
Unreal Engine code: 4 min 16 sec (6.76 times faster)
Total time: 5 min 6 sec (6.08 times faster)
The numbers speak for themselves! Feel free to get the EAP build and take your own measurements on your own Unreal Engine project.
Smaller memory footprint
Besides faster initial indexing, our team has implemented many memory usage optimizations. Both the memory traffic during initial indexing and the memory footprint afterwards have been improved in order to make the IDE more responsive.
Check out the latest ReSharper C++ 2019.1 EAP build and let us know if the IDE performance has improved for you in Unreal Engine 4 projects! As always, your feedback will be greatly appreciated. And there are more goodies coming in this area, so don’t change the channel!
Join us at Game Developers Conference 2019 later in March and chat about Unreal Engine 4 support in our tools!
Please welcome the third release of ReSharper C++ this year! v2018.1 brought debug step filters and includes analyzer, while v2018.2 came with the initial C++/CLI support and better understanding of C++17 and C++20 standards. The just released v2018.3 tunes literally every smart feature the product has, making them work more precisely on modern C++ code.
C++/CLI support has been improved with several new context and generate actions for C++/CLI code.
Solutions are loaded a lot faster, especially those that use the Unreal Engine. The main catch is that ReSharper C++ only parses non-engine projects during the initial indexing; the engine files are indexed in the background later.
Predefined naming schemes for common C++ code standards were introduced.
Refactorings, code generation, formatting, and other areas have been enhanced in various ways.
Among these improved areas, there’s one we’d like to talk about in more detail. The error annotator in ReSharper C++. These improvements are available in the recently published 2018.3 EAP 6 build. Let’s see what it’s all about! Continue reading →
While ReSharper C++ 2018.1 introduced two major new features, debug step filters and includes analyzer, ReSharper C++ 2018.2 is focused on improving its understanding of the C++ language. The biggest highlight is its long-awaited support for C++/CLI. In addition, many important features from C++17 and even the upcoming C++20 have been implemented. Code analysis is enhanced with spell-checking inspections powered by the newly bundled ReSpeller plugin, as well as formatting inspections to help you maintain a consistent code style.
ReSharper C++ joined the ReSharper fold back in 2015 to bring the power of ReSharper to the world of C++ – and has been getting better ever since! For most people this has rounded out the ReSharper story within Visual Studio. However an odd gap remains. Odd because the worlds of C++ and C# are bridged by the interop language, C++/CLI, yet this has remained unsupported by the ReSharper family.
Until now, that is!
From 2018.2 (available now in the EAP) ReSharper C++ has initial support for C++/CLI. There are some limitations, so read on to find out more. Support is enabled by default, but can be disabled by going to ReSharper | Options | Code Editing | C++ | Inspections, and unchecking “Enable C++/CLI support”. But we hope you won’t do that – especially as we’re also looking for user feedback and greater field experience.
A peculiar beast
As a rule nobody uses C++/CLI as a primary language. That’s not what it’s been designed for. While C# is a highly productive language, and is no slouch when it comes to performance, there are many reasons that we may also have a parts of our project written in pure C++. C++/CLI is an answer to the question, “how do I get to, or from, my pure C++ from C# (or any .NET language)?”. If you just need to call into C++, and it exposes a C API, P/Invoke may be the simplest way to go. But for more complex cases – where you want to model richer types and class hierarchies – C++/CLI let’s you do that. But it comes at the cost of a more complex language, with curious syntactic additions and sometimes tricky lifetime issues. So any help we can get from our tools while writing and maintaining this code is very welcome.
What is supported?
ReSharper C++ 2018.2 gives us initial support for C++/CLI projects. What does that mean? Well first it means that the parser and resolver now finally understand the extension system, with ^’s for CLR references, gcnew for allocating on the managed heap, etc. It also means that many static analysis features now work and can give us valuable insight. Note that, at time of this writing, there may still be a few limitations here. Please report these in our issue tracker so we can address them as quickly as possible.
Within C++/CLI code we have access to all the same great refactorings and intention actions as in pure C++ code. For example postfix templates are a great way to rewrite statements around a value. Where applicable these should work across C++/CLI and pure C++ codebases – for example you can rename a pure C++ symbol, or even a C# symbol, from within a C++/CLI usage. Again, some limitations may apply.
We can also navigate between C# and C++/CLI worlds. For example if we place the caret over a C++/CLI method name in some C# code you can now navigate to the definition in the C++/CLI code (note that this is referred to as “Go to declaration” in the menu, due to how these terms are used in C#). You can do the same going the other way, too.
For now there are some known limitations here. For instance from a C# project in the same solution, renaming a C++/CLI symbol is not an option. From the C++/CLI project, renaming a symbol referred to by the C# project wll rename it within the C++/CLI code, but not in the C# project. As mentioned already, renaming a native C++ symbol from a C++/CLI project works as expected, however.
Code generation is also limited for now, as generators for C++/CLI specific constructs, such as ref classes, have not yet been written. And the #using directive (for importing metadata in directly from a dll) is not supported at all – meaning both the use of the #using directive, as well as any symbols referenced from the dll, will currently be flagged as errors by the analyser.
We need your help
C++/CLI is unique in many ways. Software projects that make use of it tend to be larger enterprise style projects of in-house code bases that cannot be shared outside the organisation. There is very little in the way of non-trivial open source projects using C++/CLI. Here at JetBrains we only use it in some small ways internally to the ReShaper C++ implementation. So it is particularly difficult to build realistic test cases. As we move to expand our coverage we’ll rely a lot more on the community to tell us what’s not working (of course we’d also love to hear what’s working, too!) so we can do our best to address it and make our C++/CLI support first class.
Last week we published a detailed overview of ReSharper C++ 2018.1 changes. One of the major features for this release is Includes analyzer, a tool for locating and eliminating unnecessary header dependencies and thus upping compilation speeds. You can read about it in detail in this blog post. Today though, we’d like to give you a short demo recorded by Phil Nash, our C++ tools developer advocate. Watch the Includes analyzer in action and download the free 30-day trial of ReSharper C++ to try it on your project:
If you find Includes analyzer useful or have questions or comments about it, please use the comment section below or our issue tracker to share your feedback with us. We’ll be glad to know what you think!
We are pleased to introduce ReSharper C++ 2018.1, our first major update this year!
This release comes with two new important features. First, Debug Step Filters lets you avoid stepping into specific functions during debugging. Second, Includes Analyzer helps investigate the dependencies between header files that affect build times. Read on for more details about these features and other highlights of the 2018.1 release:
When you invoke Step Into, the Visual Studio debugger will normally step into all the functions that are called from the current statement. However, there are functions (like simple getters, setters, or dereference operators), which are either trivial or so well tested that you never want to step into them. This is where step filters come in: with this feature, you can specify the functions that should always be stepped over.
A step filter is defined by a regular expression, which is matched against the name of the function that the debugger is stepping into. You can inspect, configure, disable, or enable back step filters on the Tools | Debugging | C++ options page, which lists all the available filters.
ReSharper C++ comes with a predefined collection of step filters for the standard library, but you can easily add your own. You can come up with a custom regular expression that matches the names of functions to step over and manually add a filter from the options page. Or you can have ReSharper C++ automatically create one during a debugging session.
When you step into a function and decide that you want to step over it in the future, you can use a context action to quickly add a new step filter. For template functions, there are separate context actions to add either only the current instantiation of the function template or all of its instantiations. If a matching filter has already been added to the list but was temporarily disabled, a context action will be available to enable it back.
The filters are stored using ReSharper’s layered settings. By default, the action to add a new filter follows the Smart Save logic, but you can use the action’s submenu to choose the layer to which the filter should be saved to. For example, you can use the Solution team-shared layer to make the new filter available to your teammates.
You might remember that Visual Studio has a built-in way to customize stepping behavior in C++, which is a part of C++ Just My Code. However, no user interface is provided for configuring this feature from the IDE, so you need to manually edit .natstepfilter XML configuration files to change existing or add new rules. Furthermore, there is no way to add solution-specific rules, since the configuration files are global. Please note that at the moment Visual Studio’s support for .natstepfilter files gets disabled if ReSharper C++ is installed.
Long build times is one of the biggest problems in large real-world C++ projects. ReSharper C++ already has a few tricks up its sleeve to aid you. For example, it will mark unused #include directives or automatically create forward declarations for unresolved names instead of simply including the headers with the required declarations.
ReSharper C++ 2018.1 introduces Includes Analyzer, a brand new code inspection tool that helps you speed up the compilation process.
Includes Analyzer is meant to help you locate and eliminate unnecessary header dependencies. A typical project might contain many thousands of #include directives, and it’s not clear which of them are worth investigating. Includes Analyzer attempts to estimate the contribution of each header file to the build time, based on the number of lines of code that it adds to the total compilation workload. While this is not a precise metric, it’s a useful starting criterion which can help you find and prioritize the most included header files.
After you identify the header dependencies that potentially have the biggest impact, you can try getting rid of them one by one via the standard approaches. These include: using forward declarations wherever possible, removing unneeded #include directives, applying the Pimpl idiom, splitting header files into smaller ones, and so on.
To start the analysis, invoke one of the ReSharper | Inspect | Analyze Includes in… actions from the main menu, or select Analyze Includes from the Solution Explorer context menu.
ReSharper C++ will analyze the files in the given scope and present a report in a dedicated tool window, where you can explore the dependencies between the files. The Includes analysis window provides two separate views, Includees and Includers, both of which present include dependencies as a tree where each node corresponds to a file. You can switch between the views via the corresponding toolbar buttons, or by navigating to the same file in the other view from the context menu.
The Includees view helps you understand how many lines of code the header file in a top-level tree node contributes to all source files that directly or indirectly include it. Child nodes in this view represent files that include the file from the parent node. Consider the following analysis of the entire Catch2 solution:
There are three metrics for each node in the tree:
Times included shows how many source files include the header in the top-level node through the path to the current node. In the example above, catch_common.h was included into 75 source files in total, of which 26 included catch_common.h through the #include "catch_common.h" directive in catch_tag_alias_autoregistrar.h.
Line contribution shows how many lines of code the header in the top-level node contributed through the path to the current node by itself, without transitively included files. catch_common.h contributed 4,050 lines of code in total, which is 75 (the number of source files that include it) times 54 (the number of lines of code in the file). Out of 4,050 in total, 1,404 lines were contributed because of #include "catch_common.h" in catch_tag_alias_autoregistrar.h.
Line contribution inclusive is similar to Line contribution, but this metric takes into account all headers transitively included into the file in the top-level node. E.g. catch_common.h, together with the headers included into it, contributes 2,654,938 lines in total during compilation of the entire solution. 1,017,626 of those lines were contributed because of #include "catch_common.h" in catch_tag_alias_autoregistrar.h. Line contribution inclusive is the default and arguably the most useful sorting criteria.
The Includers view is similar to the Includees view, but acts in the opposite way: the child nodes inside the tree represent files which are included into the file from the parent node.
This view shows how many lines of code are transitively included into the file in a top-level node as if it was compiled as a standalone source file (e.g. catch_common.h together with all headers included into it comprises 42,365 lines of code, of which 27,046 were brought with #include <string>). The metrics that this view provides are Includee count (the number of included files), Line count (the size of the file itself), and Line count inclusive (the size of the file with all the header files it includes).
One important limitation of Includes Analyzer is that ReSharper C++ does not actually run a full preprocessing stage in order to speed up the analysis process. This means that the line count does not in fact include the results of macro expansions, and that include guards do not get handled as well. Instead, ReSharper C++ assumes that each header file starts with an include guard or a #pragma once directive, and gets included at most once in any source file. Each successive include of the same header does not count towards its number of contributed lines, which means that sometimes you may encounter Times included and other metrics equal to zero next to an internal tree node.
In addition to navigation controls and the refresh button, the toolbar in the Includes analysis window lets you change two options:
Show only root nodes belonging to some project will hide top-level tree nodes that correspond to files not belonging to any project. This is a quick way to filter out library files if you want to concentrate only on headers inside your solution.
By default, ReSharper C++ skips blank lines and comments during an analysis. The Count blank and comment lines button lets you change this behavior.
We would like to give a shout-out to Header Hero, which inspired our own implementation of the same underlying idea. Check out the Caring by Sharing: Header Hero blog post, which introduces this great little tool and gives a few tips for improving project build times.
ReSharper C++ 2018.1’s biggest navigation update is the redesigned Go to File Member (Alt+\) dialog.
We have updated the dialog in several ways:
Class members in the open file are now grouped by their containing class in the results list.
With no search string active, file members are sorted in the order of their declarations inside the file.
The scrolling list with the results accommodates more items.
Together, these updates make the dialog more usable as they provide clearer insight into the structure of the current file.
In all Go to dialogs and several other places, ReSharper C++ now attempts to shorten symbol names that are excessively long, by omitting function and template parameters.
When you perform a search using the Recent Files dialog (Ctrl+,), Go to File search results are also appended to the results list after the Recent File items.
Finally, the option to remember the last search in the Search Everywhere dialog is now on by default. You can revert to the old behavior through the Environment | Search & Navigation | Remember last search setting.
Command-line code cleanup
ReSharper Command Line Tools, a free standalone collection of tools that can be used from the command line or as part of the continuous integration process, can now perform code formatting and cleanup in C++ projects. This instantly eliminates code style violations in a project or solution, and helps ensure a uniform code base.
To run the code cleanup tool on your solution, invoke cleanupcode.x86.exe from the command-line tools distribution with the path to the solution file. It will automatically reformat your code, fix common code style violations, remove redundant code, and optionally apply Clang-Tidy fix-its.
By default, command-line tools will use the predefined Full Cleanup profile, which includes the formatting stage and most (though not all) fixes for common code style issues, but skips the Clang-Tidy analysis stage. The other built-in profile is Reformat Code, which will apply only code formatting preferences. To use it, pass the profile name via the --profile command-line argument of cleanupcode.x86.exe:
ReSharper 2018.1 also fixes bogus errors which were output by the InspectCode tool on x64 projects. In addition, the upcoming 2018.1 release of TeamCity is able to run InspectCode on C++ projects (see TW-48978 for details).
ReSharper C++ 2018.1 adds several new built-in inspections:
A new inspection (with a corresponding fix and a code cleanup item) suggests replacing if statements with if constexpr when the condition is a compile-time constant expression.
Attempted usages of deleted functions are now diagnosed as errors, including usages via implicit function calls.
A new inspection warns about overriding destructors without the override specifier. There’s still debate in the C++ community whether destructors should ever be marked with override (for example, C++ Core Guidelines recommend against doing that), so the inspection is turned off by default. If you wish to use this inspection, please enable it on the Code Inspection | Inspection Severity options page.
Control flow and usage checking analyses have been updated to handle lambdas. This means that all the related inspections (unused variables and function parameters, unreachable code, redundant jumps, and many others), that previously worked only with functions, are also now available inside lambda bodies.
Finally, a minor change fixes the interaction between the Declarator is never used inspection and C++17 structured binding declarations. Previously, ReSharper C++ warned you about each unused structured binding separately from all the other bindings in the same declaration. We’ve changed this behavior so that if at least one of the structured bindings is used, the inspection does not trigger on any of the bindings.
Now all the major C++ compilers follow this logic, including MSVC starting with the update shipped in Visual Studio 15.7. If none of the bindings are used, you can still use the [[maybe_unused]] attribute to silence the inspection, but in practice you probably won’t ever need to.
More ways to configure inspection severity
In previous ReSharper C++ releases, inspection severity could only be set for the entire solution. But it is often required to be able to configure severity settings independently in different parts of the codebase, for example in legacy or test projects. In ReSharper С++ 2018.1, you can optionally enable the ability to have separate severity settings via the Read settings from EditorConfig and project settings option on the Code Inspection | Settings | General options page.
With this option turned on, you can set custom inspection severity using one of two approaches:
EditorConfig files. ReSharper C++ inspection severity can be specified inside an EditorConfig file using resharper_[severity id]_highlighting properties, where [severity id] is the name of the severity spelled in lower case with underscores. Depending on your needs, you can assign any value of do_not_show, hint, suggestion, warning or error to the property.
EditorConfig supports wildcard patterns in filenames, which means that inspection severity can be set independently even for specific files. A previous blog post entitled Configuring inspection severity with EditorConfig goes into more detail about using EditorConfig files, but do remember that you need to enable the option Code Editing | General Formatter Style | Enable EditorConfig support in order to have EditorConfig available.
Please note that enabling granular inspection severity might have a noticeable performance impact on the speed of code analysis, depending on your configuration and the number of issues in a given file.
Clang-Tidy integration updates
Clang 6.0 was released this March. To keep up, we have updated the Clang-Tidy binary bundled with ReSharper C++, with several user-visible changes:
The following checks have changed their prefix from misc- to bugprone-: misc-argument-comment, misc-assert-side-effect, misc-bool-pointer-implicit-conversion, misc-dangling-handle, misc-fold-init-type, misc-forward-declaration-namespace, misc-inaccurate-erase, misc-move-forwarding-reference, misc-multiple-statement-macro, misc-string-constructor, misc-use-after-move, misc-virtual-near-miss.
The following checks have changed their prefix from misc- to performance-: misc-inefficient-algorithm, misc-move-const-arg, misc-move-constructor-init, misc-noexcept-move-constructor.
Another new Clang-Tidy feature from the 6.0 release is the extended syntax of the NOLINT comment, which now accepts an optional list of check names to silence. ReSharper C++ adds a new inspection action that utilizes the new syntax and lets you disable a specific Clang-Tidy diagnostic on the current line:
We have also received several reports of Clang-Tidy crashes, with Windows displaying crash notifications as a result. While the ReSharper C++ team cannot fix the crashes themselves, we have changed the default error reporting mode used by the clang-tidy binary to prevent the annoying message boxes.
Unit testing support includes two minor updates:
ReSharper C++ 2018.1.1 fixes compatibility with Boost.Test from Boost 1.67 (which was broken because of a bug in Boost.Test).
The new setting Tools | Unit Testing | C++ Tests | Use command-line arguments… lets you manage whether ReSharper C++ should use the value of the Debugging | Local Windows Debugger | Command Arguments project property when running unit tests.
Other changes to ReSharper C++ include:
The #include_next preprocessor directive is now supported, for better compatibility with compilers that implement this GNU extension.
Typing assistance in C++ files automatically removes trailing whitespaces on Enter in order to keep your code clean of redundant whitespaces.
If you select an expression and open the Quick Documentation window, it will show various information about the selected expression, such as its type, value, and value category. You can use this ability, for example, to quickly evaluate a type trait for a specific type:
The /Y- (ignore precompiled header options) and /Zc:__cplusplus (enable the updated value of the __cplusplus macro) command-line MSVC compiler arguments are supported.
The performance of the completion pop-up and start-up time have been improved in several cases.
If you’d like to learn more about how C++ tools can improve your development workflow, Anastasia Kazakova (C++ tools PMM at JetBrains) recently gave a talk at the ACCU 2018 conference entitled Debug C++ Without Running. In her talk, Anastasia discusses a few peculiarities of the C++ language that contribute to its notorious complexity and demonstrates some helpful features from ReSharper C++, CLion, and other C++ tools.
Why do you need step filters? Well, the illustration below explains pretty much everything:
Some functions never need to be stepped into because they are either very simple or very well tested. But the problem is that the debugger cannot tell which functions are worth debugging and which aren’t, and therefore Step Into will not miss any user function on its way.
Visual Studio’s Just My Code functionality takes basic care of this problem by ignoring non-user code and letting you customize ignored symbols using text config files.
However with ReSharper C++, you can now visually maintain step filters — a list of function masks that tells the debugger what should be skipped on stepping. By default, this list includes a lot of library functions and it can be extended.
Of course, ReSharper wouldn’t be ReSharper without having some handy goodies here: to quickly add a function to the filters, you can press Alt+Enter on that function while debugging and pick the corresponding action:
The filters are stored using ReSharper’s layered settings. By default, the action saves the filter in the ‘Solution personal’ layer, but you can use the action’s submenu to choose where the filter should be saved — e.g in the ‘Solution team-shared’ layer, so that this filter will be also available to your teammates.
You can study and further configure step filters on the Tools | Debugging | C++ options page:
Clang-Tidy is a powerful open-source code analysis tool based on the popular Clang compiler. It comes with an extensive set of code checks and accompanying fixes for typical programming errors.
ReSharper C++ 2017.3 provides seamless integration with Clang-Tidy. This means that as you edit a file, ReSharper C++ runs Clang-Tidy on it in background as a separate process, with inspection results shown right in the editor alongside other ReSharper C++’s inspections. Unsaved files are handled transparently by saving the text of the current document to a temporary file and instructing Clang-Tidy to use it instead of the on-disk version.
To distinguish between Clang-Tidy checks and ReSharper C++’s inspections, look at the name of the check in square brackets, appended to the inspection message.
In addition to diagnostics from Clang-Tidy checks, Clang-Tidy also issues diagnostics from Clang Static Analyzer and warnings provided by the Clang compiler itself. All of them have corresponding ReSharper inspections with configurable severity levels, which can be adjusted to meet your needs on the Inspection Severity options page.
Some of the Clang-Tidy checks that duplicate ReSharper C++’s built-in inspections are turned off by default. In addition, all static analyzer checks are disabled, since enabling them significantly slows down Clang-Tidy.
As with the built-in inspections, you can use the inspection context menu to quickly change the severity of a Clang-Tidy check, or to disable it via a comment. There is also an additional action that opens the online documentation page for a particular check.
ReSharper C++ lets you apply the fixes provided by Clang-Tidy similarly to its own built-in quick-fixes. As with other bulk fixes, Clang-Tidy fixes can be applied individually or inside a specific scope (file, folder, project, or solution).
By default, ReSharper C++ will reformat code changed by Clang-Tidy to maintain the code style. This behavior can be disabled via the Reformat changed code after applying Clang-Tidy fix-its setting to speed up fix execution.
Clang-Tidy fixes can also be applied from code cleanup. Built-in code cleanup profiles do not include the Clang-Tidy stage, so to enable it you need to create a new profile and select the Clang-Tidy checks which will be enabled during a code cleanup run.
The selected checks will be enabled even if they are turned off on the Inspection Severity options page. Please be careful when enabling too many checks at once — code cleanup runs Clang-Tidy only once for a given file, so if multiple fixes touch the same block of code, the changes might conflict with each other.
ReSharper C++ does not write its own Clang-Tidy config, so a user-provided one can be picked. Clang-Tidy attempts to read configuration for each source file from a .clang-tidy file located in the closest parent directory of the source file. The source file here (as with the rest of ReSharper C++ inspections) is the .cpp file itself if the analysis is run on it, or a random .cpp file which includes the header when the analysis is performed on a header file. Alternatively, you can use the Clang-Tidy config ReSharper setting to pass a string with custom configuration to Clang-Tidy via the -config command-line option.
The -checks command line option is used to pass the list of enabled checks to Clang-Tidy, which then gets appended to the value of the checks option read from the Clang-Tidy config. To construct the -checks argument, ReSharper C++ takes the value of the List of enabled/disabled Clang-Tidy checks and appends to it the names of checks which are turned off on the Inspection Severity options page.
We needed to make a few modifications to Clang-Tidy to facilitate its usage from the IDE, so unfortunately a custom Clang-Tidy binary cannot be used at the moment. ReSharper C++ 2017.3 is shipped with a version of Clang-Tidy built from the trunk, and we plan to update it to the final Clang 6.0 version in ReSharper C++ 2018.1.
There are a few caveats to Clang-Tidy integration that we are aware of:
Files using UTF-16 or UTF-32 encoding cannot be read by Clang and thus are not supported by Clang-Tidy at the moment.
Sometimes Clang-Tidy might crash on your code, and Windows will show you the “Process has stopped working” message. In this case please disable Clang-Tidy integration for the current solution (see how below). We’ll update the bundled binary in 2018.1 so that this message is not shown.
There are several ways to disable or enable Clang-Tidy integration:
Via the Enable Clang-Tidy support setting in ReSharper options.
Through the Enable Clang-Tidy analysis toggle in the status indicator context menu:
With the Ctrl+Shift+Alt+9 keyboard shortcut.
ReSharper C++ 2017.3 is the first release that brings debugger-related features to the table. The most useful of them is inline watches: ReSharper C++ will display local variables, function parameters, current line expressions, and function return values right inside the editor. This feature provides immediate feedback during debugging sessions, which means that often you don’t even have to consult the Watches or Autos tool windows.
ReSharper C++ is careful to evaluate only those expressions that do not have side effects. At the moment, expression evaluation is limited to references, constants, member access, and built-in subscript operators. Subscript operators of std::vector and std::array are also evaluated as an exception. Please note that inline watches use the Visual Studio debugger engine to evaluate expression, which means that Natvis files with user-provided visualization rules are automatically supported.
ReSharper C++ also comes with its own debugger DataTips, which provide several advantages over their Visual Studio counterparts:
You can quickly search for a string inside a DataTip (just start typing with the DataTip open).
You can mark members of a class which will be used to construct a custom presentation string for objects of this class. To do this, invoke Highlight Property from the context menu on class members that you are interested in.
Unlike Visual Studio DataTips, ReSharper DataTips do not disappear when the mouse pointer leaves the DataTip window area.
To access ReSharper DataTips, just click the inline value display. If you find ReSharper DataTips helpful, you can replace Visual Studio DataTips with ReSharper’s by enabling Override VS DataTips with ReSharper DataTips on the Tools | Debugger ReSharper options page.
Working with multiple breakpoints should now become easier. The new Go to Breakpoint action (Ctrl+Alt+F9) displays breakpoints in a context menu so that you can quickly navigate between them. In addition, the dedicated R# Breakpoints tool window (ReSharper | Windows | Breakpoints) groups breakpoints and displays the line of code where each breakpoint was set.
Breakpoints and tracepoints can also be created directly in the Find Results tool window, from the occurrence context menu.
But that’s not all — we are working on adding new debugger-related features. In particular, ReSharper C++ 2018.1 will bring debug step filters, a feature which lets you make the debugger step over certain functions (e.g. subscript operators or trivial getters). If you are interested in trying it, head over to the Early Access Program page when the EAP starts and install the latest available ReSharper 2018.1 build.
For the 2017.3 release, we specially focused on improving the product’s understanding of C++. We made sure the following new C++17 and C++14 features received support:
C++17 structured binding declarations allow declaring multiple variables that bind to subobjects of another object. This is particularly useful when working with functions that need to return multiple values. As with other identifiers, you can determine the actual types of structured bindings via ReSharper C++’s tooltips or the Quick Documentation popup.
Structured binding declarations support binding to array elements, public class data members, and tuple-like objects. Making your own classes support the tuple-like binding protocol requires specializing std::tuple_size and std::tuple_element, and if something goes wrong, ReSharper C++ will provide you with detailed error messages.
Return type can now be deduced for C++14 auto functions without trailing return types.
Supporting this language feature was rather complicated because, to determine the return type of a function declared in a header file, its body is needed. On the upside, implementing it also allowed us to fully support C++17 constexpr if statements, which can cause a function to have different return types depending on which constexpr if branch is chosen.
Type checking and return type deduction now work for lambda expressions, including support for C++14 generic lambdas.
Previously only functions could be declared as inline, but in C++17 variables can be declared inline too. This is now supported by ReSharper C++, and a warning will be issued when the inline specifier is required to avoid linking errors.
All in all, this brings ReSharper C++ almost to the level of standard C++ support provided by the Visual C++ compiler at the moment, with two notable features still in our queue to implement — fold expressions and evaluation of constexpr functions.
Other language-related changes include:
ReSharper C++ now understands include_alias pragma directives, which allow mapping any header filename to another.
Improved support of explicit template instantiations. In particular, explicit instantiations of both class and function templates are now handled correctly by the Rename refactoring, and can be navigated to via gutter icons.
ReSharper C++ 2017.3 extends its set of available code inspections:
Binary operators with suspiciously looking identical or equal operands will be highlighted.
Default arguments on virtual functions are considered bad style (see e.g. Google’s C++ style guide for details). ReSharper C++ now includes an inspection which finds redefinitions of a default argument from a base function.
const and volatile specifiers on parameters in a function declaration have no effect and will be shown as dead code.
Function parameters that are not mentioned in the function documentation comment will be underlined, with a fix to insert the corresponding documentation line.
Member initializers in constructors that duplicate the corresponding default member initializers will be marked as redundant.
All user-defined literal suffixes must start with the underscore character according to the C++ standard. ReSharper C++ will warn you about literal operators that violate this requirement.
A couple of context actions were also added:
An action to move a member initializer from a constructor member initializer list to a default member initializer.
An action to switch between class and typename keywords in type template parameter declarations.
If you wish to preserve custom formatting just inside a block of code, ReSharper C++’s formatter can now be selectively disabled by wrapping this block with a pair of comments containing formatter directives: // @formatter:off to disable formatting, and // @formatter:on to enable it back.
Instead of disabling the formatter completely, you can configure it using inline EditorConfig-style settings and override only one or several of them, keeping common code style settings active. Please refer to the EditorConfig Properties help page for the list of supported properties.
Another long-requested formatter feature is the ability to align specific code elements in columns, which is now supported for assignment statements, declaration names, and single-line comments (configured by a family of settings in Indentation and Alignment | Align Similar Code In Columns).
There’s also a related multiline alignment setting, which controls the outdenting of command and member access operators in chained method calls.
The layout of linkage specification blocks can now be customized via two formatting settings, Indentation | Indent linkage specification block members and Braces Layout | Linkage specifications. The usual idiom of using extern "C" blocks in header files to create an API compatible with C is now supported:
Finally, two new settings, Spaces | Before/after commas in uniform initialization braces and Spaces | Before end of line comment, provide more options to match spacing in your code.
The Go to Declaration command is now available on dependent names inside definitions of templates. This should make it much more useful in template-heavy code. Since ReSharper C++ has no way of finding the exact entity that the name refers to, instead it will look through all the symbols and offer those with matching names and signatures as potential navigation targets.
In addition, Go to Declaration now lets you navigate from a member function definition to a declaration with a non-matching signature if no matching declaration is found. This ability comes in handy when you change the definition and need to update the declaration (even though we encourage you to use the Change Signature refactoring and related fixes for this purpose).
To-do patterns get a URL field, which creates a link in your code for navigating to external resources by Ctrl+Click on the to-do item, or via the Alt+Enter shortcut. This helps you keep your to-do comments brief and straightforward: no full URLs are needed, only an issue ID. Links in to-do items support the Peek Preview feature to display the linked issue inline in the editor. Also, you can easily locate the to-do item in To-do Explorer via the Alt+Enter menu.
Smaller navigation-related changes include:
Search Everywhere always shows text matches in a dedicated section, even when there are other results. So, you do not need to switch to Go to Text when you want to take a peek at text occurrences.
When occurrences are shown in the Find Usages window, ReSharper C++ considers and presents the context (e.g. function calls or return statements) from the surrounding lines.
The redesigned preview pane in ReSharper tool windows (shown above) and formatter options pages are now based on the Visual Studio editor. This gives preview pane code a more natural look: keywords and strings are highlighted, identifier colors are applied, and font settings and scaling are inherited from Visual Studio’s text editor settings.
Catch2, the latest version of the popular Catch unit testing framework, is now supported. Its codebase has been updated to use C++11, with strong focus on both compile and runtime performance. If you are interested in learning more about new Catch2 features and Catch in general, a good place to start would be the announcement blog post and the Modern C++ testing with Catch2 talk by Phil Nash, the author of Catch.
The Performance Guide page in ReSharper options collects a set of Visual Studio and ReSharper settings that might affect overall performance in one place and provides a way to quickly change them.
While it does not have any C++-related tips yet, it can still help you improve the general responsiveness of your development environment.
Generative completion now allows creating definitions not only for member functions, but also for free functions.
Built-in live templates cctor and mctor which expand to a copy and move constructor, accordingly, were added.
We’ve added the setting Use trailing return types in generated function declarations (in ReSharper | Options | Code Editing | C++) for trailing return types afficionados. When it is enabled, various code generation features will create function declarations with trailing return types instead of using the classic return type style.
Numerous performance issues were resolved. Most importantly, typing assist and completion lags in Visual Studio 15.5 and slow renaming of files were addressed. Additionally, nested queries in Go to Symbol should execute much faster now.
We hope you find the new features useful! Please leave us any feedback and report issues either in the issue tracker or on the support forum.