The ReSharper C++ Blog : The Visual Studio Extension for C++ Development | The JetBrains Blog https://blog.jetbrains.com Developer Tools for Professionals and Teams Fri, 16 Jun 2023 15:22:38 +0000 en-US hourly 1 https://blog.jetbrains.com/wp-content/uploads/2023/02/cropped-icon-512-32x32.png The ReSharper C++ Blog : The Visual Studio Extension for C++ Development | The JetBrains Blog https://blog.jetbrains.com 32 32 ReSharper C++ 2023.2 EAP: Support for the C++23 Standard Library Modules https://blog.jetbrains.com/rscpp/2023/06/16/resharper-cpp-2023-2-eap5/ Fri, 16 Jun 2023 15:22:35 +0000 https://blog.jetbrains.com/wp-content/uploads/2023/05/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=364095 The new Early Access build is here with support for the C++23 standard library modules and C++20’s [[no_unique_address]] attribute, new code formatter settings, and other updates. Read on for more details and check out the full list of issues we’ve fixed in this update.

You can download the EAP builds from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ EAP

C++20 and C++23 updates

The C++23 standard library introduces two named modules: std and std.compat (P2465). You can now use import std or import std.compat to import the entire standard library instead of using a precompiled header or including specific headers for the parts of the standard library that you need. This way you’ll also get all the usual benefits associated with the C++20 modules, including much faster compilation time and the absence of hidden dependencies on the standard library internals.

In addition to shipping the source code for the std and std.compat modules in the standard library, Visual Studio 17.6 introduced a new setting that enables the automatic building of these modules when using the /std:c++latest switch (Project Properties | C/C++ | Language | Build ISO C++23 Standard Library Modules). As of this EAP build, ReSharper C++ will correctly resolve import directives for standard library modules and automatically build the necessary ones. This makes it much easier to experiment with modules and benefit from improved compilation time (depending on the size of your project, of course).

C++23 Standard Library Module

C++20 added char8_t, a new fundamental, unsigned integral type that stores one UTF-8 code unit. The recently accepted paper P2513 allows the initialization of a char or unsigned char array with a UTF-8 string literal. Visual Studio has supported this proposal since the 17.4 release, and now ReSharper C++ supports it as well. Interestingly, this change has also been backported to C++20 as a defect report. Yes, the language standard can have bug-fix updates too!

Compatibility and portability fix for char8_t

We’ve also introduced support for the C++20’s new [[no_unique_address]] attribute, which can be used instead of relying on the empty base class optimization. [[no_unique_address]] indicates that a unique address is not required for a non-static data member of a class (P0840), allowing the compiler to lay out members of the class in a more efficient way. ReSharper C++ now takes [[no_unique_address]] into account when calculating the size of an object.

[[no_unique_address]]

Code analysis

ReSharper C++ now highlights the #error and #warning diagnostic preprocessor directives according to their severity level:
#error and #warning diagnostic preprocessor directives

We’ve improved the evaluation engine to support aggregate initialization of constexpr arrays.
aggregate initialization of constexpr arrays

This EAP build also brings a new compatibility inspection for forward declarations of C-style enums. Since the size of a C-style enum depends on its contents, the C++ standard forbids forward-declaring them without specifying the underlying type. MSVC, however, still accepts forward declarations like that, which can lead to non-portable code:

ISO C++ forbids forward enum declarations without underlying type

Code formatting

In this EAP build, we’ve improved the formatting for bit-field members. The options to align initializers and declaration names in columns now support bit-fields. We’ve also added two new formatter settings specifically for bit-fields:

  • Spaces before and after the colon in bit-field declarations.
  • Alignment of bit-field sizes in columns.

formatting for bit-field members
Finally, there is a new setting to turn off indentation in member initializer lists.

Among other noteworthy updates, the Safe Delete refactoring now handles conflicts in dependent code. And for Unreal Engine 5.1 projects, we’ve introduced support for the UE_INLINE_GENERATED_CPP_BY_NAME macro, which lets you inline generated files into your module to improve compilation time. UE_INLINE_GENERATED_CPP_BY_NAME is now correctly handled when ordering #include directives, and it does not cause issues for the Rename refactoring.

That’s all for now! Please try out the new build and share your feedback with us. If you encounter any issues, don’t hesitate to report them to our issue tracker.

DOWNLOAD RESHARPER C++ EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2023.2 EAP: Improvements for Navigation and Coding Assistance https://blog.jetbrains.com/rscpp/2023/06/06/resharper-cpp-2023-2-eap3/ Tue, 06 Jun 2023 11:26:39 +0000 https://blog.jetbrains.com/wp-content/uploads/2023/05/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=360202 The new Early Access Program build is here with gutter marks for recursive calls, improvements for more intuitive code navigation, and support for the .cppm module interface file extension! Read on for more details and check out the full list of issues we’ve fixed in this update.

You can download the EAP builds from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ EAP

More intuitive code navigation

This update brings several improvements for more consistent and straightforward code navigation without extra steps:

  • When invoked on a class name in a constructor call, Go to declaration now navigates to the constructor instead of the containing class. Previously, you had to invoke Go to declaration on the corresponding braces or parentheses to navigate to a constructor.
  • Go to declaration now navigates to the first typedef or type alias declaration instead of showing the menu with all declarations.
  • Type of symbol is now available on non-declarator symbols. The way it works there is similar to Go to declaration.

Coding assistance updates

