[PATCH] D70052: [clang-tidy] Add misc-mutating-copy check

Gabor Bencze via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 10 13:05:44 PST 2019


gbencze added a comment.

In D70052#1740142 <https://reviews.llvm.org/D70052#1740142>, @mgehre wrote:

> Did you consider to warn on copy constructors/assignment operators take a their arguments by non-`const` reference, and suggest the user to turn them into const references? This seems like a more useful (and easier) check to me.
>  The link above contains `Ideally, the copy operator should have an idiomatic signature. For copy constructors, that is T(const T&); and for copy assignment operators, that is T& operator=(const T&);.`.
>
> The only remaining case are then `mutable` members which are quite rare.


I haven't really considered it as the non-compliant example has the idiomatic signature, but it probably would be a good addition to the check. misc-unconventional-assign-operator already seems to do this for the assignment operator.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70052/new/

https://reviews.llvm.org/D70052





More information about the cfe-commits mailing list