[PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

Martin Böhme via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 12 06:44:38 PDT 2016


mboehme added inline comments.

================
Comment at: test/clang-tidy/misc-move-forwarding-reference.cpp:50
@@ +49,3 @@
+// operator.
+template <typename T, typename U> void f5(U &&SomeU) {
+  {
----------------
Sorry, that should have been "scope resolution operator". Comment changed.

What this is trying to test is that the replacements still happen as desired even if there are spaces around the scope resolution operator. Unfortunately, I inadvertently deleted those spaces when I clang-formatted this entire file... I've now restored the spaces.

================
Comment at: test/clang-tidy/misc-move-forwarding-reference.cpp:118
@@ +117,3 @@
+}
+
+// Handle the case correctly where the forwarding reference is a parameter of a
----------------
Good point. Done.

As it turns out, the detection didn't yet work quite correctly. This was due to the special format of LambdaExprs for generic lambdas. In particular, what tripped my test up is that the same TemplateTypeParmDecl is contained in two different FunctionTemplateDecls -- one for operator() and one for __invoke.

As a result, I've needed to rewrite the detection to do a little more work outside of the matcher. (There was no way to do it inside the matcher as the FunctionTemplateDecl for operator() is actually not visited by the RecursiveASTVisitor.)


https://reviews.llvm.org/D22220





More information about the cfe-commits mailing list