Early Access Program

ReSharper C++ 2021.2 EAP: Inline Function Refactoring, Modernizing Inspections, Faster Clang-Tidy

We are moving into the next stage of this EAP cycle with a new set of features and fixes. Today’s EAP build comes with:

Starting from this EAP build, you can join the program only if you have an active JetBrains account. If you have already logged in, you can access the EAP builds automatically. If you have not yet logged in, you will be redirected to this page, where you can enter your credentials or create a new JetBrains account. You can learn more in this blog post.

DOWNLOAD RESHARPER C++ 2021.2 EAP

Inline Function refactoring

With ReSharper C++, you can use the Extract Method refactoring to create a new method based on the selected code fragment. Before 2021.2 this only worked in one direction, but now you can use the opposite code transformation – the new Inline Function refactoring!

The Inline Function refactoring is usually used when the function body is quite obvious, so code will become more straightforward if you minimize the number of extra function calls. To invoke it, place the caret on the function call and select Inline Function from the Refactor This menu, or choose ReSharper | Refactor | Inline from the main menu.
Inline Function refactoring

If the refactoring is applicable, ReSharper C++ will perform the necessary transformations, handle all name conflicts for used variables, and reformat the resulting code. Otherwise, there will be a short pop-up message explaining why it’s not a good idea to try inlining some method.
Cannot inline virtual function

Please give it a try and let us know if there is anything we should adjust. Your feedback is always welcome!

Modernizing inspections

We’ve added two new inspections that help you modernize your code:

  • std::size can be used. The C idiom for array size calculation is error-prone and works incorrectly when the sizeof operator is applied to a pointer instead of a built-in array. This happens, for example, with decaying function parameters (void f(int arr[3])) or dynamically allocated arrays (int arr[]). The new inspection suggests using std::size as a type safe alternative.
    std::size can be used
  • Zero initialization can be used instead of memset. The accompanying quick-fix replaces memset with a modern zero-initialization to shorten expressions and prevent various memset related errors like underflows while filling in an object of the wrong size.
    Zero initialization can be used instead of memset

Faster Clang-Tidy analysis

We’ve improved the performance of the bundled Clang-Tidy. You might have noticed a message about some long-running analyses still working in the background on files with a lot of included code, particularly in C++20 projects:
Low-priority analyses still running in the background

Code analysis now finishes up to several times faster on such files.

That’s all the news for now. As usual, the EAP build is free to use and available for download from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ 2021.2 EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

image description