summaryrefslogtreecommitdiff
path: root/include/llvm/Support/Compiler.h
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2012-05-02 05:39:15 +0000
committerJohn McCall <rjmccall@apple.com>2012-05-02 05:39:15 +0000
commit38dbb606755232e229f11994fc2bbf10e8c5788b (patch)
tree0e5d94911cda11f75288a5431d7f6fdf3c992ae0 /include/llvm/Support/Compiler.h
parent9679f0f35742aa9792b01c26e08b2932cc8428ed (diff)
downloadllvm-38dbb606755232e229f11994fc2bbf10e8c5788b.tar.gz
llvm-38dbb606755232e229f11994fc2bbf10e8c5788b.tar.bz2
llvm-38dbb606755232e229f11994fc2bbf10e8c5788b.tar.xz
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/Compiler.h')
-rw-r--r--include/llvm/Support/Compiler.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h
index d0b186ea7c..0ae02e85c5 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