forked from OSchip/llvm-project
parent
fa2f307c54
commit
dfa3b3d3ee
|
@ -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.
|
||||
|
|
|
@ -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) {}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue