[llvm-commits] [llvm] r168993 - in /llvm/trunk/include/llvm: ADT/Optional.h Support/Compiler.h
Chandler Carruth
chandlerc at gmail.com
Fri Nov 30 03:04:18 PST 2012
Author: chandlerc
Date: Fri Nov 30 05:04:18 2012
New Revision: 168993
URL: http://llvm.org/viewvc/llvm-project?rev=168993&view=rev
Log:
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.
Modified:
llvm/trunk/include/llvm/ADT/Optional.h
llvm/trunk/include/llvm/Support/Compiler.h
Modified: llvm/trunk/include/llvm/ADT/Optional.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Optional.h?rev=168993&r1=168992&r2=168993&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Optional.h (original)
+++ llvm/trunk/include/llvm/ADT/Optional.h Fri Nov 30 05:04:18 2012
@@ -55,7 +55,7 @@
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
Modified: llvm/trunk/include/llvm/Support/Compiler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compiler.h?rev=168993&r1=168992&r2=168993&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compiler.h (original)
+++ llvm/trunk/include/llvm/Support/Compiler.h Fri Nov 30 05:04:18 2012
@@ -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
More information about the llvm-commits
mailing list