X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2FTinyPtrVector.h;h=8f3925c9c55414b47dac1b7175d944ca949f50bb;hb=1cacae0f297b7330c4cd2b4f0a1f95ab2615bd65;hp=f9b7d559c39efa6e49af0ad2914ac778533b05a6;hpb=ac5802bca0285eee49c1c372846552823d819181;p=oota-llvm.git diff --git a/include/llvm/ADT/TinyPtrVector.h b/include/llvm/ADT/TinyPtrVector.h index f9b7d559c39..8f3925c9c55 100644 --- a/include/llvm/ADT/TinyPtrVector.h +++ b/include/llvm/ADT/TinyPtrVector.h @@ -120,6 +120,14 @@ public: return Val.template get()->front(); } + EltTy back() const { + assert(!empty() && "vector empty"); + if (EltTy V = Val.template dyn_cast()) + return V; + return Val.template get()->back(); + } + + void push_back(EltTy NewVal) { assert(NewVal != 0 && "Can't add a null value"); @@ -139,6 +147,15 @@ public: Val.template get()->push_back(NewVal); } + void pop_back() { + // If we have a single value, convert to empty. + if (Val.template is()) + Val = (EltTy)0; + else if (VecTy *Vec = Val.template get()) + Vec->pop_back(); + } + + void clear() { // If we have a single value, convert to empty. if (Val.template is()) {