When generating documentation comments, ReSharper C++ will now adjust the documentation template according to the comment style from the editor. For /**, typing assistance will generate the comment in the /** */ style, and for ///, the comment will be in the /// style.
Documentation comments style

We’ve also introduced a new typing assist option to turn off the generation of documentation comments to avoid conflict with the Visual Studio built-in generator (ReSharper | Options | Environment | Editor | Behavior | C++, C, HLSL | Generate documentation comments).

If you have a recursive call, ReSharper C++ will mark it in the gutter, making it more visible:
Recursive call gutter marks

Other improvements

If you use module interfaces with a different extension than the standard .ixx, ReSharper C++ now also recognizes .cppm as a module interface file.
cppm module interface file

There is a new inspection for redundant template arguments that match the default template argument:
Redundant template arguments

The code completion list now filters out reserved identifiers and suggests them only after “_“. This means you no longer have to scroll through the suggestions from standard libraries unless you need them.
Filtering out reserved identifiers

We’ve also added scoped fixes and code cleanup tasks for dereference inspections implemented in the previous build, Make variable constexpr, and Replace if with if consteval.

That’s all for now! Please try out the new build and share your feedback with us. If you encounter any issues, report them to our issue tracker.

DOWNLOAD RESHARPER C++ EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ Starts the 2023.2 Early Access Program https://blog.jetbrains.com/rscpp/2023/05/15/resharper-cpp-2023-2-eap-safe-delete/ Mon, 15 May 2023 13:47:43 +0000 https://blog.jetbrains.com/wp-content/uploads/2023/05/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=354770 The ReSharper C++ 2023.2 Early Access Program starts today!

Give the free EAP builds a try and let us know what you think about the changes and improvements they introduce.

ReSharper C++ 2023.2 EAP

You can download the EAP builds from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ EAP

Safe Delete refactoring

ReSharper C++ introduces the Safe Delete refactoring to let you remove symbols from the source code safely. Starting with this EAP build, the refactoring is available for deleting a class, function, variable, namespace, and even a concept.

“What makes this refactoring safe?” you might ask. The trick is that before deleting a symbol, ReSharper C++ searches for usages and lets you preview the results, so you can be sure that all the removals are intended. For example, if you try to delete a complex entity, like a class or namespace, ReSharper C++ will recursively check the usages for all its members.

To invoke the refactoring, place the caret on the item you want to delete and select Safe Delete from the Refactor This menu. Alternatively, choose ReSharper | Refactor | Safe Delete from the main menu, or use the corresponding shortcut (Alt+Del or Ctrl+R,D, depending on the shortcut scheme you use).

Safe Delete

If you want to keep some code slated for removal, double-click on the usage in the list to navigate to the corresponding line and make the necessary adjustments. Once you’re happy with the list of usages to be removed, click Next to confirm your code deletion.

Safe Delete conflicts

C++23’s if consteval

C++20 brought several new features related to constant evaluation, including consteval (P1073) and std::is_constant_evaluated() (P0595). As a quick recap, the consteval keyword specifies a function that can be evaluated only during compile-time, while std::is_constant_evaluated() is a library function that checks whether the current evaluation is a constant evaluation.

C++23 fixed some interaction issues for these features and further developed the idea by introducing the if consteval statement (P1938). If the evaluation of this statement occurs during a constant evaluation, then the following compound statement is executed. Otherwise, the else branch is executed.

In this EAP build, ReSharper C++ introduces support for if consteval and brings new inspections to help you play around with recent language additions for constant evaluation:

  • consteval if is always constant” warns you when the condition is always true in the immediate context.
  • std::is_constant_evaluated will always evaluate to constant” warns you when the function result is always true in a manifestly constant-evaluated expression.
  • if can be replaced by if consteval” suggests a quick-fix to update your code in C++23 style.

if can be replaced by if consteval

Updates for C++20’s concepts support

With improved completion for dependent code, you will now get completion items when the type is restricted by concepts or traits. ReSharper C++ now considers the full variety of std::is_same/std::is_base_of type traits, their _v value-aliases, the corresponding std::same_as/std::derived_from concepts, and the Unreal Engine TIsSame trait.
Completion for concepts

For more helpful code completion suggestions, ReSharper C++ now also extracts type and value requirements from a requires-clause, if constexpr, and SFINAE, like template <class T, class = std::enable_if_t<std::is_base_of<X, T>>> void foo(T arg);.

A new context action will help you move the template parameter constraint to a requires-clause:
Move constraint to requires-clause

There’s also a complementary context action to help you with the opposite update – converting a requires-clause to a template parameter constraint:
Convert clause to parameter constraint

Finally, all the usual ReSharper C++ inspections for unused entities now also work for templates and concepts.

Other improvements

ReSharper C++ 2023.1 introduced proper highlighting and formatting for macro substitution in the Quick Documentation popup and tooltips on hover. For consistency, starting with this EAP build, these improvements will also work for macro definitions themselves:
Macro definition tooltip

When you specify the parameter direction with the [in], [in,out], or [out] attribute of the Doxygen param command, the tooltips now fetch them from your comment:
Doxygen parameter direction

This EAP build adds a new inspection that detects redundant dereferencing and taking addresses. It offers you several quick-fixes to remove the redundancies:

  • “Operator . can be replaced with ->” and vice versa.
    Operator . can be replaced
  • “Taking address of dereferencing can be removed” and vice versa.
    Taking address of dereferencing can be removed

ReSharper C++ now supports the /Zc:preprocessor compiler option, which enables preprocessor conformance mode.

