[PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 1 06:52:12 PDT 2016


aaron.ballman added inline comments.

================
Comment at: test/clang-tidy/misc-assign-operator.cpp:16
@@ +15,3 @@
+  AlsoGood& operator=(AlsoGood);
+};
+
----------------
sbenza wrote:
> This is a very common C++98 way of implementing copy-and-swap with copy elision support.
> You do: `T& operator=(T t) { swap(t); return *this; }`
> And it will avoid the copy if the argument is already a temporary due to copy elision on the caller.
I wasn't arguing that it wasn't useful, but this check is also registered as cppcoreguidelines-c-copy-assignment-signature, and so we need to make sure that we aren't breaking that check. Basically, this can be resolved by looking at the spelling of the check and deciding whether to diagnose this particular case or not and add appropriate tests. (We do this for a few checks shared with CERT rules as well.)


http://reviews.llvm.org/D18265





More information about the cfe-commits mailing list