summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2016-08-24 21:23:24 +0000
committerAlexander Kornienko <alexfh@google.com>2016-08-24 21:23:24 +0000
commiteedcd9c1ea4c98b97714bcc7fc4167fd4cb47b37 (patch)
tree7075c871a897d19cfd31efdba159ba6e6306c4d6 /clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp
parent9c3633f516fbc995abc46f4d0684d0a0411ccaca (diff)
downloadbcm5719-llvm-eedcd9c1ea4c98b97714bcc7fc4167fd4cb47b37.tar.gz
bcm5719-llvm-eedcd9c1ea4c98b97714bcc7fc4167fd4cb47b37.zip
[clang-tidy misc-move-const-arg] more specific messages + suggest alternative solution
llvm-svn: 279666
Diffstat (limited to 'clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp')
-rw-r--r--clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp b/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp
index cf62732a3cd..04812139196 100644
--- a/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -74,12 +74,17 @@ void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
if (IsConstArg || IsTriviallyCopyable) {
bool IsVariable = isa<DeclRefExpr>(Arg);
+ const auto *Var =
+ IsVariable ? dyn_cast<DeclRefExpr>(Arg)->getDecl() : nullptr;
auto Diag = diag(FileMoveRange.getBegin(),
"std::move of the %select{|const }0"
- "%select{expression|variable}1 "
- "%select{|of a trivially-copyable type }2"
- "has no effect; remove std::move()")
- << IsConstArg << IsVariable << IsTriviallyCopyable;
+ "%select{expression|variable %4}1 "
+ "%select{|of the trivially-copyable type %5 }2"
+ "has no effect; remove std::move()"
+ "%select{| or make the variable non-const}3")
+ << IsConstArg << IsVariable << IsTriviallyCopyable
+ << (IsConstArg && IsVariable && !IsTriviallyCopyable)
+ << Var << Arg->getType();
ReplaceCallWithArg(CallMove, Diag, SM, getLangOpts());
} else if (ReceivingExpr) {
OpenPOWER on IntegriCloud