We’ve also updated the bundled clang-tidy binary to Clang 16, providing new checks.
clang-tidy 16

Those are the biggest highlights for this first EAP build. If you have any feature requests or encounter any issues, please submit them to our tracker. We are looking forward to your feedback!

DOWNLOAD RESHARPER C++ EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2023.1: Call Tracking, Macro Expansion Preview, and Support for C++23 Features https://blog.jetbrains.com/rscpp/2023/04/05/resharper-cpp-2023-1/ Wed, 05 Apr 2023 12:09:59 +0000 https://blog.jetbrains.com/wp-content/uploads/2023/04/Release_Preview_image_1280x600_ReSharperCPP_released.png https://blog.jetbrains.com/?post_type=rscpp&p=340363 We’ve just released ReSharper C++ 2023.1!

This update brings support for new C++20 and C++23 features as well as improvements for C++20 modules, Call tracking, macro substitution previews, context actions for refactorings, and file templates for Unreal Engine tests. To learn about all of the improvements in this release, check out our What’s New page.

ReSharper C++ 2023.1

Update to this version, or start a free 30-day trial today! The brand-new build is available on our website, and all our tools for Visual Studio can be downloaded via the Toolbox App.

DOWNLOAD RESHARPER C++

Without further ado, let’s take a look at the key features in the new version:

Call tracking

ReSharper’s Call tracking has finally come to ReSharper C++! You can now view and navigate through call chains in the hierarchy of incoming calls. Just place the caret at any function and select Inspect | Incoming calls from the context menu or press Ctrl+Shift+Alt+A to invoke it from the Inspect This menu.

Call tracking

In the call tracking results window, you can double-click on the hierarchy entry to navigate to the corresponding call in the editor or expand any node to check out its incoming calls.
Tracking outgoing calls is currently not supported.

Macro substitution preview

When hovering over a macro, you can now see the macro expansion in the tooltip with full syntax highlighting and proper code formatting. You can still use the Substitute macro call context action to check out the macro expansion right in the code, but the instant preview makes working with macros easier.
Macro substitution preview

Additionally, the Quick Documentation popup (Ctrl+Shift+F1) allows you to click on any entity from the substitution preview to check out its documentation.

Updates for C++20 modules

ReSharper C++ 2022.3 introduced initial support for C++20 modules. In this update, we’ve polished our implementation to handle more corner cases and better support real-world projects that use them. We’ve also expanded the list of ReSharper C++ features that help you write modularized code:

  • Find usages now lets you find all locations where a given module is imported.
  • The Rename refactoring helps you safely rename modules and module partitions, updating all the relevant declarations and imports in your code.
  • The code formatter and Rearrange code now handle export blocks and exported entities.
  • Code completion suggests the module-related keywords and names of known modules.

Completion for C++20 modules

Support for C++23 features

The ISO C++ Standards Committee has recently completed the technical work on C++23. With many C++23 features already available in the major compilers, ReSharper C++ 2023.1 is here to help you try out the following new language features:

  • With Deducing this (P0847), you can now make the object parameter explicit with the this keyword, which simplifies the implementation of several C++ idioms.
  • auto(x) and auto{x} (P0849) allow you to make a copy of the argument as if it were passed as a function argument by value.
  • Empty parentheses () in lambdas are now optional in many cases (P1102).
  • Alias declarations are now allowed in init statements (P2360).
  • Labels are now allowed at the end of compound statements (P2324).

Deducing this
Check out this blog post for more details about new C++23 features.

Unreal Engine

You can now quickly add a simple or a complex Unreal Engine test using the new built-in file templates. Just go to Solution Explorer and right-click on the preferred project folder to open the Add menu (or use Ctrl+Alt+Insert).

Unreal Engine tests

Among other updates for Unreal Engine projects are mappings for shader source directories, a live template to add a new UINTERFACE class, and a completion item that lets you generate a lambda expression where a delegate, TFunction, or TFunctionRef argument is expected.

Consider Rider if you’re interested in a stand-alone cross-platform IDE for Unreal Engine development, consider Rider. Unreal Engine support in Rider and ReSharper C++ is aligned, and you can expect the same improvements in the Rider 2023.1 update.

Refactorings

You can now access most of the refactorings easily from the Alt+Enter menu in addition to the dedicated Refactor This popup (Ctrl+Shift+R).
Extract method in the Alt+Enter menu

This release includes many bug fixes and usability improvements for the Change signature and Extract method refactorings, and also a new quick-fix to create parameter from an unresolved identifier.

Create parameter

Code analysis

We’ve introduced an inspection that flags function parameters of expensive-to-copy types that are passed by value, with a quick-fix to pass the parameter by const reference instead.

Pass a parameter by const reference

The following new code inspections warn you about potential code smells:

  • Template parameter is never used.
  • Typedef/type alias is never used.
  • Redundant base class initializer.
  • Function result of type HRESULT/NTSTATUS should be used.

One more inspection lets you know when C++17 class template argument deduction fails to deduce the template arguments, allowing you to quickly add the required arguments with a fix.

ReSharper C++ 2023.1 also includes many improvements for the compile-time evaluation engine, such as the evaluation of range-based for loops and better support for unions.

Other changes

ReSharper C++ now supports the __VA_OPT__ macro, which was introduced in C++20 to help define variadic macros. This special functional macro expands to its arguments when the variable argument list is not empty and expands to nothing otherwise.

__VA_OPT__

Other important changes include an option to sort #includes in path-order or alphabetically, a postfix template to quickly make a const reference with std::as_const or AsConst, and disabled auto-insertion of the closing */ comment.

