summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/TinyPtrVector.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-18 01:53:11 +0000
committerChris Lattner <sabre@nondot.org>2011-07-18 01:53:11 +0000
commit79976a40728c8baa8cd16de90173fe2c48937e22 (patch)
treee48d444a9119087a1cbd3d99a42ae844ea4d86c8 /include/llvm/ADT/TinyPtrVector.h
parent840635741f132a9a10f052cbf3b21e14bc74835a (diff)
downloadllvm-79976a40728c8baa8cd16de90173fe2c48937e22.tar.gz
llvm-79976a40728c8baa8cd16de90173fe2c48937e22.tar.bz2
llvm-79976a40728c8baa8cd16de90173fe2c48937e22.tar.xz
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
Diffstat (limited to 'include/llvm/ADT/TinyPtrVector.h')
-rw-r--r--include/llvm/ADT/TinyPtrVector.h22
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>()) {