From 79976a40728c8baa8cd16de90173fe2c48937e22 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 18 Jul 2011 01:53:11 +0000 Subject: [PATCH] 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 --- include/llvm/ADT/TinyPtrVector.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/llvm/ADT/TinyPtrVector.h b/include/llvm/ADT/TinyPtrVector.h index 8fbd6f61e27..8fcd2f33f52 100644 --- a/include/llvm/ADT/TinyPtrVector.h +++ b/include/llvm/ADT/TinyPtrVector.h @@ -58,6 +58,28 @@ public: return Val. template get()->size(); } + typedef const EltTy *iterator; + iterator begin() const { + if (empty()) + return 0; + + if (Val.template is()) + return Val.template getAddrOf(); + + return Val.template get()->begin(); + + } + iterator end() const { + if (empty()) + return 0; + + if (Val.template is()) + return begin() + 1; + + return Val.template get()->end(); + } + + EltTy operator[](unsigned i) const { assert(!Val.isNull() && "can't index into an empty vector"); if (EltTy V = Val.template dyn_cast()) {