What’s New in ReSharper C++ 2017.2

Please welcome ReSharper C++ 2017.2! This is the second annual ReSharper C++ release, packed as usual with new features and bug-fixes.
ReSharper C++ 2017.2

Take a look at the What’s New page for a quick overview, or continue reading for a deep dive into the highlights of this release:

Language understanding

ReSharper C++ 2017.2 has finalized support for several C++11 features:

  • In addition to user-defined integer literals, ReSharper C++ supports floating-point, character, and string literals. Find Usages and Rename were also updated to handle literal operators.
    Rename of a literal operator
  • C++11 extended friend declarations are recognized.
    Extended friend declarations
  • Expression SFINAE support was improved in several ways. Most importantly, overload resolution results are now checked inside expressions during template substitution.
    Substitution failure inside an expression
  • More standard type traits are supported, including all traits with names prefixed by is_trivially.

Visual Studio 15.3 comes with a significant update for its C++ toolset. The following new C++17 features introduced in 15.3 are now also supported by ReSharper C++:

  • Selection statements with initializer (P0305R1) — the extended syntax for if and switch statements which allows initializers:
    If with initializer
  • Code inspections understand the C++17 attributes [[nodiscard]] (P0189R1) and [[maybe_unused]] (P0212R1):
    [[nodiscard]] and [[maybe_unused]] attributes
  • Using attribute namespaces without repetition (P0028R4):
    Using attribute namespaces without repetition
  • Lambda capture of this by value (P0018R3):
    Lambda capture of this by value

Unfortunately, structured binding declarations from C++17 are not yet supported, but they are top-of-the-list for our next release.

On a related note, another important change in the 15.3 toolset is partial support for two-phase name lookup. It has to be manually enabled through the /permissive- conformance switch, but MSVC’s team plan is to turn conformance mode on by default in the next major compiler revision. If you want to move your code forward and make it fully two-phase clean, ReSharper C++ can be a great aid since it has been using two-phase name lookup since the beginning. You just need to pay attention to warnings inside template code—for example, ReSharper C++ will point out lookup errors during the first phase of lookup:
Two-phase name lookup
For help with errors related to two-phase name lookup, we have suggestions about missing template and typename keywords in dependent code:
add_typename

There is some news about C support as well. ReSharper C++ now implements anonymous structures, a Microsoft C extension that allows declaring a structure variable within another structure without giving it a name. Members of anonymous structures can be accessed as if they were members in the containing structure. This extension is limited to C only, but it is supported both by Clang and GCC with the -fms-extensions option.
Anonymous structs

If you need to override a few functions from a base class, there is now an alternative to using the Generate overriding members dialog. Virtual functions that can be overridden will be included into the completion list when you complete inside a class body. When selected, these completion items will insert a full function declaration. To continue, you can use Generate implementation or Generate inline implementation – either context action will create a function body.
Override functions in completion

Finally, the Generate constructor dialog got a new option, Make empty constructors = default. As the name suggests, with this option enabled ReSharper C++ will = default the generated constructor when it is empty, so it’s a quick way to add a defaulted constructor if you need one in your class.

Code inspections and quick-fixes

ReSharper C++ 2017.2 adds several new code inspections:

  • The much-requested Inconsistent Naming inspection detects violations of naming style in your code, and the accompanying fix allows you to quickly invoke the Rename refactoring with the name changed according to the corresponding naming rule. By default, the naming inspection has the Hint severity, which means that naming inconsistencies do not appear on the marker bar and are not highlighted with curly underlines. If you want to enforce naming rules and find that this inspection is useful, do change its severity to Suggestion or Warning.
    Inconsistent naming inspection
    Naming rules used by the inspection can be configured on the Code Editing | C++ | Naming Style options page. This page has been reworked since the previous release and now allows adding new names rules and editing existing ones. The rules are checked in reverse order, meaning that a rule that comes later in the list has higher priority than the one before it.
    Naming style
    For each naming rule, it is possible to specify the kinds (e.g. class, function or variable), accessibility, and specifiers (static, const, constexpr or volatile) of entities to which the rule should apply.
    Naming rule editorPlease note that the naming rules for getters and setters, which are present in previous versions of ReSharper C++, are now gone. You can use new options in the Generate getters and setters dialog instead to control whether or not to add is/get/set prefixes to getter and setter names.
  • One of the unique ReSharper C++ inspections is Member function may be const, which highlights functions that do not change member variables of the containing class and thus can be marked as const. ReSharper C++ 2017.2 adds a couple of related inspections, Local variable may be const and Parameter may be const (since 2017.2.1), which perform a similar analysis and show local variables and function parameters that can be made immutable.
    Add const fix
    If you consider using const everywhere possible as too excessive, reduce the severity of one or both of these inspections.
  • Unused entity inspections used to work only with local variables and function parameters. Their scope has been extended now to also include global variables, classes, enums, and enumerators that have internal linkage or are members of an anonymous namespace.
    Unused entity inspection

A number of new quick-fixes for existing inspections were also introduced:

  • Add #pragma once is the recommended fix when an include guard is missing in a header file. There are teams though that prefer using #ifndef/#define/#endif include guards, and ReSharper C++ now has a fix that wraps the header file with this combination of directives.
    Include guard fix
  • If there is an unused expression without any side effects inside a function of a type compatible with the function’s return type, ReSharper C++ lets you convert it into a return statement via the Return unused expression fix.
    Add return fix
  • Trying to bind lvalue expressions to rvalue references is a compiler error, but sometimes it just means that a call to std::move was intended but is missing. To quickly add it, use the new Add std::move fix.
    Add std::move fix

ClangFormat support and line wrapping

ReSharper C++ 2017.1 brought support for EditorConfig, a popular standard for defining code formatting preferences. In the C++ community, however, ClangFormat is the de facto standard for formatting tooling. ReSharper C++ 2017.2 adds support for reading ClangFormat configuration files, so if there is one in your project, ReSharper’s code formatting engine will automatically pick it up and use it. To find the configuration files that affect a particular file, ReSharper C++ looks for .clang-format and _clang-format files in the containing folders. ReSharper C++ will also help you understand exactly which style options are applied and where they come from:

  • You will see a yellow warning on ReSharper C++ formatting options pages if at least one preference on a page is overridden by ClangFormat options. Each overridden preference will be also highlighted with yellow:
    ClangFormat in options
  • You can see and study all ClangFormat configuration files that affect the current file in the File Formatting Info window:
    File formatting info window

Please refer to the Using Clang-Format help page for the full list of supported ClangFormat style options.

Another big change related to code formatting is support for line wrapping. You can find the option to turn it on or off, as well as a collection of options that control wrapping inside different syntax elements, in the Line wrapping group on the Code Editing | C++ | Formatting Style | Line breaks and Wrapping options page.
Line wrapping options

