ReSharper C++ 2022.3 EAP: Clang-Format Integration, Clang-Tidy 15
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.
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.
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.
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).
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:
stdcall_callback_t = void(__attribute__((stdcall))*)();
In this EAP, we’ve also updated the bundled Clang-Tidy binary to Clang 15, bringing new checks.
Finally, there’s a new inspection with a quick-fix that simplifies 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!
Your ReSharper C++ team
The Drive to Develop