add iteration support to TinyPtrVector for clang's use.

llvm-svn: 135367
This commit is contained in:
Chris Lattner 2011-07-18 01:53:11 +00:00
parent 7b70bef7c8
commit 8e8d674d79
1 changed files with 22 additions and 0 deletions

View File

@ -58,6 +58,28 @@ public:
return Val. template get<VecTy*>()->size();
}
typedef const EltTy *iterator;
iterator begin() const {
if (empty())
return 0;
if (Val.template is<EltTy>())
return Val.template getAddrOf<EltTy>();
return Val.template get<VecTy *>()->begin();
}
iterator end() const {
if (empty())
return 0;
if (Val.template is<EltTy>())
return begin() + 1;
return Val.template get<VecTy *>()->end();
}
EltTy operator[](unsigned i) const {
assert(!Val.isNull() && "can't index into an empty vector");
if (EltTy V = Val.template dyn_cast<EltTy>()) {