A number of new formatting options were added, in particular options that control:

  • line breaks after template headers and function return types;
  • indentation of parentheses and their contents in function declarations, function calls, and if/while/for statements; and
  • spaces around colons in range-based for loops and in lists of base classes.

Go to declaration now works inside the bodies of macro definitions. Of course, due to the textual nature of preprocessor macros, the results of such a context search are tentative. For macro parameters, the search will jump to the parameter declaration. For other identifiers inside macro bodies, all symbols inside the solution with names that match the identifier will be shown.
Declaration search inside macro bodies

Go to Everything (Ctrl+T), Go to File Member (Alt+\) and Go to Action (Alt+Enter) have been improved as follows:

  • The query syntax got extended in several ways. ReSharper will now match identifiers even if the word order inside your query is mixed up:
    Word order
    On the other hand, if you add quotes around a search query, ReSharper will only look for exact matches. If you need even more control, it is also possible to combine exact search with wildcard characters like * and ?.
    Exact search
  • To streamline the navigation experience, Go to Text is integrated into Search Everywhere, so you do not need to deliberately use Go to Text to get text matches in search results.
  • A laptop-friendly Shift+Enter shortcut can now be used in addition to Num + to open search results in a separate Find Results tool window, where you can explore and filter items more easily.

Navigate to file nearby is a completely new navigation feature, which displays project structure around the current file in a popup menu. The top-level menu shows the solution, the current project, containing folders, and files in the same folder. From there you can navigate deeper, open files, and create new files and folders. Navigate to file nearby is not bound to a key shortcut by default, but it can be invoked similar to other navigation actions from the Navigate To context menu (Alt+Backquote) or via ReSharper | Navigate | Go to File Nearby.
Go to file nearby

For more information about platform-wide changes in navigation, please see ReSharper 2017.2 – what’s new in navigation?.

Performance improvements

ReSharper C++ 2017.1 introduced the option to not reindex includers when preprocessor directives in a header file get modified. In the 2017.2 release, another common situation which caused bulk reindexing is addressed using a similar mechanism. By default, ReSharper C++ will now not reindex files after the current build configuration of a project is changed. Please note that code inspections may execute slower after a configuration change the first time you open a file, since ReSharper C++ will need to reparse the included files. If you prefer the old behavior, you can revert via the option Code Editing | C++ | Performance | Reindex affected files after a project or a file property is changed.

The second performance-related change is added support for the new asynchronous Visual Studio API for reading project properties, available starting with Visual Studio 15.3. In the past, ReSharper C++ had to query project properties on the main thread, which could lead to UI stalls when you opened your solution or changed project configurations. These freezes should be gone now, with the additional benefit of lower memory usage for storing project properties. Moreover, the lightweight solution load Visual Studio feature is now supported, and ReSharper C++ should no longer force loading of all projects in the solution even when LSL is enabled. If you encounter ReSharper C++ issues when running Visual Studio 15.3, please try disabling the option Code Editing | C++ | Performance | Read project properties asynchronously in Visual Studio 15.3 and later and reopening the solution. If it does help, do let us know!

CppCon 2017

CppCon 2017
This year’s biggest C++ conference takes place in Bellevue, Washington, USA on September 24–29. JetBrains is proud to return as a bronze sponsor and will have an exhibition booth set up on the 27th and 28th. If you’re there, stop by the booth to have a chat with members of our CLion and ReSharper C++ teams, give them your feedback, and consider attending one or more of the talks delivered by JetBrainers:

  • New standards to the rescue: the view through an IDE’s glasses, by Anastasia Kazakova (CLion Product Marketing Manager) at 2 pm, September 25.
  • Tools from the C++ eco-system to save a leg, by Anastasia as well at 3:15 pm, September 26.
  • The Holy Grail—A Hash Array Mapped Trie for C++, by Phil Nash (JetBrains developer advocate and the author of the famous Catch unit testing framework) at 9 am, September 29.

We are looking forward to seeing you there!

That’s it! Start your free 30-day evaluation and try out all the new features and fixes. As always, please leave us any feedback and report issues either in the issue tracker or on the support forum.


Download ReSharper C++ 2017.2

Posted in ReSharper C++ Tips & Tricks | Tagged , , | Leave a comment

C++ Annotated: Apr – Aug 2017

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: April – August 2017

A long time has passed since the last edition of C++ Annotated. Which means today we have lots of great articles and news to share with you. In this edition:

  • C++ language news
    • C++20
    • Metaclasses
  • Conferences
    • Recent events like ACCU and C++Now
    • Upcoming events
  • Learning
  • Releases

C++ language news

C++20

wg21-timeline-2017-07b
With C++17 ready for final publication by the end of 2017, we can now start thinking about the future of C++ and in particular C++20. The Toronto C++ committee meeting was solely about just this! Just look:

  • Concept TS was merged into C++20 draft. It takes now only one clean syntax (out of three) and doesn’t include function concepts.
  • Coroutines TS, Networking TS and Ranges TS are done, Modules TS is quite close.
  • Several nice enhancements like designated Initializers, template syntax for generic lambdas, default member initializers for bit-fields and others.

It seems that Fall will bring even more exciting features to C++20, and maybe for example, compile-time reflection. (And here’s one to definitely have a check of the talk by Jackie Kay from C++Now). And not to mention the library evolution group and new standard library under discussion. To find out more check Herb Sutter’s traditional trip report. And if you want a summary table view, check the trip report by Botond Ballo.
Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

What’s New in ReSharper C++ 2016.3 and 2017.1

ReSharper Ultimate 2017.1 is out! It’s been some time since our last post about updates in ReSharper’s C++ support, so let’s take a look at what has kept the team busy.
ReSharper C++ 2017.1
Major areas of improvements include:


Visual Studio 2017 support

Visual Studio 2017 has launched, bringing a lot of new features and improvements to C++ developers. ReSharper C++ 2017.1 has full support for the latest Visual Studio release, including:

  • The handling of the v141 toolset, the C++ Language Standard project property and the equivalent /std compiler command line argument.
  • Understanding of several new C++ language features.
  • Support for the Enable Faster Project Load IDE option.

Most importantly, ReSharper C++ introduces initial support for the Open Folder functionality and CMake-based projects in Visual Studio 2017. The latter is particularly helpful since it eliminates the need to regenerate and reload the Visual Studio project when CMakeLists.txt is modified. However, there are a couple of related caveats:

  • In the Open Folder mode without a CppProperties.json configuration file present, ReSharper C++ will use include paths set via the INCLUDE environment variable. You can start Visual Studio from the developer command prompt to have INCLUDE automatically populated with paths to the standard library and Windows SDK.
  • Since there is no Debugging property page, additional configuration is required if you want to use ReSharper’s unit testing capabilities. You can specify how to run tests on the new page, Tools | Unit Testing | C++ Tests, in ReSharper options.

Please note that support for this kind of projects is still experimental — do let us know if you experience any problems!

