Index: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp @@ -188,7 +188,8 @@ // 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)) + if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType( + *Result.Context)) return; auto Diag = diag(ParamDecl->getLocStart(), "pass by value and use std::move"); Index: clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h +++ clang-tools-extra/trunk/test/clang-tidy/Inputs/modernize-pass-by-value/header.h @@ -1,4 +1,7 @@ class ThreadId { +public: + ThreadId(const ThreadId &) {} + ThreadId(ThreadId &&) {} }; struct A { Index: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp @@ -3,6 +3,6 @@ // RUN: FileCheck -input-file=%T/pass-by-value-header.h %s -check-prefix=CHECK-FIXES #include "pass-by-value-header.h" -// CHECK-MESSAGES: :5:5: warning: pass by value and use std::move [modernize-pass-by-value] +// CHECK-MESSAGES: :8:5: warning: pass by value and use std::move [modernize-pass-by-value] // CHECK-FIXES: #include // CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {} Index: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp @@ -6,6 +6,8 @@ #include HEADER struct A { + A(const A &) {} + A(A &&) {} }; struct B { Index: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp +++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp @@ -2,8 +2,15 @@ namespace { // POD types are trivially move constructible. +struct POD { + int a, b, c; +}; + struct Movable { int a, b, c; + Movable() = default; + Movable(const Movable &) {} + Movable(Movable &&) {} }; struct NotMovable { @@ -147,7 +154,8 @@ // Test with value parameter. struct O { O(Movable M) : M(M) {} - // CHECK-FIXES: O(Movable M) : M(M) {} + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move + // CHECK-FIXES: O(Movable M) : M(std::move(M)) {} Movable M; }; @@ -179,7 +187,8 @@ } struct R { R(ns_R::RMovable M) : M(M) {} - // CHECK-FIXES: R(ns_R::RMovable M) : M(M) {} + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move + // CHECK-FIXES: R(ns_R::RMovable M) : M(std::move(M)) {} ns_R::RMovable M; }; @@ -199,3 +208,8 @@ // CHECK-FIXES: T(array a) : a_(a) {} array a_; }; + +struct U { + U(const POD &M) : M(M) {} + POD M; +};