Those are the highlights of this release! We’ve also addressed many quality and performance issues – check out the full list of fixed issues in our YouTrack. More changes are coming from the ReSharper platform, like CSS support being disabled by default.

If you have any feedback or questions, please don’t hesitate to reach out to us and report issues to our tracker.

DOWNLOAD RESHARPER C++

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2023.1 EAP: __VA_OPT__ and Updates for Modules https://blog.jetbrains.com/rscpp/2023/03/10/resharper-cpp-2023-1-eap-va-opt/ Fri, 10 Mar 2023 14:56:37 +0000 https://blog.jetbrains.com/wp-content/uploads/2023/01/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=331946 A new EAP build for ReSharper C++ 2023.1 is here! Read on for details about features we’ve introduced over the last few builds and give the new version a try.

DOWNLOAD RESHARPER C++ EAP

C++20 macro __VA_OPT__

The long-awaited support for __VA_OPT__ is finally here! This special functional macro was introduced in C++20 to make variadic macros easier to use without arguments. If there are no variadic arguments, then __VA_OPT__(content) expands to nothing. Otherwise, it is replaced by content, which can contain any admissible replacement text, including __VA_ARGS__. Give it a try with our recent improvement for working with macros – the macro substitution preview in tooltips:
__VA_OPT__

С++20 modules

We keep improving how ReSharper C++ works with C++20 modules. This EAP build resolves two limitations in the initial support:

  • With the updated Find usages, you can now find all locations where a given module is imported.
    Completion for C++20 modules
  • You can now use the Rename refactoring to safely rename module partitions and named modules.
    Rename C++20 module

Unreal Engine

ReSharper C++ offers a new UINTERFACE live template for Unreal Engine solutions. Similar to the existing UCLASS, USTRUCT, and UENUM live templates, it allows you to quickly add a new interface class:
UINTERFACE live template
You can use the Templates Explorer (ReSharper | Tools | Templates Explorer) to edit the templates according to your needs and development practices.

Code analysis

We’ve introduced two new inspections to warn you about potential code issues:

  • Unused template parameterUnused template parameter
  • Unused return value of HRESULT/NTSTATUS typeUnused return value of HRESULT/NTSTATUS type

This build also includes many bug fixes and improvements for compile-time evaluation, including evaluation of unions and range-based for loops.

Other changes

Convert to scoped enum and a set of refactorings to Introduce variables, fields, using enum, typedef, and namespace aliases are now available as context actions in the Alt+Enter menu.

Comments beginning with /* are no longer auto-closed with */ by default. You can enable auto-insertion of the closing comment with the new Insert */ after /* typing-assist option:
Auto-insertion of the closing comment

We’ve also added a new formatting option for spaces around unary operators.

And last but not least, ReSharper C++ now supports C++23 alias declarations in init statements (P2360).

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

DOWNLOAD RESHARPER C++ EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2023.1 EAP: Call Tracking and C++23 Features https://blog.jetbrains.com/rscpp/2023/02/03/resharper-cpp-2023-1-eap3-call-tracking/ Fri, 03 Feb 2023 15:03:08 +0000 https://blog.jetbrains.com/wp-content/uploads/2023/01/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=320262 The new Early Access build is here with the Incoming Calls hierarchy and support for the first set of C++23 features! Read on for more details and check out the full list of issues we’ve fixed in this update.

You can download the EAP builds from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ EAP

Call tracking

ReSharper’s Call tracking has finally come to ReSharper C++! You can now view and navigate through call chains in the hierarchy of incoming calls. Just place the caret at any function and select Inspect->Incoming calls from the context menu or press Ctrl+Shift+Alt+A to invoke it from the Inspect This menu.

Incoming calls

In the call tracking results window, you can double-click the hierarchy entry to navigate to the corresponding call in the editor or expand any node to check out their incoming calls.
Tracking outgoing calls is currently not supported.

C++23 support

The February 2023 meeting of the C++ committee will be the last one dedicated to resolving C++23 issues, and technical work on C++23 will be completed. The new language standard brings a lot of interesting features, and ReSharper C++ 2023.1 is here to help you try them.

C++23 introduces a new way of declaring non-static member functions that allow deducing the type and value category of the class instance parameter. Why give it a try? Previously, you had to duplicate a function for a const and non-const overload, or even make 4 versions with different ref-qualifiers: &, const&, &&, and const&&. With C++23 deducing this, you can handle all of these cases with just one function:

template <typename T>
class optional_cpp20 {
  constexpr T& value() & { /* ... */ }
  constexpr T const& value() const& { /* ... */ }
  constexpr T&& value() && { /* ... */ }
  constexpr T const&& value() const&& { /* ... */ }
  // ...
};

template <typename T>
class optional_cpp23 {
  template <typename Self>
  constexpr auto&& value(this Self&& self) { /* ... */ }
};

Check out the Deducing this (P0847) proposal for other use cases and new design patterns.

auto is one of the easiest and most useful features in modern C++. C++23 introduces more ways to use it: auto(x) and auto{x} (P0849). With the new function-style auto casting, you can make a decaying prvalue copy of a variable to pass it as a function argument by value.

void pop_front_alike(Container auto& x) {
    std::erase(x.begin(), x.end(), auto(x.front()));
}

Starting with this EAP build, ReSharper C++ is also aware of the following C++23 syntax updates:

  • For C compatibility, labels are now allowed at the end of a compound statement (P2324).
  • Empty parentheses () in lambdas are now optional in many cases (P1102).

