aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ADT/TinyPtrVector.h
diff options
context:
space:
mode:
authorShih-wei Liao <sliao@google.com>2012-08-03 00:11:18 -0700
committerShih-wei Liao <sliao@google.com>2012-08-03 00:11:18 -0700
commit7744acd1ab73b3eec6f1449f47083abe3fb1b527 (patch)
tree17ef28b6d1034fdea7f42a19bebe7ad834901d62 /include/llvm/ADT/TinyPtrVector.h
parent4a05ed708aed4c7a099d924ed3feb604d3e44074 (diff)
parenta94d6e87c4c49f2e81b01d66d8bfb591277f8f96 (diff)
downloadexternal_llvm-7744acd1ab73b3eec6f1449f47083abe3fb1b527.zip
external_llvm-7744acd1ab73b3eec6f1449f47083abe3fb1b527.tar.gz
external_llvm-7744acd1ab73b3eec6f1449f47083abe3fb1b527.tar.bz2
Merge with LLVM upstream r160668 (Jul 24th 2012)
Conflicts: include/llvm/Support/ELF.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/Support/Memory.cpp lib/Transforms/Instrumentation/AddressSanitizer.cpp Change-Id: Iddd658cf2eadc7165b2805b446d31af2c5c9917f
Diffstat (limited to 'include/llvm/ADT/TinyPtrVector.h')
-rw-r--r--include/llvm/ADT/TinyPtrVector.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/llvm/ADT/TinyPtrVector.h b/include/llvm/ADT/TinyPtrVector.h
index 5014517..8f3925c 100644
--- a/include/llvm/ADT/TinyPtrVector.h
+++ b/include/llvm/ADT/TinyPtrVector.h
@@ -10,8 +10,10 @@
#ifndef LLVM_ADT_TINYPTRVECTOR_H
#define LLVM_ADT_TINYPTRVECTOR_H
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/PointerUnion.h"
+#include "llvm/Support/Compiler.h"
namespace llvm {
@@ -32,6 +34,11 @@ public:
if (VecTy *V = Val.template dyn_cast<VecTy*>())
Val = new VecTy(*V);
}
+#if LLVM_USE_RVALUE_REFERENCES
+ TinyPtrVector(TinyPtrVector &&RHS) : Val(RHS.Val) {
+ RHS.Val = (EltTy)0;
+ }
+#endif
~TinyPtrVector() {
if (VecTy *V = Val.template dyn_cast<VecTy*>())
delete V;
@@ -113,6 +120,14 @@ public:
return Val.template get<VecTy*>()->front();
}
+ EltTy back() const {
+ assert(!empty() && "vector empty");
+ if (EltTy V = Val.template dyn_cast<EltTy>())
+ return V;
+ return Val.template get<VecTy*>()->back();
+ }
+
+
void push_back(EltTy NewVal) {
assert(NewVal != 0 && "Can't add a null value");
@@ -132,6 +147,15 @@ public:
Val.template get<VecTy*>()->push_back(NewVal);
}
+ void pop_back() {
+ // If we have a single value, convert to empty.
+ if (Val.template is<EltTy>())
+ Val = (EltTy)0;
+ else if (VecTy *Vec = Val.template get<VecTy*>())
+ Vec->pop_back();
+ }
+
+
void clear() {
// If we have a single value, convert to empty.
if (Val.template is<EltTy>()) {
@@ -159,6 +183,9 @@ public:
private:
void operator=(const TinyPtrVector&); // NOT IMPLEMENTED YET.
+#if LLVM_USE_RVALUE_REFERENCES
+ void operator=(TinyPtrVector&&); // NOT IMPLEMENTED YET.
+#endif
};
} // end namespace llvm