We’ve also updated ReSharper C++ to handle several new types of projects — properties like predefined macros, include paths, and others should be correctly read from VisualGDB MSBuild, Linux Makefile, and CUDA projects. Moreover, when a compiler other than MSVC is used, ReSharper C++ predefines a number of macros for better compatibility with GCC and CLang compilers.

Language features

C++17 nested namespace definitions are now supported in ReSharper C++. Available since VS 2015 Update 3, this feature provides a concise way of defining nested namespaces. When ReSharper C++ detects that the latest language standard is being used, the Convert to nested namespace definition context action is available to change the old-style syntax into the new one:
Nested namespaces

ReSharper C++ also understands some of the other language features introduced in VS2017, in particular C++17 terse static_assert and C++14 no implicit const specifier on constexpr functions.

Last, std::is_constructible, std::is_convertible, std::is_polymorphic, and std::is_standard_layout C++11 type traits are now supported.

Introduce/Inline typedef

A couple of new refactorings were implemented to complement the existing Substitute typedef context action. The Introduce typedef refactoring allows you to quickly create a typedef for the selected data type and replace this data type and all its occurrences with the newly created typedef. The Inline typedef refactoring does the opposite: it replaces an existing typedef with the actual data type.
Typedef refactorings

Needless to say, these refactorings also support C++11 type aliases. If you want the Introduce typedef refactoring to insert a type alias instead of a typedef declaration, set this behavior on the options page Code Editing | C++ | Code style.

Unit testing

In addition to Google Test and Boost Test, ReSharper C++ 2016.3 delivered first class support for Catch, a cross-platform test framework for C++. Catch is popular because of its ease of use and expressive API, which allows you to divide test cases into sections (each of which is run in isolation) and structure them using BDD style. The framework is distributed as a single header file, with no external dependencies (beyond the C++03 standard library). You can always get the latest version of this header directly at this URL. For an introduction to Catch, please refer to the Catch tutorial, watch the CppCon presentation, or read the article in the CLion blog.

We are also happy to say that the author of Catch, Phil Nash, joined JetBrains as a developer advocate last fall. If you have any ideas on how to improve Catch integration into JetBrains products or have feature suggestions for Catch itself, do not hesitate to contact him!

Other updates in unit testing support include:

  • Boost Test runner has been updated to support Boost 1.62, 1.63 and 1.64. We have also fixed performance issues while working with a large number of dynamic tests and changed the runner to ignore output from the test program, so it does not affect parsing of the XML test report.
  • Google Test runner now supports the 1.8 release of the framework. ReSharper C++ will also correctly merge results of several runs and calculate total execution time if the --gtest_repeat flag is used to run the tests several times.
  • The list of unit tests is now automatically updated after external file changes (for example, when unit tests are generated as a result of a build step).

Completion

Postfix templates, a popular feature first introduced by ReSharper for C#, allow you to focus on your data rather than the syntax. ReSharper C++ gets a set of its own templates specifically tailored for C++. You can now quickly wrap an expression with several available templates, including if, else, while, do, return, switch, foreach, and others.
Foreach template

The new options page Code Editing | Postfix Templates lists all the available postfix templates. It allows you to disable the ones you do not use, and contains a number of related options.

Postfix templates

One common C++ coding practice is to prefer non-member non-friend functions to member functions. This is a great way to increase encapsulation and keep class interfaces as minimal as possible (see item 32 in Scott Meyer’s “Effective C++” for a detailed discussion). However, from the tooling perspective there have always been drawbacks to this practice. Whereas member completion list shows all the available member functions, it’s not so easy to list and complete non-member functions which are applicable to an object of the given class. This problem is now solved by ReSharper C++: when you type a dot (.) or an arrow (->) after an expression, free functions that accept that expression as the first parameter will be suggested in the completion list as well as member functions.
FreeFunctionCompletion

Code cleanup and inspections

ReSharper C++ 2017.1 introduces cleanup tasks, including:

  • A set of tasks to apply the existing quick-fixes for common code issues.
  • The Update file header cleanup task, which updates the comment at the top of the file according to the template specified on the options page Code Editing | File Header Text (take a look at the related blog post for more details).

To run code cleanup, use the command ReSharper | Edit | Cleanup Code (Ctrl+E, C) — it will work either with the current text selection, the entire file opened in the text editor, or on a set of files and projects selected in the solution explorer. You have the choice to use the built-in profile (which has several of the tasks that you might not always want to run disabled) or create your own. Here’s one that shows all the available C++ cleanup tasks:
Code cleanup

Control flow inspections (uninitialized/reassigned/unused variable and the like) used to work only with local variables and function parameters, but now class fields are also analyzed. For example, ReSharper C++ will find a self-initialization error in this snippet:
Self initialization
Or an uninitialized member here:
Uninitialized member

If you declare a local variable and initialize it later without any conditions, ReSharper C++ now suggests to join declaration and assignment where the variable is first initialized. This removes the unnecessary statement and improves code readability.
Join declaration and assignment

We have introduced several ReSharper-specific C++11 attributes that can be used to improve the results of certain inspections. For example, ReSharper C++ now understands the [[rscpp::format]] attribute (or, alternatively, [[gnu::format]]), which can be used to enable printf format string analyses for user-defined functions (RSCPP-15890).
printf attribute
There are also attributes to mark functions as having side effects (see RSCPP-18615) and guard classes for which the Unused variable highlighting should be suppressed (RSCPP-18764) — please refer to the corresponding issues for examples of their usage.

A number of smaller new code inspections were also added:

  • Incrementing expression of type bool and Deprecated register storage class specifier for language features removed in C++17.
    Incrementing bool
  • Deleting a void pointer is undefined behavior according to the C++ standard.
    Deleting a void pointer
  • Redundant void argument list (void argument lists are only useful in C code).
    Redundant void argument list
  • Private special member function is not implemented, which reminds you to use the C++11 = delete specifier instead of making the function private and omitting its definition to prohibit its usage.
    Private special member function not implemented

ReSharper’s File Status Indicator (the small icon at the top of the Error Stripe) receives a new context menu. With a right-click on the icon, you can quickly toggle not only ReSharper code analysis, but also identifier highlightings and Visual Studio code analysis (the lightbulb and squiggles). If there are code issues in the current file, you’ll also see commands for navigating between issues of the highest severity level (you can still use the good old Inspect | Next/Previous Error/Warning commands to do that).
File status menu

Finally, a new option on the options page Code Editing | C++ | Inspections controls the visibility of gutter icons (like “Navigate to definition/declaration”), should you find they clutter the user interface too much for your liking.

Documentation support

ReSharper C++ 2016.3 finally learned to display rich syntax-highlighted tooltips for C++ code elements. The contents of the tooltips mirror what was previously available through the Quick Documentation popup, namely function and variable types, containing namespace, template and function parameters, as well as documentation comments.
Quick info

