llvm-svn: 270472
This commit is contained in:
Mads Ravn 2016-05-23 18:15:40 +00:00
parent fa2f307c54
commit dfa3b3d3ee
2 changed files with 12 additions and 0 deletions

View File

@ -181,6 +181,12 @@ 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 modernize-pass-by-value
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.

View File

@ -194,3 +194,9 @@ struct S {
Movable M;
};
// Test that types that are trivially copyable will not use std::move. This will
// cause problems with misc-move-const-arg, as it will revert it.
struct T {
std::array<int, 10> a_;
T(std::array<int, 10> a) : a_(a) {}
};