initSlowCase(that);
}
-#if LLVM_HAS_RVALUE_REFERENCES
/// \brief Move Constructor.
APInt(APInt &&that) : BitWidth(that.BitWidth), VAL(that.VAL) {
that.BitWidth = 0;
}
-#endif
/// \brief Destructor.
~APInt() {
return AssignSlowCase(RHS);
}
-#if LLVM_HAS_RVALUE_REFERENCES
/// @brief Move assignment operator.
APInt &operator=(APInt &&that) {
if (!isSingleWord())
return *this;
}
-#endif
/// \brief Assignment operator.
///
std::memcpy(Bits, RHS.Bits, Capacity * sizeof(BitWord));
}
-#if LLVM_HAS_RVALUE_REFERENCES
BitVector(BitVector &&RHS)
: Bits(RHS.Bits), Size(RHS.Size), Capacity(RHS.Capacity) {
RHS.Bits = 0;
}
-#endif
~BitVector() {
std::free(Bits);
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
const BitVector &operator=(BitVector &&RHS) {
if (this == &RHS) return *this;
return *this;
}
-#endif
void swap(BitVector &RHS) {
std::swap(Bits, RHS.Bits);
return std::make_pair(iterator(TheBucket, getBucketsEnd(), true), true);
}
-#if LLVM_HAS_RVALUE_REFERENCES
// Inserts key,value pair into the map if the key isn't already in the map.
// If the key is already in the map, it returns false and doesn't update the
// value.
TheBucket);
return std::make_pair(iterator(TheBucket, getBucketsEnd(), true), true);
}
-#endif
-
+
/// insert - Range insertion of pairs.
template<typename InputIt>
void insert(InputIt I, InputIt E) {
return FindAndConstruct(Key).second;
}
-#if LLVM_HAS_RVALUE_REFERENCES
value_type& FindAndConstruct(KeyT &&Key) {
BucketT *TheBucket;
if (LookupBucketFor(Key, TheBucket))
ValueT &operator[](KeyT &&Key) {
return FindAndConstruct(std::move(Key)).second;
}
-#endif
/// isPointerIntoBucketsArray - Return true if the specified pointer points
/// somewhere into the DenseMap's array of buckets (i.e. either to a key or
return TheBucket;
}
-#if LLVM_HAS_RVALUE_REFERENCES
BucketT *InsertIntoBucket(const KeyT &Key, ValueT &&Value,
BucketT *TheBucket) {
TheBucket = InsertIntoBucketImpl(Key, TheBucket);
new (&TheBucket->second) ValueT(std::move(Value));
return TheBucket;
}
-#endif
BucketT *InsertIntoBucketImpl(const KeyT &Key, BucketT *TheBucket) {
// If the load of the hash table is more than 3/4, or if fewer than 1/8 of
copyFrom(other);
}
-#if LLVM_HAS_RVALUE_REFERENCES
DenseMap(DenseMap &&other) : BaseT() {
init(0);
swap(other);
}
-#endif
template<typename InputIt>
DenseMap(const InputIt &I, const InputIt &E) {
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
DenseMap& operator=(DenseMap &&other) {
this->destroyAll();
operator delete(Buckets);
swap(other);
return *this;
}
-#endif
void copyFrom(const DenseMap& other) {
this->destroyAll();
copyFrom(other);
}
-#if LLVM_HAS_RVALUE_REFERENCES
SmallDenseMap(SmallDenseMap &&other) : BaseT() {
init(0);
swap(other);
}
-#endif
template<typename InputIt>
SmallDenseMap(const InputIt &I, const InputIt &E) {
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
SmallDenseMap& operator=(SmallDenseMap &&other) {
this->destroyAll();
deallocateBuckets();
swap(other);
return *this;
}
-#endif
void copyFrom(const SmallDenseMap& other) {
this->destroyAll();
retain();
}
-#if LLVM_HAS_RVALUE_REFERENCES
IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.Obj) {
S.Obj = 0;
}
IntrusiveRefCntPtr(IntrusiveRefCntPtr<X>&& S) : Obj(S.getPtr()) {
S.Obj = 0;
}
-#endif
template <class X>
IntrusiveRefCntPtr(const IntrusiveRefCntPtr<X>& S)
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Compiler.h"
#include <cassert>
-
-#if LLVM_HAS_RVALUE_REFERENCES
#include <utility>
-#endif
namespace llvm {
new (storage.buffer) T(*O);
}
-#if LLVM_HAS_RVALUE_REFERENCES
Optional(T &&y) : hasVal(true) {
new (storage.buffer) T(std::forward<T>(y));
}
}
return *this;
}
-#endif
static inline Optional create(const T* y) {
return y ? Optional(*y) : Optional();
public:
explicit OwningPtr(T *P = 0) : Ptr(P) {}
-#if LLVM_HAS_RVALUE_REFERENCES
OwningPtr(OwningPtr &&Other) : Ptr(Other.take()) {}
OwningPtr &operator=(OwningPtr &&Other) {
reset(Other.take());
return *this;
}
-#endif
~OwningPtr() {
delete Ptr;
public:
explicit OwningArrayPtr(T *P = 0) : Ptr(P) {}
-#if LLVM_HAS_RVALUE_REFERENCES
OwningArrayPtr(OwningArrayPtr &&Other) : Ptr(Other.take()) {}
OwningArrayPtr &operator=(OwningArrayPtr &&Other) {
reset(Other.take());
return *this;
}
-#endif
~OwningArrayPtr() {
delete [] Ptr;
switchToLarge(new BitVector(*RHS.getPointer()));
}
-#if LLVM_HAS_RVALUE_REFERENCES
SmallBitVector(SmallBitVector &&RHS) : X(RHS.X) {
RHS.X = 1;
}
-#endif
~SmallBitVector() {
if (!isSmall())
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
const SmallBitVector &operator=(SmallBitVector &&RHS) {
if (this != &RHS) {
clear();
}
return *this;
}
-#endif
void swap(SmallBitVector &RHS) {
std::swap(X, RHS.X);
// Helpers to copy and move construct a SmallPtrSet.
SmallPtrSetImplBase(const void **SmallStorage, const SmallPtrSetImplBase &that);
-#if LLVM_HAS_RVALUE_REFERENCES
SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize,
SmallPtrSetImplBase &&that);
-#endif
explicit SmallPtrSetImplBase(const void **SmallStorage, unsigned SmallSize) :
SmallArray(SmallStorage), CurArray(SmallStorage), CurArraySize(SmallSize) {
assert(SmallSize && (SmallSize & (SmallSize-1)) == 0 &&
void swap(SmallPtrSetImplBase &RHS);
void CopyFrom(const SmallPtrSetImplBase &RHS);
-#if LLVM_HAS_RVALUE_REFERENCES
void MoveFrom(unsigned SmallSize, SmallPtrSetImplBase &&RHS);
-#endif
};
/// SmallPtrSetIteratorImpl - This is the common base class shared between all
// Constructors that forward to the base.
SmallPtrSetImpl(const void **SmallStorage, const SmallPtrSetImpl &that)
: SmallPtrSetImplBase(SmallStorage, that) {}
-#if LLVM_HAS_RVALUE_REFERENCES
SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize,
SmallPtrSetImpl &&that)
: SmallPtrSetImplBase(SmallStorage, SmallSize, std::move(that)) {}
-#endif
explicit SmallPtrSetImpl(const void **SmallStorage, unsigned SmallSize)
: SmallPtrSetImplBase(SmallStorage, SmallSize) {}
public:
SmallPtrSet() : BaseT(SmallStorage, SmallSizePowTwo) {}
SmallPtrSet(const SmallPtrSet &that) : BaseT(SmallStorage, that) {}
-#if LLVM_HAS_RVALUE_REFERENCES
SmallPtrSet(SmallPtrSet &&that)
: BaseT(SmallStorage, SmallSizePowTwo, std::move(that)) {}
-#endif
template<typename It>
SmallPtrSet(It I, It E) : BaseT(SmallStorage, SmallSizePowTwo) {
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
SmallPtrSet<PtrType, SmallSize>&
operator=(SmallPtrSet<PtrType, SmallSize> &&RHS) {
if (&RHS != this)
this->MoveFrom(SmallSizePowTwo, std::move(RHS));
return *this;
}
-#endif
/// swap - Swaps the elements of two sets.
void swap(SmallPtrSet<PtrType, SmallSize> &RHS) {
/// std::move, but not all stdlibs actually provide that.
template<typename It1, typename It2>
static It2 move(It1 I, It1 E, It2 Dest) {
-#if LLVM_HAS_RVALUE_REFERENCES
for (; I != E; ++I, ++Dest)
*Dest = ::std::move(*I);
return Dest;
-#else
- return ::std::copy(I, E, Dest);
-#endif
}
/// move_backward - Use move-assignment to move the range
/// std::move_backward, but not all stdlibs actually provide that.
template<typename It1, typename It2>
static It2 move_backward(It1 I, It1 E, It2 Dest) {
-#if LLVM_HAS_RVALUE_REFERENCES
while (I != E)
*--Dest = ::std::move(*--E);
return Dest;
-#else
- return ::std::copy_backward(I, E, Dest);
-#endif
}
/// uninitialized_move - Move the range [I, E) into the uninitialized
/// memory starting with "Dest", constructing elements as needed.
template<typename It1, typename It2>
static void uninitialized_move(It1 I, It1 E, It2 Dest) {
-#if LLVM_HAS_RVALUE_REFERENCES
for (; I != E; ++I, ++Dest)
::new ((void*) &*Dest) T(::std::move(*I));
-#else
- ::std::uninitialized_copy(I, E, Dest);
-#endif
}
/// uninitialized_copy - Copy the range [I, E) onto the uninitialized
goto Retry;
}
-#if LLVM_HAS_RVALUE_REFERENCES
void push_back(T &&Elt) {
if (this->EndX < this->CapacityX) {
Retry:
this->grow();
goto Retry;
}
-#endif
-
+
void pop_back() {
this->setEnd(this->end()-1);
this->end()->~T();
}
T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val() {
-#if LLVM_HAS_RVALUE_REFERENCES
T Result = ::std::move(this->back());
-#else
- T Result = this->back();
-#endif
this->pop_back();
return Result;
}
return(N);
}
-#if LLVM_HAS_RVALUE_REFERENCES
iterator insert(iterator I, T &&Elt) {
if (I == this->end()) { // Important special case for empty vector.
this->push_back(::std::move(Elt));
I = this->begin()+EltNo;
goto Retry;
}
-#endif
iterator insert(iterator I, const T &Elt) {
if (I == this->end()) { // Important special case for empty vector.
SmallVectorImpl &operator=(const SmallVectorImpl &RHS);
-#if LLVM_HAS_RVALUE_REFERENCES
SmallVectorImpl &operator=(SmallVectorImpl &&RHS);
-#endif
bool operator==(const SmallVectorImpl &RHS) const {
if (this->size() != RHS.size()) return false;
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
template <typename T>
SmallVectorImpl<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&RHS) {
// Avoid self-assignment.
RHS.clear();
return *this;
}
-#endif
/// Storage for the SmallVector elements which aren't contained in
/// SmallVectorTemplateCommon. There are 'N-1' elements here. The remaining '1'
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
SmallVector(SmallVector &&RHS) : SmallVectorImpl<T>(N) {
if (!RHS.empty())
SmallVectorImpl<T>::operator=(::std::move(RHS));
SmallVectorImpl<T>::operator=(::std::move(RHS));
return *this;
}
-#endif
-
};
template<typename T, unsigned N>
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
TinyPtrVector(TinyPtrVector &&RHS) : Val(RHS.Val) {
RHS.Val = (EltTy)0;
}
RHS.Val = (EltTy)0;
return *this;
}
-#endif
// implicit conversion operator to ArrayRef.
operator ArrayRef<EltTy>() const {
public:
polymorphic_ptr(T *ptr = 0) : ptr(ptr) {}
polymorphic_ptr(const polymorphic_ptr &arg) : ptr(arg ? arg->clone() : 0) {}
-#if LLVM_HAS_RVALUE_REFERENCES
polymorphic_ptr(polymorphic_ptr &&arg) : ptr(arg.take()) {}
-#endif
~polymorphic_ptr() { delete ptr; }
polymorphic_ptr &operator=(polymorphic_ptr arg) {
# define LLVM_HAS_VARIADIC_TEMPLATES 0
#endif
-/// llvm_move - Expands to ::std::move if the compiler supports
-/// r-value references; otherwise, expands to the argument.
-#if LLVM_HAS_RVALUE_REFERENCES
+/// llvm_move - Expands to ::std::move. This is a hold-over from when we did
+/// not support R-value references.
#define llvm_move(value) (::std::move(value))
-#else
-#define llvm_move(value) (value)
-#endif
/// Expands to '&' if r-value references are supported.
///
class ConstantRange {
APInt Lower, Upper;
-#if LLVM_HAS_RVALUE_REFERENCES
// If we have move semantics, pass APInts by value and move them into place.
typedef APInt APIntMoveTy;
-#else
- // Otherwise pass by const ref to save one copy.
- typedef const APInt &APIntMoveTy;
-#endif
public:
/// Initialize a full (the default) or empty set for the specified bit width.
#endif
namespace llvm {
-#if LLVM_HAS_CXX11_TYPETRAITS && LLVM_HAS_RVALUE_REFERENCES
template<class T, class V>
typename std::enable_if< std::is_constructible<T, V>::value
, typename std::remove_reference<V>::type>::type &&
moveIfMoveConstructible(V &Val) {
return Val;
}
-#else
-template<class T, class V>
-V &moveIfMoveConstructible(V &Val) {
- return Val;
-}
-#endif
/// \brief Stores a reference that can be changed.
template <typename T>
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
ErrorOr(ErrorOr &&Other) {
moveConstruct(std::move(Other));
}
moveAssign(std::move(Other));
return *this;
}
-#endif
~ErrorOr() {
if (!HasError)
new (this) ErrorOr(Other);
}
-#if LLVM_HAS_RVALUE_REFERENCES
template <class OtherT>
void moveConstruct(ErrorOr<OtherT> &&Other) {
if (!Other.HasError) {
this->~ErrorOr();
new (this) ErrorOr(std::move(Other));
}
-#endif
pointer toPointer(pointer Val) {
return Val;
public:
typedef char char_type;
-#if LLVM_HAS_RVALUE_REFERENCES
mapped_file_region(mapped_file_region&&);
mapped_file_region &operator =(mapped_file_region&&);
-#endif
/// Construct a mapped_file_region at \a path starting at \a offset of length
/// \a length and with access \a mode.
std::swap(error, regex.error);
return *this;
}
-#if LLVM_HAS_RVALUE_REFERENCES
Regex(Regex &®ex) {
preg = regex.preg;
error = regex.error;
regex.preg = NULL;
}
-#endif
~Regex();
/// isValid - returns the error encountered during regex compilation, or
NumTombstones = that.NumTombstones;
}
-#if LLVM_HAS_RVALUE_REFERENCES
SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage,
unsigned SmallSize,
SmallPtrSetImplBase &&that) {
that.NumElements = 0;
that.NumTombstones = 0;
}
-#endif
/// CopyFrom - implement operator= from a smallptrset that has the same pointer
/// type, but may have a different small size.
NumTombstones = RHS.NumTombstones;
}
-#if LLVM_HAS_RVALUE_REFERENCES
void SmallPtrSetImplBase::MoveFrom(unsigned SmallSize,
SmallPtrSetImplBase &&RHS) {
assert(&RHS != this && "Self-move should be handled by the caller.");
RHS.NumElements = 0;
RHS.NumTombstones = 0;
}
-#endif
void SmallPtrSetImplBase::swap(SmallPtrSetImplBase &RHS) {
if (this == &RHS) return;
::munmap(Mapping, Size);
}
-#if LLVM_HAS_RVALUE_REFERENCES
mapped_file_region::mapped_file_region(mapped_file_region &&other)
: Mode(other.Mode), Size(other.Size), Mapping(other.Mapping) {
other.Mapping = 0;
}
-#endif
mapped_file_region::mapmode mapped_file_region::flags() const {
assert(Mapping && "Mapping failed but used anyway!");
::UnmapViewOfFile(Mapping);
}
-#if LLVM_HAS_RVALUE_REFERENCES
mapped_file_region::mapped_file_region(mapped_file_region &&other)
: Mode(other.Mode)
, Size(other.Size)
other.FileHandle = INVALID_HANDLE_VALUE;
other.FileDescriptor = 0;
}
-#endif
mapped_file_region::mapmode mapped_file_region::flags() const {
assert(Mapping && "Mapping failed but used anyway!");