In addition to the standard Doxygen syntax, ReSharper C++ now understands C#-style XML documentation comments.
XML documentation

Finally, while only references to function parameters were resolved before from inside documentation comments, now template parameter references are also supported. This means that they will be shown in the list of results from Find Usages and updated by Rename when it is used on a template parameter.

Command line tools

ReSharper Command Line Tools (CLT) are a standalone set of command line tools that enable you to run code inspections outside of Visual Studio (for example, on your CI server or code quality management system). You can now use inspectcode.x86.exe from the CLT distribution to analyze C++ projects and generate a report with found code issues. What’s the best part? CLT are free and do not require an active license. To analyze your solution, just run inspectcode.x86.exe -o=report.xml YourSolution.sln.

Command line tools

You can either get CLT via a NuGet package or download a standalone archive. In the latter case ensure that the downloaded .zip file is “unblocked” before extracting: right click on the file, select Properties and click Unblock. (Failure to do this will cause the .NET framework to load the application in partial trust, which means it won’t load or run correctly.)

For an in-depth description of CLT usage, refer to the blog post ReSharper Code Analysis Goes Beyond Visual Studio.

Performance

In terms of performance, we have recently targeted ReSharper C++’s memory usage to make it work better with huge solutions. (Since we still run in-process, we’re limited by the amount of memory Visual Studio can use as a 32-bit process.) As a result, both the memory footprint after indexing and memory traffic during indexing have improved significantly. In some cases (like the Unreal Engine 4 solution), the amount of managed memory used has decreased by up to 30%. Furthermore, a number of issues have been resolved that had caused excessive memory usage due to background editor and Find Results tabs. All of these changes should help with the debugging experience, since additional memory usage during debugging might have led to memory pressure. If you had problems with debugging before, we would also recommend trying Visual Studio 2017, which improves memory usage during debugging.

In C++ code, when you change preprocessor directives in a header file anything can happen. For example, if you add a #define or #include some file into a header file, the meaning of code can change in any file that uses that header. ReSharper C++ used to reindex all includers after a change like this, which is quite taxing on big projects, especially for common headers which get included into most C++ files. We have revisited this behavior, and now ReSharper C++ does not reindex these files by default, so the symbols in them are still used for navigation and refactoring purposes. This is a compromise between correctness and speed, the old behavior can be restored using an option in the Code Editing | C++ | Performance page. This page also contains a new option to limit the number of concurrent threads used by C++ caches — you can try tuning it to improve responsiveness during the code indexing phase, at the cost of total indexing time.

If ReSharper’s performance is still unsatisfactory, you can use the Third-party code options page to stop ReSharper C++ from indexing specific files and folders.
Third-party code
This page allows you to specify two kinds of filters:

  • Skipped Code contains files that do not get indexed at all, and is usually the right way to exclude third-party dependencies. Only indexing roots (normally .cpp files) are excluded, so if a .cpp file that is indexed includes some header files, their contents will be indexed regardless of third-party settings (since this is a prerequisite for correct parsing). So in practice, you should be able to just add the directories with third-party libraries to “Skipped code”, and if you include a header from a skipped library into your code, ReSharper will still be able to navigate to it.
  • Library Code contains files that ReSharper C++ must not modify. Highlightings are disabled inside these files, but they get indexed and ReSharper C++ is aware of symbols inside them. For example, Goto Symbol and auto-import will work for those files.

