[C++11] Remove the R-value reference #if usage from the ADT and Support

libraries. It is now always 1 in LLVM builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202580 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2014-03-01 09:27:28 +00:00
parent ef6cf47112
commit e56ffb951f
19 changed files with 4 additions and 114 deletions

View File

@ -284,12 +284,10 @@ public:
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() {
@ -656,7 +654,6 @@ public:
return AssignSlowCase(RHS);
}
#if LLVM_HAS_RVALUE_REFERENCES
/// @brief Move assignment operator.
APInt &operator=(APInt &&that) {
if (!isSingleWord())
@ -669,7 +666,6 @@ public:
return *this;
}
#endif
/// \brief Assignment operator.
///

View File

@ -98,12 +98,10 @@ public:
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);
@ -461,7 +459,6 @@ public:
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
const BitVector &operator=(BitVector &&RHS) {
if (this == &RHS) return *this;
@ -474,7 +471,6 @@ public:
return *this;
}
#endif
void swap(BitVector &RHS) {
std::swap(Bits, RHS.Bits);

View File

@ -161,7 +161,6 @@ public:
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.
@ -177,8 +176,7 @@ public:
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) {
@ -218,7 +216,6 @@ public:
return FindAndConstruct(Key).second;
}
#if LLVM_HAS_RVALUE_REFERENCES
value_type& FindAndConstruct(KeyT &&Key) {
BucketT *TheBucket;
if (LookupBucketFor(Key, TheBucket))
@ -230,7 +227,6 @@ public:
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
@ -403,7 +399,6 @@ private:
return TheBucket;
}
#if LLVM_HAS_RVALUE_REFERENCES
BucketT *InsertIntoBucket(const KeyT &Key, ValueT &&Value,
BucketT *TheBucket) {
TheBucket = InsertIntoBucketImpl(Key, TheBucket);
@ -420,7 +415,6 @@ private:
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
@ -555,12 +549,10 @@ public:
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) {
@ -585,7 +577,6 @@ public:
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
DenseMap& operator=(DenseMap &&other) {
this->destroyAll();
operator delete(Buckets);
@ -593,7 +584,6 @@ public:
swap(other);
return *this;
}
#endif
void copyFrom(const DenseMap& other) {
this->destroyAll();
@ -719,12 +709,10 @@ public:
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) {
@ -814,7 +802,6 @@ public:
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
SmallDenseMap& operator=(SmallDenseMap &&other) {
this->destroyAll();
deallocateBuckets();
@ -822,7 +809,6 @@ public:
swap(other);
return *this;
}
#endif
void copyFrom(const SmallDenseMap& other) {
this->destroyAll();

View File

@ -123,7 +123,6 @@ namespace llvm {
retain();
}
#if LLVM_HAS_RVALUE_REFERENCES
IntrusiveRefCntPtr(IntrusiveRefCntPtr&& S) : Obj(S.Obj) {
S.Obj = 0;
}
@ -132,7 +131,6 @@ namespace llvm {
IntrusiveRefCntPtr(IntrusiveRefCntPtr<X>&& S) : Obj(S.getPtr()) {
S.Obj = 0;
}
#endif
template <class X>
IntrusiveRefCntPtr(const IntrusiveRefCntPtr<X>& S)

View File

@ -20,10 +20,7 @@
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Compiler.h"
#include <cassert>
#if LLVM_HAS_RVALUE_REFERENCES
#include <utility>
#endif
namespace llvm {
@ -42,7 +39,6 @@ public:
new (storage.buffer) T(*O);
}
#if LLVM_HAS_RVALUE_REFERENCES
Optional(T &&y) : hasVal(true) {
new (storage.buffer) T(std::forward<T>(y));
}
@ -70,7 +66,6 @@ public:
}
return *this;
}
#endif
static inline Optional create(const T* y) {
return y ? Optional(*y) : Optional();

View File

@ -32,14 +32,12 @@ class OwningPtr {
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;
@ -96,14 +94,12 @@ class OwningArrayPtr {
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;

View File

@ -153,11 +153,9 @@ public:
switchToLarge(new BitVector(*RHS.getPointer()));
}
#if LLVM_HAS_RVALUE_REFERENCES
SmallBitVector(SmallBitVector &&RHS) : X(RHS.X) {
RHS.X = 1;
}
#endif
~SmallBitVector() {
if (!isSmall())
@ -506,7 +504,6 @@ public:
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
const SmallBitVector &operator=(SmallBitVector &&RHS) {
if (this != &RHS) {
clear();
@ -514,7 +511,6 @@ public:
}
return *this;
}
#endif
void swap(SmallBitVector &RHS) {
std::swap(X, RHS.X);

View File

@ -62,10 +62,8 @@ protected:
// 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 &&
@ -139,9 +137,7 @@ protected:
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
@ -247,11 +243,9 @@ protected:
// 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) {}
@ -304,10 +298,8 @@ class SmallPtrSet : public SmallPtrSetImpl<PtrType> {
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) {
@ -321,14 +313,12 @@ public:
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) {

View File

@ -183,13 +183,9 @@ protected:
/// 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
@ -198,25 +194,17 @@ protected:
/// 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
@ -244,7 +232,6 @@ public:
goto Retry;
}
#if LLVM_HAS_RVALUE_REFERENCES
void push_back(T &&Elt) {
if (this->EndX < this->CapacityX) {
Retry:
@ -255,8 +242,7 @@ public:
this->grow();
goto Retry;
}
#endif
void pop_back() {
this->setEnd(this->end()-1);
this->end()->~T();
@ -428,11 +414,7 @@ public:
}
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;
}
@ -501,7 +483,6 @@ public:
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));
@ -532,7 +513,6 @@ public:
I = this->begin()+EltNo;
goto Retry;
}
#endif
iterator insert(iterator I, const T &Elt) {
if (I == this->end()) { // Important special case for empty vector.
@ -673,9 +653,7 @@ public:
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;
@ -793,7 +771,6 @@ SmallVectorImpl<T> &SmallVectorImpl<T>::
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
template <typename T>
SmallVectorImpl<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&RHS) {
// Avoid self-assignment.
@ -855,7 +832,6 @@ SmallVectorImpl<T> &SmallVectorImpl<T>::operator=(SmallVectorImpl<T> &&RHS) {
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'
@ -904,7 +880,6 @@ public:
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
SmallVector(SmallVector &&RHS) : SmallVectorImpl<T>(N) {
if (!RHS.empty())
SmallVectorImpl<T>::operator=(::std::move(RHS));
@ -914,8 +889,6 @@ public:
SmallVectorImpl<T>::operator=(::std::move(RHS));
return *this;
}
#endif
};
template<typename T, unsigned N>

View File

@ -70,7 +70,6 @@ public:
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
TinyPtrVector(TinyPtrVector &&RHS) : Val(RHS.Val) {
RHS.Val = (EltTy)0;
}
@ -98,7 +97,6 @@ public:
RHS.Val = (EltTy)0;
return *this;
}
#endif
// implicit conversion operator to ArrayRef.
operator ArrayRef<EltTy>() const {

View File

@ -40,9 +40,7 @@ template <typename T> class polymorphic_ptr {
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) {

View File

@ -98,13 +98,9 @@
# 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.
///

View File

@ -42,13 +42,8 @@ namespace llvm {
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.

View File

@ -26,7 +26,6 @@
#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 &&
@ -40,12 +39,6 @@ typename std::enable_if< !std::is_constructible<T, V>::value
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>
@ -143,7 +136,6 @@ public:
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
ErrorOr(ErrorOr &&Other) {
moveConstruct(std::move(Other));
}
@ -163,7 +155,6 @@ public:
moveAssign(std::move(Other));
return *this;
}
#endif
~ErrorOr() {
if (!HasError)
@ -223,7 +214,6 @@ private:
new (this) ErrorOr(Other);
}
#if LLVM_HAS_RVALUE_REFERENCES
template <class OtherT>
void moveConstruct(ErrorOr<OtherT> &&Other) {
if (!Other.HasError) {
@ -245,7 +235,6 @@ private:
this->~ErrorOr();
new (this) ErrorOr(std::move(Other));
}
#endif
pointer toPointer(pointer Val) {
return Val;

View File

@ -664,10 +664,8 @@ private:
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.

View File

@ -52,13 +52,11 @@ namespace llvm {
std::swap(error, regex.error);
return *this;
}
#if LLVM_HAS_RVALUE_REFERENCES
Regex(Regex &&regex) {
preg = regex.preg;
error = regex.error;
regex.preg = NULL;
}
#endif
~Regex();
/// isValid - returns the error encountered during regex compilation, or

View File

@ -186,7 +186,6 @@ SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage,
NumTombstones = that.NumTombstones;
}
#if LLVM_HAS_RVALUE_REFERENCES
SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage,
unsigned SmallSize,
SmallPtrSetImplBase &&that) {
@ -214,7 +213,6 @@ SmallPtrSetImplBase::SmallPtrSetImplBase(const void **SmallStorage,
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.
@ -254,7 +252,6 @@ void SmallPtrSetImplBase::CopyFrom(const SmallPtrSetImplBase &RHS) {
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.");
@ -282,7 +279,6 @@ void SmallPtrSetImplBase::MoveFrom(unsigned SmallSize,
RHS.NumElements = 0;
RHS.NumTombstones = 0;
}
#endif
void SmallPtrSetImplBase::swap(SmallPtrSetImplBase &RHS) {
if (this == &RHS) return;

View File

@ -538,12 +538,10 @@ mapped_file_region::~mapped_file_region() {
::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!");

View File

@ -659,7 +659,6 @@ mapped_file_region::~mapped_file_region() {
::UnmapViewOfFile(Mapping);
}
#if LLVM_HAS_RVALUE_REFERENCES
mapped_file_region::mapped_file_region(mapped_file_region &&other)
: Mode(other.Mode)
, Size(other.Size)
@ -671,7 +670,6 @@ mapped_file_region::mapped_file_region(mapped_file_region &&other)
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!");