X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2FSmallVector.h;h=2a5168c261fb4b96b8b8e4dfa4a9838deeb35294;hb=26abef7b5a3f239204a1ad605a88b99a1ef878c3;hp=6ea8de511da9517cb9f0899260040cfb0981e6c0;hpb=617330909f0c26a3f2ab8601a029b9bdca48aa61;p=oota-llvm.git diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 6ea8de511da..2a5168c261f 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -53,7 +53,7 @@ public: return size_t((char*)CapacityX - (char*)BeginX); } - bool empty() const { return BeginX == EndX; } + bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { return BeginX == EndX; } }; template struct SmallVectorStorage; @@ -183,13 +183,9 @@ protected: /// std::move, but not all stdlibs actually provide that. template 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 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 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(); @@ -268,8 +254,8 @@ template void SmallVectorTemplateBase::grow(size_t MinSize) { size_t CurCapacity = this->capacity(); size_t CurSize = this->size(); - // Always grow, even from zero. - size_t NewCapacity = NextPowerOf2(2*CurCapacity+(CurCapacity==0)); + // Always grow, even from zero. + size_t NewCapacity = size_t(NextPowerOf2(CurCapacity+2)); if (NewCapacity < MinSize) NewCapacity = MinSize; T *NewElts = static_cast(malloc(NewCapacity*sizeof(T))); @@ -427,12 +413,8 @@ public: this->grow(N); } - T pop_back_val() { -#if LLVM_HAS_RVALUE_REFERENCES + T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val() { 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 &SmallVectorImpl:: return *this; } -#if LLVM_HAS_RVALUE_REFERENCES template SmallVectorImpl &SmallVectorImpl::operator=(SmallVectorImpl &&RHS) { // Avoid self-assignment. @@ -855,7 +832,6 @@ SmallVectorImpl &SmallVectorImpl::operator=(SmallVectorImpl &&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(N) { if (!RHS.empty()) SmallVectorImpl::operator=(::std::move(RHS)); @@ -914,8 +889,6 @@ public: SmallVectorImpl::operator=(::std::move(RHS)); return *this; } -#endif - }; template