Sort #includes alphabetically

We’ve introduced a new option to configure the sorting order for #include directives. By default, all #includes are sorted in the path order. If you prefer to see them in alphabetical order, you can now disable “Put files before folders”.

Sort #includes alphabetically

That’s all for now! Please try out the new build and share your feedback with us. If you encounter any issues, don’t hesitate to report them to our issue tracker.

DOWNLOAD RESHARPER C++ EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2023.1 EAP: Macro Expansion Preview https://blog.jetbrains.com/rscpp/2023/01/31/resharper-cpp-2023-1-eap2/ Tue, 31 Jan 2023 16:56:45 +0000 https://blog.jetbrains.com/wp-content/uploads/2023/01/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=318014 A new week, a new Early Access Program build packed with improvements and bug fixes! Read on for the highlights and check out the full list of issues we’ve fixed in this update.

You can download the EAP builds from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ EAP

Preview of macro substitution

We’ve significantly reworked the macro substitution preview. You can now see the macro expansion with syntax highlighting and proper code formatting in tooltips on hover! You can still use the Substitute macro call context action to check out the macro expansion right in the code, but the instant preview makes working with macros easier:

Preview of macro substitution

With the Quick Documentation popup (Ctrl+Shift+F1), there’s even more: you can now click any entity from the substitution preview to check out its documentation, as well. If there is an issue with your macro, it will be highlighted in the substitution preview of both the on-hover tooltip and the Quick Documentation popup.
Issue with a macro

Code analysis

We’ve introduced a new inspection with a quick-fix to pass a parameter by a const reference. ReSharper C++ will suggest you update the way you pass a parameter if it’s copied for each invocation, or when the parameter type is passed by value but is expensive to copy:

Pass a parameter by const reference

The following new inspections will help you clean up your code by getting rid of redundancies:

  • Inspection with a quick-fix to remove an unused typedef or type alias.
    Unused typedef
  • Inspection with a quick-fix to remove a redundant base class initializer.
    Redundant base class initializer

The inspection for a non-void function without a return statement now offers one more quick-fix! You can now both add a return statement and change the function return type to void:

Change return type to void

When there is a possibly erroneous empty statement in your code, ReSharper C++ will suggest replacing it with a {} block, which is a good starting point for fixing the missing piece:

Possibly erroneous empty statement

Other improvements

We continue to make code completion more helpful for experimenting with C++20 modules. ReSharper C++ now suggests module names when you are about to import a module:

Completion for module names

The Introduce variable refactoring now uses direct initialization for constructor calls where possible (RSCPP-33796).

Updates to the formatter bring a new option to configure line breaks after init-statements and a bug fix for blank lines before Unreal Engine macros.

That’s all for now! Please try out the new build and share your feedback with us. If you encounter any issues, don’t hesitate to report them to our issue tracker.

DOWNLOAD RESHARPER C++ EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2023.1 Early Access Program Is Now Open https://blog.jetbrains.com/rscpp/2023/01/19/resharper-cpp-2023-1-eap/ Thu, 19 Jan 2023 12:43:38 +0000 https://blog.jetbrains.com/wp-content/uploads/2023/01/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=314242 We’re launching the Early Access Program (EAP) for ReSharper C++ 2023.1! If you’ve never participated in one of our EAPs, in short, this means that we’ll be rolling out a new build every week, and these builds are free to use. We encourage you to take part and share your thoughts on the latest improvements and features so we can make ReSharper C++ better for you.
ReSharper C++ 2023.1 EAP

You can download the EAP builds from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ EAP1

Here are some of the highlights of the first EAP build. The full list of issues we’ve fixed in this update is available in our issue tracker.

C++20 modules

We introduced support for C++20 modules just recently, in 2022.3. We’re continuing to improve how it works under the hood and expand the list of ReSharper features available for new code entities.

The first EAP build comes with a ton of bug fixes for modules support, and it also includes some nice additions that improve the overall modules experience.

The Rearrange code feature has long allowed you to quickly move your code. It now also works for export blocks and exported entities! To rearrange code, press Ctrl+Shift+Alt with the caret on the code element or with a code selection, and then press the corresponding arrow key:

  • Press Up or Down to move the code relative to other elements in the same scope or between neighboring scopes.
  • Press Left or Right to move the code out of or into the exporting scope.

Rearrange code for modules

Additionally, code formatting now correctly formats export blocks and exported entities.

Unreal Engine

ReSharper C++ now suggests you autocomplete lambda signatures where a delegate, TFunction, or TFunctionRef is expected. That’s one less boilerplate task you have to worry about!
Unreal Engine lambdas

Our set of Unreal Engine file templates has some new items! You can now quickly generate templates for both simple and complex Unreal Engine tests. Just go to Solution Explorer and right-click on the preferred project folder to open the Add menu (or use Ctrl+Alt+Insert).
Unreal Engine tests

Refactorings

This build includes many bug fixes and usability improvements for the Change signature and Extract method refactorings.

These refactorings are now easier to access. We’ve made it possible to invoke them via context actions from the Alt+Enter menu.
Extract method in the Alt+Enter menu

Change signature can now be called from anywhere on function signatures instead of just function names, as was previously the case. Just press Alt+Enter or invoke the refactorings menu (Ctrl+Shift+R), no matter where your cursor is.

Calling Extract method is now easier, as well. If you need to extract a one-line function, you no longer have to select the whole line, since the refactoring now, by default, extracts the current line when there is no active selection.
Extract a one-line function

