summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/modernize
diff options
context:
space:
mode:
authorMads Ravn <madsravn@gmail.com>2016-05-24 15:00:16 +0000
committerMads Ravn <madsravn@gmail.com>2016-05-24 15:00:16 +0000
commit7175c2ce4d669e8ca2e97ec01eca86b7764173f6 (patch)
tree84b42c954c2f153dad7cba50039912ace857deba /clang-tools-extra/clang-tidy/modernize
parentad5b55a2776a9beb675c4172093fe7d067dc9907 (diff)
downloadbcm5719-llvm-7175c2ce4d669e8ca2e97ec01eca86b7764173f6.tar.gz
bcm5719-llvm-7175c2ce4d669e8ca2e97ec01eca86b7764173f6.zip
[clang-tidy] modernize-pass-by-value bugfix
Modified the clang-tidy PassByValue check. It now stops adding std::move to type which is trivially copyable because that caused the clang-tidy MoveConstArg to complain and revert, thus creating a cycle. I have also added a lit-style test to verify the bugfix. This is the bug on bugzilla: https://llvm.org/bugs/show_bug.cgi?id=27731 This is the code review on phabricator: http://reviews.llvm.org/D20365 llvm-svn: 270565
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize')
-rw-r--r--clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
index c727deb7969..b8f83bbd7c1 100644
--- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
@@ -181,6 +181,11 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) {
if (!paramReferredExactlyOnce(Ctor, ParamDecl))
return;
+ // If the parameter is trivial to copy, don't move it. Moving a trivivally
+ // copyable type will cause a problem with misc-move-const-arg
+ if (ParamDecl->getType().isTriviallyCopyableType(*Result.Context))
+ return;
+
auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use std::move");
// Iterate over all declarations of the constructor.
OpenPOWER on IntegriCloud