Commit Graph

7 Commits

Author SHA1 Message Date
Richard Trieu 1993dc8b15 Fix -Wredundant-move warning.
Without DR1579 implemented, the only case for -Wredundant-move is for a
parameter being returned with the same type as the function return type.  Also
include a check to verify that the move constructor will be used by matching
nodes in the AST dump.

llvm-svn: 243594
2015-07-29 23:47:19 +00:00
Richard Trieu 6093d143c5 Disable -Wpessimizing-move and -Wredundant-move in template instantiations.
Dependent types can throw off the analysis for these warnings, possibly giving
conflicting warnings and fix-its.  Disabling the warning in template
instantiations will prevent this problem, and will still catch the
non-dependent cases in templates.

llvm-svn: 243538
2015-07-29 17:03:34 +00:00
Richard Trieu 8d4006a079 Do not give a -Wredundant-move warning when removing the move will result in an
error.

If the object being moved has a move constructor and a deleted copy constructor,
std::move is required, otherwise Clang will give a deleted constructor error.

llvm-svn: 243463
2015-07-28 19:06:16 +00:00
Richard Trieu 159e5ed9dc Change a test to follow the formatting of the rest of the tests in the file.
No functional change.

llvm-svn: 242854
2015-07-21 23:38:30 +00:00
Davide Italiano 7842c3fcea [Sema] Emit correct warning when copy-elision is not possible.
If we're returning a function parameter, copy elision isn't possible,
so we now warn for redundant move.

PR:		23819
Differential Revision:	 http://reviews.llvm.org/D11305

llvm-svn: 242600
2015-07-18 01:15:19 +00:00
Richard Trieu 1d4911bc99 Have -Wredundant-move ignore reference types.
Don't give a warning when the type being moved is a reference type.  Also
uncomment two lines in the test case.

llvm-svn: 237607
2015-05-18 19:54:08 +00:00
Richard Trieu ac3eca536d 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
2015-04-29 01:52:17 +00:00