add some helper methods to make the type more uniform.
authorChris Lattner <sabre@nondot.org>
Mon, 28 May 2012 01:29:59 +0000 (01:29 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 28 May 2012 01:29:59 +0000 (01:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157554 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/TinyPtrVector.h

index f9b7d559c39efa6e49af0ad2914ac778533b05a6..8f3925c9c55414b47dac1b7175d944ca949f50bb 100644 (file)
@@ -120,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");
     
@@ -139,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>()) {