[PATCH] D12031: Const std::move() argument ClangTidy check
Samuel Benzaquen via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 21 09:03:09 PDT 2015
sbenza added inline comments.
================
Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:20
@@ +19,3 @@
+ const auto* CallMove = result.Nodes.getNodeAs<CallExpr>("call-move");
+ if (CallMove->getNumArgs() != 1) return;
+ const Expr* Arg = CallMove->getArg(0);
----------------
You can move both checks to the matcher.
Something like:
callExpr(callee(functionDecl(hasName("::std::move"))),
argumentCountIs(1),
hasArgument(0, expr(hasType(isConstQualified()))))
================
Comment at: clang-tidy/misc/MoveConstantArgumentCheck.cpp:32
@@ +31,3 @@
+ diag(CallMove->getLocStart(), "move of const variable")
+ << FixItHint::CreateReplacement(MoveRange, ArgString);
+ }
----------------
It is better to remove/insert than to replace.
Replacement could strip comments inadvertently.
In this case it also removes the need to find the text for the replacement.
You could do:
Remove(CallMove->Start(), Arg->Start())
Remove(CallMove->End(), CallMove->End())
http://reviews.llvm.org/D12031
More information about the cfe-commits
mailing list