[llvm-commits] [llvm] r135367 - /llvm/trunk/include/llvm/ADT/TinyPtrVector.h
Chris Lattner
sabre at nondot.org
Sun Jul 17 18:53:11 PDT 2011
Author: lattner
Date: Sun Jul 17 20:53:11 2011
New Revision: 135367
URL: http://llvm.org/viewvc/llvm-project?rev=135367&view=rev
Log:
add iteration support to TinyPtrVector for clang's use.
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=135367&r1=135366&r2=135367&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/TinyPtrVector.h (original)
+++ llvm/trunk/include/llvm/ADT/TinyPtrVector.h Sun Jul 17 20:53:11 2011
@@ -58,6 +58,28 @@
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>()) {
More information about the llvm-commits
mailing list