Add -Wpessimizing-move and -Wredundant-move warnings.
authorRichard Trieu <rtrieu@google.com>
Wed, 29 Apr 2015 01:52:17 +0000 (01:52 +0000)
committerRichard Trieu <rtrieu@google.com>
Wed, 29 Apr 2015 01:52:17 +0000 (01:52 +0000)
commitac3eca536d3de943f4accd3d52a5ed31e3662017
tree268dfa85eadc684cb50c5d4fe2b47b12d817a867
parentf3a8362bf28b80573e4ca27aa5e9f81817c4dd4f
Add -Wpessimizing-move and -Wredundant-move warnings.

-Wpessimizing-move warns when a call to std::move would prevent copy elision
if the argument was not wrapped in a call.  This happens when moving a local
variable in a return statement when the variable is the same type as the
return type or using a move to create a new object from a temporary object.

-Wredundant-move warns when an implicit move would already be made, so the
std::move call is not needed, such as when moving a local variable in a return
that is different from the return type.

Differential Revision: http://reviews.llvm.org/D7633

llvm-svn: 236075
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaInit.cpp
clang/test/SemaCXX/warn-pessmizing-move.cpp [new file with mode: 0644]
clang/test/SemaCXX/warn-redundant-move.cpp [new file with mode: 0644]