summaryrefslogtreecommitdiffstats
path: root/libcxx/include/algorithm
diff options
context:
space:
mode:
authorDimitry Andric <dimitry@andric.com>2015-08-19 06:43:33 +0000
committerDimitry Andric <dimitry@andric.com>2015-08-19 06:43:33 +0000
commit251c6291170cf6c999655626a0e246c9f7117dab (patch)
tree21b2ee81128f41388acf653dcdf341752db6a6f1 /libcxx/include/algorithm
parent1098e496e1bf32400ae59bfab135eeb70e930b41 (diff)
downloadbcm5719-llvm-251c6291170cf6c999655626a0e246c9f7117dab.tar.gz
bcm5719-llvm-251c6291170cf6c999655626a0e246c9f7117dab.zip
Fix warnings about pessimizing return moves for C++11 and higher
Summary: Throughout the libc++ headers, there are a few instances where _VSTD::move() is used to return a local variable. Howard commented in r189039 that these were there "for non-obvious reasons such as to help things limp along in C++03 language mode". However, when compiling these headers with warnings on, and in C++11 or higher mode (like we do in FreeBSD), they cause the following complaints about pessimizing moves: In file included from tests.cpp:26: In file included from tests.hpp:29: /usr/include/c++/v1/map:1368:12: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move] return _VSTD::move(__h); // explicitly moved for C++03 ^ /usr/include/c++/v1/__config:368:15: note: expanded from macro '_VSTD' #define _VSTD std::_LIBCPP_NAMESPACE ^ Attempt to fix this by adding a _LIBCPP_EXPLICIT_MOVE() macro to __config, which gets defined to _VSTD::move for pre-C++11, and to nothing for C++11 and later. I am not completely satisfied with the macro name (I also considered _LIBCPP_COMPAT_MOVE and some other variants), so suggestions are welcome. :) Reviewers: mclow.lists, howard.hinnant, EricWF Subscribers: arthur.j.odwyer, cfe-commits Differential Revision: http://reviews.llvm.org/D11394 llvm-svn: 245421
Diffstat (limited to 'libcxx/include/algorithm')
-rw-r--r--libcxx/include/algorithm2
1 files changed, 1 insertions, 1 deletions
diff --git a/libcxx/include/algorithm b/libcxx/include/algorithm
index c1635fc9f51..908882940b9 100644
--- a/libcxx/include/algorithm
+++ b/libcxx/include/algorithm
@@ -851,7 +851,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f)
{
for (; __first != __last; ++__first)
__f(*__first);
- return _VSTD::move(__f); // explicitly moved for (emulated) C++03
+ return _LIBCPP_EXPLICIT_MOVE(__f); // explicitly moved for (emulated) C++03
}
// find
OpenPOWER on IntegriCloud