diff options
author | John McCall <rjmccall@apple.com> | 2012-05-02 05:39:15 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2012-05-02 05:39:15 +0000 |
commit | 38dbb606755232e229f11994fc2bbf10e8c5788b (patch) | |
tree | 0e5d94911cda11f75288a5431d7f6fdf3c992ae0 /include/llvm/Support | |
parent | 9679f0f35742aa9792b01c26e08b2932cc8428ed (diff) | |
download | external_llvm-38dbb606755232e229f11994fc2bbf10e8c5788b.zip external_llvm-38dbb606755232e229f11994fc2bbf10e8c5788b.tar.gz external_llvm-38dbb606755232e229f11994fc2bbf10e8c5788b.tar.bz2 |
Update SmallVector to support move semantics if the host does.
Note that support for rvalue references does not imply support
for the full set of move-related STL operations.
I've preserved support for an odd little thing in insert() where
we're trying to support inserting a new element from an existing
one. If we actually want to support that, there's a lot more we
need to do: insert can call either grow or push_back, neither of
which is safe against this particular use pattern.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155979 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/Compiler.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index d0b186e..0ae02e8 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -19,6 +19,25 @@ # define __has_feature(x) 0 #endif +/// LLVM_HAS_RVALUE_REFERENCES - Does the compiler provide r-value references? +/// This implies that <utility> provides the one-argument std::move; it +/// does not imply the existence of any other C++ library features. +#if (__has_feature(cxx_rvalue_references) \ + || defined(__GXX_EXPERIMENTAL_CXX0X__) \ + || _MSC_VER >= 1600) +#define LLVM_USE_RVALUE_REFERENCES 1 +#else +#define LLVM_USE_RVALUE_REFERENCES 0 +#endif + +/// llvm_move - Expands to ::std::move if the compiler supports +/// r-value references; otherwise, expands to the argument. +#if LLVM_USE_RVALUE_REFERENCES +#define llvm_move(value) (::std::move(arg)) +#else +#define llvm_move(value) (value) +#endif + /// LLVM_LIBRARY_VISIBILITY - If a class marked with this attribute is linked /// into a shared library, then the class should be private to the library and /// not accessible from outside it. Can also be used to mark variables and |