Create from usage

We’ve added a new quick-fix for unresolved identifiers. If you have an identifier that needs to be passed as a parameter, select the Create parameter quick-fix from the Alt+Enter menu to invoke Change Signature.
Create parameter

A similar quick-fix for generating definitions for unresolved functions has also received an upgrade in this EAP build. The Create function quick-fix now prefers to pass parameters by value instead of by const reference where doing so makes sense (for example, string_view and span).

Other improvements

A new postfix template allows you to quickly make a const reference with std::as_const or AsConst in Unreal Engine projects.as_const postfix template
We’ve also added a new inspection that shows an error when a class template argument deduction (CTAD) fails.
CTAD failed

And our last notable addition is for parameter name hints, which now work when functions are called through function pointers (RSCPP-25339).

Here are this build’s most noteworthy bug fixes:

  • ReSharper C++ no longer breaks when you switch CMake solutions (RSCPP-33686).
  • Generate definition should no longer occasionally generate definitions in the header file instead of the source file (RSCPP-32958).
  • Scoped fixes now work in non-project files (RSCPP-33613).

Those are the biggest highlights for this first EAP build. Please report any issues you encounter to our issue tracker, and stay tuned for the next build update!

DOWNLOAD RESHARPER C++ EAP1

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2022.3: C++20 Modules and Clang-Format Integration https://blog.jetbrains.com/rscpp/2022/12/07/resharper-cpp-2022-3/ Wed, 07 Dec 2022 16:23:11 +0000 https://blog.jetbrains.com/wp-content/uploads/2022/12/Release_Preview_image_1280x600_ReSharperCPP_released-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=305013 ReSharper C++ 2022.3 is now available!
Update to the latest version, or start a free 30-day trial today! Download the build from our website or via the Toolbox App.

ReSharper C++ 2022.3


Check out the highlights and visit our What’s New page for more details about these and other improvements:

DOWNLOAD RESHARPER C++

C++20 modules

ReSharper C++ 2022.3 introduces experimental support for C++20 modules. We’ve updated the language engine and many of the ReSharper C++ features to work with the new compilation model, supporting both named modules and header units.

C++20 modules: Code completion

ReSharper C++ now properly handles new syntax and warns you about unresolved module names or paths in import declarations. There’s also support for modules in all basic navigation features, a new built-in Module interface unit file template, as well as other enhancements.

Check out this blog post for details about supported features and known limitations. If you’d like to experiment with this long-awaited C++20 feature on other platforms, give it a try in CLion, which now includes support for modules, too!

C++ support

Besides our ongoing work on C++20 modules, we continue to improve ReSharper’s support for other language features. Here are the highlights for this release:

  • ReSharper C++ now understands #pragma pack directives and uses them when calculating object size and alignment.
  • #pragma pack

  • Parameter info and inlay hints in emplace-like and make-like calls are now available for any function that implies a constructor call according to the declaration of the function.
  • Improved compile-time evaluation now correctly handles various forms of object initialization, including the evaluation of constructors of any kind and designated initialization.
  • Support for C++20’s [[nodiscard("should have a reason")]], __atomic* and __sync* GCC builtins, and the GNU style for specifying calling conventions in function declarations.

Unreal Engine

If an asset is affected by renaming a symbol, Unreal Engine will no longer recognize it. To prevent data loss, ReSharper C++ suggests adding a Core Redirect when you perform the Rename refactoring. If you accept, it will update the corresponding .ini file for you.

The Add Core Redirect option was already available for UCLASS and UPROPERTY, and now it also works for UFUNCTION, USTRUCT, and UENUM.

Add Core Redirect

We hope you found Blueprints-specific inlay hints introduced in ReSharper C++ 2022.2 helpful. Based on community feedback, we’ve added one more type of Blueprints hint: you can now quickly check how many blueprints use a function marked with the BlueprintCallable specifier and get a list of all usages from the hint’s context menu.

Hints for BlueprintCallable

This release also includes miscellaneous updates to support the latest Unreal Engine 5.1 version.

ReSharper C++ no longer offers unwanted entities from system headers and shader files in auto-import suggestions. You can enable system header suggestions in Options | Code Editing | C++ | Unreal Engine.

If you are interested in a stand-alone cross-platform IDE for Unreal Engine development, consider Rider. Unreal Engine support in Rider and ReSharper C++ is aligned, and you can expect the same improvements in the Rider 2022.3 update.

Code formatting

ReSharper C++ 2022.3 introduces seamless integration with clang-format as an alternative code formatter. You can now switch between ReSharper’s formatting engine and the built-in or a custom clang-format binary for formatting files.

Clang-format

ReSharper’s own formatter has also received a few updates. We’ve added new options for managing spaces before and after ellipses (...) in parameter packs, aligning enumerator initializers in columns, and a bunch of formatting options for blank lines.

Clang-tidy updates

We’ve updated the bundled clang-tidy binary to Clang 15, bringing new checks.
Clang 15

This release also brings several improvements for clang-tidy integration:

  • In C files, clang-tidy now adjusts its checks according to the C language standard set in the project settings.
  • When using your own clang-tidy binary, you can now specify a path to the binary relative to the solution folder.
  • ReSharper’s own inspections now have priority when they share the same range with clang-tidy checks.

Coding assistance

There are two useful new additions to help you make conditions more readable:

  • A context action that replaces && with || and vice versa inside boolean expressions, following De Morgan’s laws.
  • An inspection with a quick-fix that simplifies negated comparison expressions.

