[llvm-commits] [llvm] r157554 - /llvm/trunk/include/llvm/ADT/TinyPtrVector.h
Chris Lattner
sabre at nondot.org
Sun May 27 18:29:59 PDT 2012
Author: lattner
Date: Sun May 27 20:29:59 2012
New Revision: 157554
URL: http://llvm.org/viewvc/llvm-project?rev=157554&view=rev
Log:
add some helper methods to make the type more uniform.
Modified:
llvm/trunk/include/llvm/ADT/TinyPtrVector.h
Modified: llvm/trunk/include/llvm/ADT/TinyPtrVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/TinyPtrVector.h?rev=157554&r1=157553&r2=157554&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/TinyPtrVector.h (original)
+++ llvm/trunk/include/llvm/ADT/TinyPtrVector.h Sun May 27 20:29:59 2012
@@ -120,6 +120,14 @@
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 @@
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>()) {
More information about the llvm-commits
mailing list