diff options
author | Chris Lattner <sabre@nondot.org> | 2011-07-18 01:53:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-07-18 01:53:11 +0000 |
commit | 79976a40728c8baa8cd16de90173fe2c48937e22 (patch) | |
tree | e48d444a9119087a1cbd3d99a42ae844ea4d86c8 | |
parent | 840635741f132a9a10f052cbf3b21e14bc74835a (diff) |
add iteration support to TinyPtrVector for clang's use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135367 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/TinyPtrVector.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/llvm/ADT/TinyPtrVector.h b/include/llvm/ADT/TinyPtrVector.h index 8fbd6f61e2..8fcd2f33f5 100644 --- a/include/llvm/ADT/TinyPtrVector.h +++ b/include/llvm/ADT/TinyPtrVector.h @@ -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>()) { |