ReSharper C++ now also shows the origin of a function in the parameter info and other tooltips, identifying whether a function is implicitly generated or a compiler intrinsic.

Function origin

Those are all the highlights for today! The full list of fixed issues is available in our issue tracker. More changes are coming from the ReSharper platform. For example, ReSharper will now alert you about vulnerable dependencies associated with the use of NuGet packages.

We’re always keen to receive your feedback about new features and updates! Please give ReSharper C++ 2022.3 a try and let us know what you think.

DOWNLOAD RESHARPER C++

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
C++20 Modules Come to ReSharper C++ https://blog.jetbrains.com/rscpp/2022/11/14/cpp20-modules/ Mon, 14 Nov 2022 17:24:03 +0000 https://blog.jetbrains.com/wp-content/uploads/2022/09/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=296608 C++20 modules are a new core language feature. Modules offer a unique way to organize source code with isolated file sets and independently compiled components. After a module is built, other translation units can import it without having to include and process the header files that constitute the interface of the module.

The ReSharper C++ 2022.3 EAP provides experimental support for C++20 modules. First of all, this means that the code analysis engine now understands the semantics of the new compilation model. But of course, there’s also more than that:

You can download the EAP builds from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ EAP

Let’s take a closer look at how ReSharper C++ helps you work with C++20 modules.

Named modules and header units

ReSharper C++ supports both of the main ways to introduce modules into your codebase: named modules and header units. The modern way is to use named modules. A named module defines its interface through module interface units, which by convention use the .ixx file extension. Additionally, there can be one or several module implementation units.
Module interface unit

After you build a module, the compiler produces a special metadata file that uses the IFC format and describes the public interface of the module. This interface description in the binary format is used by the compiler to import a module into another translation unit.
Importing a module

The main benefit of the new approach is that modules are compiled independently of the code that imports them. This means that preprocessor definitions in the translation unit that imports a module do not affect the imported module. Moreover, there’s no need for the compiler to parse the source code of the module each time it is imported, which has the potential to improve compilation times. We recommend going through the “Named modules tutorial in C++” to learn more about using named modules in Visual C++.

Making the switch to named modules in your projects could be a daunting task. In order to make the transition easier, C++20 provides a way to use existing header files as modules through header units. The idea behind header units is that most header files are sufficiently self-contained so that instead of including them they can be imported as stand-alone modules. More generally, you can think of header units as a modern and standard-supported alternative to precompiled header files.
Header units

An important distinction between a header unit and an include is that header units are not affected by preprocessor definitions outside of them. But similar to including a header file, importing a header unit makes preprocessor definitions from the header unit visible after the import statement. For more information about creating and consuming header units, please refer to the “Build and import header units” walkthrough.

Thus, whichever approach you’d like to experiment with, ReSharper C++ is here to help you.

Syntax highlighting

ReSharper C++ now properly handles new keywords: import, export, and module. You can also use the new ReSharper C++ Module Identifier category in Visual Studio’s Fonts and Colors settings to configure the style of module names.
C++20 modules: Syntax highlighting

Like it does for include directives, ReSharper C++ will warn you about unresolved module names or paths in import declarations.

We’ve added support for module declarations in all basic navigation features. You can now use Go to Declaration from the module name in import directives, navigate to module declarations from File Structure, and search for modules with Go to Symbol.
C++20 modules: Navigation

Code completion

The code completion list now includes items from all the imported modules and header units.
C++20 modules: Code completion

File template for module interface units

If you want to quickly create a module, you can now use a new built-in file template – Module interface unit. To create a new file from a file template, use the Ctrl+Alt+Insert shortcut or select ReSharper | Edit | Create New File from the main menu:
C++20 modules: File templates

Known limitations and roadmap

This is just the beginning of our work on modules support, and there are still some rough edges. The most important limitation is that importing modules directly from binary module interface files is not supported yet. This means that you must have the source of the module included in your solution in order for ReSharper C++ to be able to import it. Additionally, ReSharper C++ expects module interface files to use the conventional .ixx extension.

We are working on introducing modules support in other features for a future release. Our roadmap includes plans to:

  • Allow auto-import features to insert import module directives.
  • Update Find Usages to find all locations where a given module is imported.
  • Extend the Rename refactoring to support renaming modules.
  • Support the std and std.compat standard library modules introduced by P2465.

We hope you can now experiment with this long-awaited C++20 feature in your projects while using ReSharper C++. We would greatly appreciate it if you gave our modules support a try.
Check out the new EAP build and share your feedback with us in the issue tracker or in the comments below. Thank you!

DOWNLOAD RESHARPER C++ EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2022.3 EAP: Clang-Format Integration, Clang-Tidy 15 https://blog.jetbrains.com/rscpp/2022/10/24/resharper-cpp-2022-3-eap-clang-format/ Mon, 24 Oct 2022 18:50:25 +0000 https://blog.jetbrains.com/wp-content/uploads/2022/09/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=289880 This week we’ve collected a few new features to share with you: the option to use clang-format as the main formatting engine, a Clang-Tidy upgrade with new inspections, and updates to C++ support. Read on for the details and give the new build a try!

You can download the EAP builds from our website or via the Toolbox App.

DOWNLOAD RESHARPER C++ EAP

Clang-format integration

ReSharper C++ introduced support for reading clang-format settings back in 2017.2. If the code style of your project is configured in .clang-format files, the ReSharper C++ formatter will read and automatically use most of these settings to format your C++ code. Ever since, we’ve been working on improving compatibility and adding support for more formatting options.