The File and folders list can only contain files and folders that are a part of the solution. The File masks list allows to match arbitrary paths. Masks are automatically prefixed by **/ and are matched against absolute file paths. If you want to match all files inside a folder, /** would also be required at the end of the mask. So for example, files inside C:/Foo/Bar would be matched by Bar/**, Foo/Bar/**, or C:/Foo/Bar/** (although shorter masks might match unwanted folders too).

Code formatting

EditorConfig offers a convenient way to share code style settings between teammates who use different editors and IDEs. ReSharper 2017.1 supports EditorConfig configuration files out of the box. To learn more about this, refer to the Using EditorConfig help section or watch the introductory video.

A new setting in the General Formatter Style options page (turned off by default) makes ReSharper C++ automatically detect and set the indent size used in a file. This feature becomes particularly handy in solutions where different files have variable indent sizes.

Indenting of preprocessor directives is now supported and controlled via the Indentation | Preprocessor directives indenting formatter option. Code that uses the OpenMP API is one example where this option is crucial for correct formatting:
Directives indenting

The list of other formatter options introduced for improved configurability includes:

  • Indent namespace members.
  • Break line in simple case statement.
  • Spaces within/after parentheses in cast expressions.
  • Place enumerators on new line.
  • Align multiline chained method calls and binary operators.

The list of small and not-so-small improvements in navigation and find usages includes:

  • The Find Results window now works asynchronously, meaning that you can work with the results tree while usage search is still in progress.
  • The Go to Everything and Go to Text popups support inline commands for advanced filtering of search results.
    Search filters
  • The Find Results window allows you to group results by kind of usage. This ability is very useful if you want to inspect only specific usage scenarios.
    Find results grouping
  • Recent Files can delete entries with the Delete key, and both the Recent Files and Recent Edits popups will now show the path of the file, to avoid confusion with similarly named files.
  • There is a new setting to remember the last search in Go to Everything, Go to Text and other search actions.
  • ReSharper’s Search & Navigation page adds a new option to open files in the preview tab from everywhere. This option is turned off by default.

ACCU 2017

The ACCU 2017 conference takes place in Bristol April 25-29 and as always has a great lineup of presenters and a lot of interesting talks, including “Functional C++ For Fun And Profit” and “A look at C++ through the glasses of a language tool” by our very own Phil Nash and Anastasia Kazakova. You can watch video recording on the ACCU conference YouTube channel later if you do not attend, but if you do, be sure to stop by the JetBrains booth to say “Hi,” grab a couple of souvenirs or shoot any questions at members of the ReSharper C++ and CLion teams.

That about wraps it up! All in all, 210+ issues have been fixed in the 2016.3 release iteration, and 140+ issues in 2017.1. We’d like to give a big shout-out to everybody who tried Early Access Preview (EAP) ReSharper builds and helped us iron out the bugs and improve the product. As always, please leave us any feedback and report issues either in the issue tracker or on the support forum. Develop with pleasure with ReSharper C++!


Download ReSharper C++ 2017.1

Posted in ReSharper C++ Tips & Tricks | Tagged , , , , | Leave a comment

C++ Annotated: Jan – Mar 2017

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: January – March 2017

In this edition:

C++ in 2017

The C++ ecosystem

logo-sunThis blog post about the C++ ecosystem in 2017 is worth a special mention. Written in January, it overviews nicely the main expectations and trends, and not just about the language. While C++17 is indeed the main topic for this year’s discussions (as well as the features that failed to be included and so postponed for the future), it is also about adopting new standards and libraries, and of course the community including user groups and conferences.

C++17

cpp_17As C++17 is approved, pending national body comments, there are lots of resources now where you can find the final feature list, explanatory code samples, committee meeting live threads and committee meeting trip reports. This list by Bartlomiej Filipek is quite useful as it provides code samples for each feature, lists the key compilers (GCC, Clang, MSVC) explaining the versions where the feature is supported, and links to various additional articles. It’s very detailed and includes every small change.
Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

C++ annotated: Sep – Dec 2016

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: September – December 2016

In this edition:

Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

Introducing Phil Nash, Developer Advocate for C++, Objective-C and Swift tools

Phil NashPhil Nash has joined us recently as a Developer Advocate for C++, Objective-C and Swift tools. Here we talk to Phil about his experience and interests and introduce him to all of you.

Twitter: @phil_nash
Blog: levelofindirection
GitHub: philsquared

A: Hi Phil, and welcome to the JetBrains team! Let’s talk about you. Can you please share a bit about yourself?

P: Hi Anastasia. Thanks for having me here. A bit about me? Well, I’ve been programming since I was 9. Like most who came of programming age in the early 80s, I started with various versions of BASIC on 8-bit home computers (ZX-81, ZX-Spectrum, Commodore-64, BBC Micro and others), but within a few years progressed on to assembler (mostly 6502 – but later 68000 on the Amiga, then 8086 on PC). In the early 90s I went for my first programming job, writing C & C++, which I prepared for by reading a book on C the night before. Somehow I managed to bluff my way in – but I hadn’t been there long before I realized I knew more C++ than anyone still there. That was the start of my C++ journey. It started on MS-DOS, but as the 90s progressed I naturally fell into Windows – which I did exclusively for the rest of the 90s.

A: What’s your background as a developer? I know you did C++ on Windows for a very long time. How did you end up doing iOS development in Objective-C and now Swift?

P: In the 2000s I changed things up a bit. The signs were there that C++’s heyday was coming to an end and I thought I should either learn other languages, or see which industries C++ would remain strong in. I started with the latter and moved into embedded programming – specifically mobile comms – where I stayed for about five years. It was a good experience and I’m glad I did it, but I also learned that embedded-programming was not for me. So I branched into banking, where I’ve mostly stayed until now. During that time, though, I also moved on the “other languages” front. First C#, then Python, then D and F#. At home I’d switched over exclusively to Macs, so I was interested in learning Objective-C, but it wasn’t until the iPhone AppStore launched that I gathered sufficient motivation to get past the initially steep learning curve!
Continue reading

Posted in Uncategorized | Tagged | 1 Comment

What’s New in ReSharper C++ 2016.2

As a part of ReSharper Ultimate 2016.2, our C++ team is happy to present the ReSharper C++ 2016.2 update. All in all, the new release comes with 200+ fixes and resolves several important performance- and stability-affecting issues. Let’s take a tour of the new features in this release.

Inline Variable

The mainline ReSharper’s refactorings continue to make their way into ReSharper C++. With the latest update, Inline Variable is now available for C++. This refactoring allows you to replace all occurrences of a variable in the code with its initializer. (The reverse functionality is already provided by the Introduce Variable refactoring.)
Inline Variable refactoring for cpp

Doxygen support

Doxygen is arguably the most popular format and tool for code documentation in the C++ world. ReSharper C++ now understands Doxygen syntax, and provides several key features to facilitate editing of documentation blocks:

  • Typing assist helps with creating new comment blocks and maintaining the structure of existing ones.
  • Code completion suggests Doxygen commands with accompanying short descriptions.
    Doxygen completion
  • Function parameter references introduced with \param commands will be reported by Find Usages and will get updated when Rename is used to change a function parameter’s name.
    Rename \param
  • Warnings are issued when function parameter references do not resolve to an existing function parameter.
    Unresolved \param

Documentation generation

You can now generate documentation for C++ declarators, classes and macro definitions. Since parsing a C++ file can require a significant amount of time, to avoid UI freezes this feature is implemented via a context action available when using Alt+Enter on the entity’s name.
Document context action
When the action is applied, ReSharper C++ uses the builtin doc live template to generate the resulting comment. The default documentation template is configured to be compatible with Doxygen syntax, but it can be customized (as usual) using the Templates Explorer tool window. An assortment of specialized documentation macros can be used inside the template, which evaluate to:

  • Short or qualified name of the entity that is being documented.
  • Function/macro/template parameter name or type (the containing template line is duplicated for each corresponding parameter).
  • Function return value, if there is one.

Quick Documentation

Thanks to Doxygen support, Quick Documentation now works in C++. The documentation pop-up (bound to Ctrl+Shift+F1 in the Visual Studio scheme or Ctrl+Q in the IntelliJ IDEA scheme) will display documentation from Doxygen comment blocks, or the symbol’s signature if no documentation is found.
Quick documentation pop-up

Code analysis

ReSharper C++ now understands several of the standard C++11 attributes and their Visual C++ counterparts:

  • Usages of functions and classes marked with [[deprecated]]/__declspec(deprecated) are reported together with the specified reason.
    Highlighting of a deprecated function
  • Not all control paths return a value and other control-flow based analyses correctly handle functions marked with [[noreturn]]/__declspec(noreturn).

Most header files should start with some form of include guard to avoid multiple inclusion. Similar to the Missing precompiled header include for .cpp files, ReSharper C++ will now warn you if a header file lacks an include guard and will provide a fix to automatically add a #pragma once directive.
include_guard

Omitting noexcept specifications from user-defined move constructors and assignment operators can have serious performance implications (for an in-depth discussion refer to this blog-post or Item 14 of Scott Meyers’ excellent “Effective Modern C++”). To make sure this is intentional, ReSharper C++ will warn you about move constructors, move assignment operators and swap functions without an explicit noexcept specification, with corresponding fixes to add one.
Move constructor without noexcept

Starting with Visual Studio 2013, the Visual C++ compiler has supported explicit user defined conversions. To complement the existing Non-explicit converting constructor inspection, Non-explicit conversion operator was added. Severity for both analyses is set to Hint by default (so they are not shown as suggestions), but can be increased if you prefer to avoid implicit user-defined type conversions.
Non-explicit converting constructor

In addition to suggesting to replace zero constants with nullptr in pointer contexts, ReSharper C++ will also offer replacing integral constants with true/false in boolean contexts.
Replace expression with true

Last but not least, another new inspection detects missing default cases in switch statements and provides a fix to insert it. The same fix is also available for the Uncovered enumerators inspection.
Default case

Go to Text

A new member of the Go to family, Go to Text navigation (Ctrl+T,T,T in the Visual Studio keyboard scheme or Ctrl+N,N,N in the IntelliJ IDEA scheme), lets you quickly find and navigate to any text in source and textual files in the entire solution.
Go to text
This new feature uses trigram indexing to make text search blazing-fast. Similar to other navigation commands, if there are too many matching items you can press + on the numeric keypad to explore results in the Find Results window.

New code style options

New formatter options provide support for some commonly used styles in C++ code:

  • The Braces Layout | Keep simple compound statements in one line setting was added to allow single-line definitions of trivial functions. It can be set to force ReSharper C++ to make such functions single- or multi-line, or to simply not change their formatting.
    Keep simple compound statements in one line
  • A related setting, Blank Lines | Around single line function definitions, controls the number of blank lines that a single-line function should be surrounded with.
  • The Wrapping and Aligning | Break line before member initializer list option controls whether to start member initializer lists on a new line.
    Break line before member initializer lists

Different projects use different conventions for the syntax of #include directives – as a result, we received several requests to make auto-generated #include directives more customizable. ReSharper C++ now provides preferences about whether to insert paths relative to the current file and when angle brackets should be used instead of quotes.
Include directives settings

A couple of settings were added specifically for compatibility with pre-C++11 codebases:

  • Formatter gets an option to require a space between closing angle brackets in template arguments, to avoid a notorious parsing issue in C++98.
    Space between closing angle brackets in template arguments
  • Instead of nullptr, ReSharper C++ can be configured to use NULL or 0 for default pointer initializers.
    Default pointer initializer

Generate improvements

In addition to Google Mock, the mock function generator now supports Trompeloeil. Trompeloeil is a modern header-only C++14 mocking framework, and is a great alternative to Google Mock when your project needs a mocking library but does not use Google Test. As with Google Mock, the generator becomes available when ReSharper C++ detects that the library is included into the current source file.
Trompeloeil mocks

Several existing code generators received new options:

  • To complement the related code analysis, copy/move operations and swap function generators allow making generated functions noexcept.
  • Similar to relational operators, the equality operator generator now has an option to use std::tie.
  • The constructor generator now lets you specify the accessibility of generated constructor(s) (starting with ReSharper C++ 2016.2.1).

Auto-import completion

Code completion in C++ became integrated with auto-import and can suggest symbols that are not included into the current file. The necessary #include directives are added automatically when an auto-import item gets used.
Import suggestions in C++ auto-completion
Please note that auto-import items get added into the completion list asynchronously, so they will be available after a short delay.

Code template enhancements

If you need to surround a piece of code with a template, just select the code and type in the name of the template you need: no extra shortcuts required. Furthermore, a single template can now be used for creating code (as a live template) and for surrounding existing code (as a surround template).
Surround templates

The default C++ class and struct file templates now contain a macro that expands into an #include directive for the precompiled header file, if the project uses one.

Odds and ends

Keeping up with the language evolution, ReSharper C++ extends its support of the C++14 standard. In particular, variable templates and decltype(auto) are now supported.

When your caret is on one of the exit points of a function/loop/switch (return, throw etc.), ReSharper C++ will automatically highlight all other exit points.
highlighting_exits

Similar to Visual Studio’s __INTELLISENSE__ define, ReSharper C++ now defines its own __RESHARPER__ macro in the internal preprocessor implementation. If necessary, this definition can be used to guard code that ReSharper C++ does not understand for some reason, or to hide parts of a file from code analysis.
__RESHARPER__ define

CppCon 2016

If you are attending CppCon 2016, be sure to stop by the JetBrains booth September 20-21! Members from both the CLion and ReSharper C++ teams will be present, and we will be happy to tell you all about our products, share future plans and answer your questions. Don’t miss your chance to participate in our license raffle and win a free 1-year subscription for any JetBrains C++ product of your choice!

CppCon 2016

As always, we would like to hear your feedback – and if you have any problems or feature suggestions, do not hesitate to contact us or create a request in our issue tracker!

Posted in ReSharper C++ Tips & Tricks | Tagged , , | 3 Comments

C++ Annotated: Jun – Aug 2016

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: June – August 2016

In this edition:

  • Interviews
  • Conferences
  • News & Stories
  • Releases

Interviews

Jon Kalb speaks about CppCon, C++17 standard and C++ community

jon-kalb

These months were quiet in terms of conferences, but September is just around the corner with the most well-known and significant event in the C++ world – CppCon. CLion’s PMM, Anastasia Kazakova, talked to Jon Kalb, CppCon Chair and C++ instructor. The first topic discussed was the C++ community and how modern language features are adopted by it. They went on talking about Jon’s feeling towards C++17 and his strong faith that the committee did everything just right. Jon also shared a secret recipe and a magic ingredient of CppCon success and a story of CppCat, and spoke about the era of tools for C++.

An interview with Sean Parent

sean-parent

Jens Wellers from Meeting C++ did an interview with Sean Parent. Learn why Sean would select Argument-Dependant Lookup if he could remove one feature from C++ language; why he thinks garbage collection has no place as a part of the general allocation scheme; discover his views on functional programming, smart pointers, coding guidelines and a bunch of other topics.

Stephen Kelly at CppCast

stephen-kelly

During these months many interesting episodes of CppCast were published. One of them is an interview with Stephen Kelly, Qt and CMake expert and maintainer. He talks about Qt build system and CMake similarities and how they can co-exist. While the most interesting part of the interview is dedicated to CMake API and how tools like IDEs can use it to integrate deeper with CMake, Stephen also answers questions about its design and why they dropped the idea of simply generating more content on a CMake call and decided to use the idea of the CMake server instead. In the end, Stephen shares some tips on CMake productive usage, like creating and using CMake config files.

Another great episode of CppCast worthy of a mention is an episode with Herb Sutter reviewing the results of the Oulu C++ committee meeting.
Continue reading

Posted in Uncategorized | Tagged , | Leave a comment

C++ Annotated: March – May 2016

Today we are happy to share our next compilation of C++ news with you.

Subscribe to the regular C++ Annotated and be the first to get the next edition!

C++ Annotated: March – May

In this edition:

  • Conferences
  • News & Stories
  • Webinars
  • Releases

Conferences

ACCU 2016

accu In April, ACCU came back to Bristol, UK, as usual. The premier UK developer conference this time brought together more than 400 attendees and over 60 speakers. Four playlists with video recordings, one for each day, are already available on YouTube. Lots of interesting topics were covered this year, for example Greg Law’s talk about profound and thus less known GDB features, Diego Rodriguez-Losada’s talk about C/C++ and Python working together, a talk from our developer advocate Dmitri Nesteruk about Design Patterns in Modern C++, and many more.

Besides, ACCU 2016 Chair, Russel Winder, gave JetBrains an interview where he talked about things that make ACCU unique, as well as his experience with Rust, D and Go languages and their future in comparison to C++.

C++Now 2016

cppnow Across the pond, C++Now 2016 was held in Aspen, Colorado, in early May. Attendees could find a lot of well-known names from the C++ community joining the event, like Sean Parent from Adobe with a keynote talk about Better code, Jon Kalb with his famous O’Reilly report about C++ landscape overview, Timur Doumler, a JUCE developer from ROLI, Marshall Clow, Barbara Geller, David Sankel, and many others.

Check out the best session winners and learn about C++Now 2017 dates in the blog post.

Italian C++ Conference 2016

Another C++ event was held in Italy in May. More than 100 people attended the very first Italian C++ conference in Milan. You can find the report about the event here. In particular, we want to draw your attention to two of James McNellis’ talks, Adventures in a Legacy Codebase and An Introduction to C++ Coroutines.

News & Stories

C++17 standard news

cpp March brought several reports about the C++ meeting in Jacksonville, Florida. Herb Sutter posted a long and detailed one in his blog. Despite many expectations and hopes in the C++ community, modules and concepts won’t come to C++17. However, for now they will both stay in their own technical specification. Coroutines are targeted for another TS as well. On the good side, Herb lists the features that are making their way to the upcoming C++ standard, like Parallel STL and several more TS that were merged into the final C++17 edition, and several features coming directly to the new standard like fallthrough, nodiscard and maybe_unused attributes and more. The future of C++ is presented in Herb’s blog post in a simple timeline, followed by an interesting open-ended question: Will C++ stay on the 3-year cycle or move to a 2-year cycle?

C++11 smart pointers

C++ developers (both students and professionals) can find this blog post useful, as it uncovers 10 dangerous pitfalls when working with C++11 smart pointers. It tells you where it’s better to use shared_ptr, unique_ptr and auto_ptr; how to avoid double memory allocation by using make_shared; and lays out the rules for working with the raw pointers.

lambdas and std::function

lambda C++11 lambdas are already widely used. The idea is pretty simple. The easiest (though probably useless) example is “[](){}();”. But do we know them well enough to answer even basic questions? What is the lambda’s type and why is it not std::function? How long do the variables captured by lambda stay alive? What is the size of a lambda? If you feel like testing your knowledge of lambdas, head straight to this blog post.

Conan

conan In the previous edition we already mentioned Conan, a C/C++ package manager. This time we’d like to share more information about it. First up is a CppCast episode with Diego Rodriguez-Losada, known as a biicode startup co-founder and currently Conan committer. Watch the episode to learn the Conan story first-hand.

There is also a great post in Conan’s blog for those interested in setting up a full environment for C/C++ development based on Clang as the compiler, CMake as the build system, CLion as the IDE, and Conan as the package manager. Check the steps and follow advices for an easy set-up.

Compiler Bugs Found When Porting Chromium to VC++ 2015

64_read Bruce Dawson from Google posted some great material on the bugs found while porting a big Chromium project from VC++2013 to VC++ 2015. The incredible work includes attempts to build some smaller samples to reproduce the problems, as well as some deeper analysis of the situations. Read the post to know about a problem with zeroing a five-byte array, a crash that would happen only under Profile Guided Optimization, an incorrect 64-bit structure read, and more.

Telemetry function calls in VS 2015

telemetry Recently the C++ community has been discussing the telemetry call in every binary compiled in VS2015. The discussion was huge as conspiracy theories are always popular, even though the logs written in that case were quite limited and have to be switched on manually (so not working by default).

However, the discussion on reddit got an official comment. Steve Carroll from the Visual C++ team has promised that the corresponding calls will be removed in Update 3. He explained that the main intent was to build a framework that would help investigate performance problems and improve the quality of the optimizer.

C++ I/O Benchmark

compilers Cristian Adam posted in his blog nice and solid benchmark for C++ cross-platform calls for Input/Output on Windows 10, Kubuntu 15.10 and Raspberry PI2, testing on a huge set of compilers: GCC, Clang, Visual C++ (2013/15), MinGW GCC, Cygwin GCC and Cygwin Clang. During the test he was reading one file in chunks of 1 MB and writing it to another file. The tested API calls were: C file API (fopen, fread, fwrite), C++ API (std::ifstream, std::ofstream) and POSIX API (open, read, write). And the winner’s crown went to… POSIX. See the full blog post for some interesting numbers.

CppCast

cppcast
CppCast continues gathering famous C++ community members. Jens Weller talked about the Meeting C++ platform that brings the conference, site and recruiting platform to the C++ world. Get the whole story first-hand. An interview with the author of the renowned blog Simplify C++, Arne Mertz, was recorded for CppCast in March. Find the discussion of the latest standard and more topics in there. April brought an interesting discussion with Ankit Asthana about cross-platform development, Visual Studio Code and Visual Studio for Linux. Elena Sagalaeva (known by the Russian-speaking community for her famous blog on C++ in Russian) attended the podcast in April as well, talking about distributed computing and how the latest C++ standards are useful there.

Webinars

Design Patterns and Modern C++

The recording of our May 24th webinar, Design Patterns and Modern C++, is now available on JetBrainsTV YouTube channel. In this webinar Dmitri Nesteruk shows how the classical design patterns that arose in 1994 from the infamous Gang of Four book continue to be as useful to this day. We are discussing the adapter pattern, the builder pattern and the maybe monad. Several questions from the webinar answered by Dmitri can be found in the corresponding blog post.

Releases

GCC 6.1

gcc-logo The new major release of GCC compiler was announced and brought lots of goodies. First of all, C++14 is set as a default. Besides, many features from the upcoming C++17 were added to the compiler (for both language and standard library), and even Concepts, that were postponed by the committee to another TS, are available in GCC 6.1 via -fconcepts.

Checking the list of the General Optimizer Improvements in the release notes, you may notice an interesting point that C++ developers definitely should heed: “Value range propagation now assumes that the this pointer of C++ member functions is non-null”. You may want to check whether your code base is affected by the change, just as it happened to Qt5, Chromium and KDevelop. Anyway, GCC authors suggest a temporary workaround: -fno-delete-null-pointer-checks.

Clang 3.8

libclang A lot of goodies were delivered with the Clang 3.8 release, including OpenMP 3.1 (and several elements of the OpenMP 4.0/4.5), experimental support for end-to-end CUDA compilation, static analyzer improvements, and more. You can also track the progress of the new features through the Clang 3.9 (in progress) release notes.

ReSharper C++ 2016.1

R++_400x400_Twitter_logo_white April brought the release of ReSharper C++, a Visual Studio extension for C++ developers. In addition to Google Test support, Boost.Test is now added, including a built-in test runner. This version allows you to mark your code with TODO, BUG, FIXME or any other pattern you may prefer (configurable in settings), and navigate through the marks easily using a special Todo Explorer.

The release also brought a long list of new quick-fixes and context actions that help improve the code, by suggesting various fixes. One example is when ReSharper C++ detects an uninitialized constructor parameter, it offers a context action to create and initialize the corresponding field. Find more details about the new version in this blog post.

CLion 2016.1

CLion_400x400_Twitter_logo_whiteCLion, a cross-platform IDE for C and C++ developers, got an important update. Release 2016.1 finally brought variadic templates support and auto-import for STL symbols. Quick Documentation pop-up was enhanced with the hyperlinks to the related symbols. During debugging users are now allowed to attach to the process running on a local machine but not started from the IDE – all the benefits of the built-in debugger UI are still there.

To speed up the indexing time, CLion 2016.1 lets you mark directories as excluded (several more option like libraries or sources are also available).
Overgrowing just C and C++ development, CLion turns to the multi-languages projects bringing Python and Swift support on board. Feel free to check the details in the CLion’s blog.

Finally, CLion started a new Early Access Program for version 2016.2. This build addresses Doxygen support, Complete Statement and VCS changes, CMake rename refactoring for users symbols and more.

Qt Creator 4

qt Qt came out with big news in May and released Qt Creator 4.0.0. It includes CMake workflow changes (like automatic triggering when necessary, UI to change the CMake configuration for a build directory and more), automatic use for the Clang code model, Clang static analyzer integration available under open source, fixes for the latest LLDB version and several more improvements.

Visual Studio 2015 Update 2

vs_cpp Microsoft has given us a lot of exciting news in these months. Update 2 comes with many interesting changes for C++ developers. C++ compiler got many bug fixes, with the most notable changes including support for Variable Templates and constexpr improvements. At the same time, many C++17 features have made their way to C++ standard library as well.

However, the biggest improvement is probably for those who develop for Linux, as the new extension makes possible C++ development in Visual Studio for Linux. You can now create projects and manage connections to the Linux machine right from the VS. Upon connecting, VS will copy your sources to the remote Linux machine and will invoke GCC to build the sources with the options from the project properties. Then you can debug your code remotely.

Looking into the future of Visual C++ compiler, read this blog post about upcoming changes in Visual C++ code optimizer. Find out the reasons behind the new optimizer, and see several samples of implemented optimizations.

That’s it! Let us know in the comments if you like current edition.

Cheers,
The C++ Team

Posted in Uncategorized | Tagged , | 1 Comment

What’s New in ReSharper C++ 2016.1

Apart from the change in version numbers, ReSharper C++ comes with plenty of new features as well as improvements to existing functionality. Here’s what we’ve got in store for you with this release.

Boost.Test Support

The previous release of ReSharper C++ provided a unit test runner for Google Test — well, this one augments this with Boost.Test support. This includes all the usual refinements users of our unit test infrastructure are used to. ReSharper will detect individual Boost tests as well as test suites:

ReSharper C++ Boost.Test Detection

There is also support for test labels:

ReSharper C++ Boost.Test Label Support

And of course it will use its unit test runner to actually run those tests and show a listing of the results.

ReSharper C++ Boost Unit Test Runner

Please note that Boost.Test support requires Boost 1.59 or later.

Todo Explorer

The Todo Explorer is a separate tool window that has long existed in the original ReSharper but is now coming to ReSharper C++. Its goal is to find text that matches a specific pattern in comments, strings or identifiers and show all the located elements in a single, easy-to-browse list:

ReSharper C++ Todo Explorer

There are plenty of filtering and grouping options in this window, and double-clicking each element takes you right to the line of code where the relevant piece of information was found. ReSharper comes with support for TODO and BUG in comments, but you can easily add other markers or create new ones:

ReSharper C++ Todo Explorer Edit Pattern

As the above screenshot demonstrates, you can define the regular expression to search for, the type of code element (comments, strings, identifiers) to search in, and you can also control the color that’s used for this type of item in the Todo Explorer.

Context Actions and Quick-Fixes

As with all releases, we keep expanding the set of context actions and quick-fixes that ReSharper C++ provides. Here are a few examples.

If an out-of-class member function signature fails to match the prototype in the class body, ReSharper C++ now offers two quick-fixes to change that:

ReSharper C++ Change Signature

Choosing Use signature…, the signature of the function definition will be changed to the one of its declaration. Choosing Change signature… does the reverse, changing the declaration so that it matches the definition.

ReSharper C++ Change Signature Refactoring

When ReSharper C++ detects an uninitialized constructor parameter, we now offer a context action to create and initialize the corresponding field

ReSharper C++ Create and Initialize Field

When ReSharper C++ detects possible unintended object slicing, it offers the option to perform a static_cast:

ReSharper C++ Possible Unintended object slicing

If the type of variable being returned from a function does not match the type in the function signature, ReSharper C++ offers the options to adjust either the return type or the type of variable being returned:

ReSharper C++ Incorrect Return Type Quick-Fix

In fact, we have a more general mechanism for detecting type mismatches: for example, assigning an int variable a string literal will present you with the following:

ReSharper C++ Change Type

If you try to assign a read-only member in a const function, ReSharper C++ now offers you quick-fixes to either to make the member mutable or make the function non-const:

ReSharper C++ Make Member Mutable

If a base class or its function has a final modifier, ReSharper C++ will highlight the error over both the final keyword as well as any overriding classes and offer you a quick-fix to make the base class non-final:

ReSharper C++ Remove Final Keyword

New context actions are also provided to flip operator arguments and negate boolean expressions:

We’ve added fixes and context actions for working with includes: analyses related to precompiled header usage, context actions to normalize slashes in include paths, support for replacement of quotes with angle brackets (and vise versa).

ReSharper C++ Quote Replacement

In addition to the bulk generate definitions action, we now have bulk Move Function Implementations context action. Simply select several function bodies and press Alt+Enter:

ReSharper C++ Move Function Implementations

Rename Refactoring Improvements

And there are additional fixes, too. For example, the Rename refactoring now works on files, and will rename both the file as well as any usage (e.g., in #include directives) of the file:

ReSharper C++ Rename Refactoring on Files

It’s also worth noting that the Rename behavior on an ordinary class will now affect the header/cpp filenames, too.

Code Generation

We’ve made improvements in the code generation functionality. For example, when generating relational operators, ReSharper C++ now offers the option of using std::tie:

ReSharper C++ Code Generation Relational Operators std::tie

Another feature we’ve added to the Generate stream operations feature is the support for the use of Boost for purposes of serialization:

ReSharper C++ Stream Output Private Boost.Serialize Operations

And a Few More Things

Starting with version 2016.1, the Find Code Issues functionality works in the background in both ReSharper and ReSharper C++. This lets you keep editing or navigating your code while ReSharper runs its analysis.

The list of C++ language features supported by ReSharper C++ has also been extended with support for generalized lambda captures, exception specifications and inheriting constructors. We also have formatting options now being taken into account when generating code.

The formatting settings have a new page for controlling blank lines.

Finally, all ReSharper C++ actions are now actively banned from changing the code of any of the C++ libraries that you might be using.

So that’s it! Enjoy the new release of ReSharper C++, and be sure to let us know what you think!

Posted in News & Events, ReSharper C++ Tips & Tricks | Tagged , , | 5 Comments