10 #ifndef LLVM_ADT_TINYPTRVECTOR_H
11 #define LLVM_ADT_TINYPTRVECTOR_H
27 template <
typename EltTy>
37 if (
VecTy *V =
Val.template dyn_cast<VecTy*>())
42 if (
VecTy *V =
Val.template dyn_cast<VecTy*>())
55 if (
Val.template is<EltTy>()) {
64 if (RHS.
Val.template is<EltTy>()) {
68 *
Val.template get<VecTy*>() = *RHS.
Val.template get<VecTy*>();
73 #if LLVM_HAS_RVALUE_REFERENCES
88 if (
VecTy *V =
Val.template dyn_cast<VecTy*>()) {
89 if (RHS.Val.template is<EltTy>()) {
91 V->push_back(RHS.front());
107 if (
Val.template is<EltTy>())
108 return *
Val.getAddrOfPtr1();
109 return *
Val.template get<VecTy*>();
115 if (
Val.isNull())
return true;
116 if (
VecTy *Vec =
Val.template dyn_cast<VecTy*>())
124 if (
Val.template is<EltTy>())
126 return Val.template get<VecTy*>()->
size();
133 if (
Val.template is<EltTy>())
134 return Val.getAddrOfPtr1();
136 return Val.template get<VecTy *>()->
begin();
140 if (
Val.template is<EltTy>())
141 return begin() + (
Val.isNull() ? 0 : 1);
143 return Val.template get<VecTy *>()->
end();
155 assert(!
Val.isNull() &&
"can't index into an empty vector");
156 if (EltTy V =
Val.template dyn_cast<EltTy>()) {
157 assert(i == 0 &&
"tinyvector index out of range");
161 assert(i <
Val.template get<VecTy*>()->size() &&
162 "tinyvector index out of range");
163 return (*
Val.template get<VecTy*>())[i];
167 assert(!
empty() &&
"vector empty");
168 if (EltTy V =
Val.template dyn_cast<EltTy>())
170 return Val.template get<VecTy*>()->
front();
174 assert(!
empty() &&
"vector empty");
175 if (EltTy V =
Val.template dyn_cast<EltTy>())
177 return Val.template get<VecTy*>()->
back();
181 assert(NewVal != 0 &&
"Can't add a null value");
190 if (EltTy V =
Val.template dyn_cast<EltTy>()) {
201 if (
Val.template is<EltTy>())
203 else if (
VecTy *Vec =
Val.template get<VecTy*>())
209 if (
Val.template is<EltTy>()) {
211 }
else if (
VecTy *Vec =
Val.template dyn_cast<VecTy*>()) {
219 assert(I >=
begin() &&
"Iterator to erase is out of bounds.");
220 assert(I <
end() &&
"Erasing at past-the-end iterator.");
223 if (
Val.template is<EltTy>()) {
226 }
else if (
VecTy *Vec =
Val.template dyn_cast<VecTy*>()) {
229 return Vec->erase(I);
235 assert(S >=
begin() &&
"Range to erase is out of bounds.");
236 assert(S <= E &&
"Trying to erase invalid range.");
237 assert(E <=
end() &&
"Trying to erase past the end.");
239 if (
Val.template is<EltTy>()) {
240 if (S ==
begin() && S != E)
242 }
else if (
VecTy *Vec =
Val.template dyn_cast<VecTy*>()) {
243 return Vec->erase(S, E);
249 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
250 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
255 assert(!
Val.isNull() &&
"Null value with non-end insert iterator.");
256 if (EltTy V =
Val.template dyn_cast<EltTy>()) {
257 assert(I ==
begin());
263 return Val.template get<VecTy*>()->
insert(I, Elt);
266 template<
typename ItTy>
268 assert(I >= this->
begin() &&
"Insertion iterator is out of bounds.");
269 assert(I <= this->
end() &&
"Inserting past the end of the vector.");
274 ptrdiff_t Offset = I -
begin();
282 }
else if (EltTy V =
Val.template dyn_cast<EltTy>()) {
286 return Val.template get<VecTy*>()->
insert(
begin() + Offset, From, To);
const_iterator end() const
TinyPtrVector(const TinyPtrVector &RHS)
llvm::PointerUnion< EltTy, VecTy * > Val
const EltTy * const_iterator
iterator erase(iterator I)
EltTy operator[](unsigned i) const
TinyPtrVector & operator=(const TinyPtrVector &RHS)
iterator insert(iterator I, const EltTy &Elt)
void push_back(EltTy NewVal)
ItTy next(ItTy it, Dist n)
llvm::SmallVector< EltTy, 4 > VecTy
const_iterator begin() const
ItTy prior(ItTy it, Dist n)
iterator erase(iterator S, iterator E)
VecTy::value_type value_type
iterator insert(iterator I, ItTy From, ItTy To)