However, if you’d like to use a specific clang-format version or check out a setting not yet supported by ReSharper’s formatter, you may find inconsistencies between how your code looks after formatting with clang-format and how it looks after formatting with ReSharper.

Starting with this EAP, ReSharper C++ provides seamless integration with clang-format, meaning you can now switch from ReSharper’s own formatting engine to сlang-format when formatting files.

ReSharper C++ runs the clang-format binary as a separate process, ensuring full compatibility with the industry-standard formatter, as well as better performance and a more extensive range of formatting options.

By default, ReSharper C++ uses the built-in clang-format binary. You can configure ReSharper C++ to run any other clang-format binary on the Code Editing | C++ | Formatting Style | General page of the ReSharper options.
Custom clang-format binary

C++ support

We’ve implemented support for the C++20 version of [[nodiscard]], which includes a reason why a function has been marked with the attribute. When you specify a string literal inside the attribute, you now get a clearer and more concise warning in the editor in addition to the warning offered by the compiler.
[[nodiscard]] with a reason

C++ is constantly evolving, and more and more user code and libraries depend on constexpr code evaluation. In this EAP cycle, we are filling in the last remaining gaps in our compile-time evaluation. ReSharper C++ now correctly handles various object initializations, including the evaluation of constructors of any kind – default, implicitly-generated, inherited, and user-defined (RSCPP-32214, RSCPP-32215, RSCPP-33141).
constexpr code evaluation

We’ve also improved support for calling conventions. ReSharper C++ now understands not only MSVC-style (void __stdcall foo()) but also GNU-style (void __attribute__((stdcall)) bar()) ways of specifying calling conventions in function declarations for compilers that support this syntax. It can handle function pointers as well: using stdcall_callback_t = void(__attribute__((stdcall))*)();

In this EAP, we’ve also updated the bundled Clang-Tidy binary to Clang 15, bringing new checks.
Clang 15

Finally, there’s a new inspection with a quick-fix that simplifies negated comparison expressions.
Simplify negated comparison expressions

Those are all the highlights for today! The full list of fixed issues is available in our issue tracker.
Give the new build a try and let us know what you think. We love hearing from you!

DOWNLOAD RESHARPER C++ EAP

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>
ReSharper C++ 2022.3 Early Access Program Is Open! https://blog.jetbrains.com/rscpp/2022/09/26/resharper-cpp-2022-3-eap/ Mon, 26 Sep 2022 15:00:27 +0000 https://blog.jetbrains.com/wp-content/uploads/2022/09/Blog_Featured_image_1280x600_ReSharperCPP-2x.png https://blog.jetbrains.com/?post_type=rscpp&p=282013 ReSharper C++ opens its EAP with improvements for C++ support and new formatting options. Read on for details and give the new build a try!

If you’re not familiar with our Early Access Program (EAP), we roll out free-to-use preview builds each week for developers to test with their code. The EAP builds let you try out all the latest improvements, but these builds might be unstable since they are works in progress. You can get the EAP builds via the Toolbox App or download them from our website.

ReSharper C++ 2022.3 EAP

DOWNLOAD RESHARPER C++ EAP1

We’ve introduced support for the #pragma pack directive, which modifies the current alignment rule for the members of structures. ReSharper C++ now correctly computes the sizes of packed structures so you can rely on analysis and highlighting for static assertions.
#pragma pack

The recently released ReSharper C++ 2022.2 brought a lot of improvements for working with emplace-like and make-like function calls. However, these features were limited to classes and functions from the standard library. Starting with the first EAP build of 2022.3, ReSharper C++ can now show you parameter info and inlay hints for any function or method that implies a constructor call!

To check out these enhancements, make sure that the function template is limited using SFINAE or a requires-clause with type traits and concepts that restrict T to be constructible from a given arguments pack. This could be std::enable_if with the std::is_constructible type-trait, or requires std::constructible_from<T, Args...>, or any similar construction.
std::is_constructible type-trait

As you may have noticed in the screenshot above, ReSharper C++ now includes the function origin in parameter info and other function tooltips. The updated tooltips now show you when a function is implicitly generated (e.g. constructors or assignment operators), built in (e.g. operator+ for fundamental types), or compiler intrinsic (e.g. functions with the __builtin_ prefix).
function origin in parameter info and other function tooltips

We’ve also introduced a useful new context action that replaces && with || and vice versa inside a boolean expression, following De Morgan’s laws.
Replaces && with || and vice versa

For better-looking code, we’ve added a number of new formatting options for configuring:

  • Spaces before and after ellipsis () in parameter packs.
  • The number of blank lines that are acceptable to present in declarations and in the rest of the code.
  • Whether blank lines are kept or removed after an opening brace ({) and before a closing one in declarations and in the rest of the code.
  • Blank lines before and after access specifiers.

All the new formatting settings can be found, as usual, on the Code Editing | C++ | Formatting Style page of the ReSharper options.

Finally, we have a small but important update for Unreal Engine projects: ReSharper C++ no longer offers unwanted entities from system headers in auto-import suggestions. By default, system headers are not suggested, but if you want them to be, you can enable them in Options | Code Editing | C++ | Unreal Engine.

Those are all the highlights for today! The full list of issues we’ve addressed is available in our issue tracker.

Give the new build a try and let us know what you think. We love hearing from you!

DOWNLOAD RESHARPER C++ EAP1

Your ReSharper C++ team
JetBrains
The Drive to Develop

]]>