summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp
diff options
context:
space:
mode:
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