[PATCH] Verify assign operator signatures.

Alexander Kornienko alexfh at google.com
Fri Feb 6 05:33:00 PST 2015


What about `virtual T& operator=(const T&);`? It looks like a bad pattern, IMHO.

Also, it looks like the check is not specific to Google and it's not exactly about readability. Maybe move it to misc/?


================
Comment at: clang-tidy/google/AssignOperatorSignatureCheck.cpp:23
@@ +22,3 @@
+  Finder->addMatcher(
+      methodDecl(unless(isDeleted()), unless(isPrivate()), hasName("operator="),
+                 ofClass(recordDecl().bind("class")),
----------------
sbenza wrote:
> alexfh wrote:
> > I guess you missed "unless(isImplicit())" (and a test for it). And maybe also unless(isInTemplateInstantiation()) (especially, if you would want to provide a fixit for the "const T& operator=(const T&)" case).
> I could add unless(isImplicit()), but the implicit one will have the right signature, so it shouldn't match anyway.
Reasonable. Maybe a comment would not be useless.

http://reviews.llvm.org/D6667

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list