summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-11-30 11:04:18 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-11-30 11:04:18 +0000
commita5bf44b0b396e8b9ae0db5c62c05ac6618aab5d3 (patch)
tree7b8ebc2ca50ea3c2660078232e2e88094e9d1d0a /include
parent58b45535495d20639849abf7a5605be5c8304b66 (diff)
downloadllvm-a5bf44b0b396e8b9ae0db5c62c05ac6618aab5d3.tar.gz
llvm-a5bf44b0b396e8b9ae0db5c62c05ac6618aab5d3.tar.bz2
llvm-a5bf44b0b396e8b9ae0db5c62c05ac6618aab5d3.tar.xz
Separate out the tests for whether the compiler suports R-value
references from whether it supports an R-value reference *this. No version of GCC today supports the latter, which breaks GCC C++11 compiles of LLVM and Clang now. Also add doxygen comments clarifying what's going on here, and update the usage in Optional. I'll update the usages in Clang next. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168993 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/Optional.h2
-rw-r--r--include/llvm/Support/Compiler.h16
2 files changed, 15 insertions, 3 deletions
diff --git a/include/llvm/ADT/Optional.h b/include/llvm/ADT/Optional.h
index 23100ab1b7..10fd75b738 100644
--- a/include/llvm/ADT/Optional.h
+++ b/include/llvm/ADT/Optional.h
@@ -55,7 +55,7 @@ public:
const T* operator->() const { return getPointer(); }
const T& operator*() const LLVM_LVALUE_FUNCTION { assert(hasVal); return x; }
-#if LLVM_USE_RVALUE_REFERENCES
+#if LLVM_HAS_RVALUE_REFERENCE_THIS
T&& getValue() && { assert(hasVal); return std::move(x); }
T&& operator*() && { assert(hasVal); return std::move(x); }
#endif
diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h
index 7d9785cdae..6cb397555f 100644
--- a/include/llvm/Support/Compiler.h
+++ b/include/llvm/Support/Compiler.h
@@ -30,6 +30,18 @@
#define LLVM_USE_RVALUE_REFERENCES 0
#endif
+/// \brief Does the compiler support r-value reference *this?
+///
+/// Sadly, this is separate from just r-value reference support because GCC
+/// implemented everything but this thus far. No release of GCC yet has support
+/// for this feature so it is enabled with Clang only.
+/// FIXME: This should change to a version check when GCC grows support for it.
+#if __has_feature(cxx_rvalue_references)
+#define LLVM_HAS_RVALUE_REFERENCE_THIS 1
+#else
+#define LLVM_HAS_RVALUE_REFERENCE_THIS 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
@@ -41,8 +53,8 @@
/// Expands to '&' if r-value references are supported.
///
/// This can be used to provide l-value/r-value overrides of member functions.
-/// The r-value override should be guarded by LLVM_USE_RVALUE_REFERENCES
-#if LLVM_USE_RVALUE_REFERENCES
+/// The r-value override should be guarded by LLVM_HAS_RVALUE_REFERENCE_THIS
+#if LLVM_HAS_RVALUE_REFERENCE_THIS
#define LLVM_LVALUE_FUNCTION &
#else
#define LLVM_LVALUE_FUNCTION