[AVX] Remove non-const Iterators

Remove all non-const iterators from Init classes.  This is another
step toward constifying Inits and ultimately turning them into
FoldingSetNodes.

llvm-svn: 136484
This commit is contained in:
David Greene 2011-07-29 19:07:02 +00:00
parent b3da8123c0
commit cdd64328c7
3 changed files with 13 additions and 14 deletions

View File

@ -27,7 +27,9 @@ getValueAsListOfStrings(Record &R, StringRef FieldName) {
std::vector<StringRef> Strings;
Strings.reserve(List->getSize());
for (ListInit::iterator i = List->begin(), e = List->end(); i != e; ++i) {
for (ListInit::const_iterator i = List->begin(), e = List->end();
i != e;
++i) {
assert(*i && "Got a null element in a ListInit");
if (StringInit *S = dynamic_cast<StringInit *>(*i))
Strings.push_back(S->getValue());

View File

@ -673,7 +673,13 @@ Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) {
assert(0 && "Empty list in cdr");
return 0;
}
ListInit *Result = new ListInit(LHSl->begin()+1, LHSl->end(),
ListInit::const_iterator begin = LHSl->begin()+1;
ListInit::const_iterator end = LHSl->end();
// We can't pass these iterators directly to ArrayRef because
// they are not convertible to Init **. Fortunately,
// RandomAccessIterator::operator * is guaranteed to return an
// lvalue.
ListInit *Result = new ListInit(ArrayRef<Init *>(&*begin, end - begin),
LHSl->getType());
return Result;
}
@ -920,7 +926,7 @@ static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type,
std::vector<Init *> NewOperands;
std::vector<Init *> NewList(MHSl->begin(), MHSl->end());
for (ListInit::iterator li = NewList.begin(),
for (std::vector<Init *>::iterator li = NewList.begin(),
liend = NewList.end();
li != liend;
++li) {

View File

@ -749,15 +749,14 @@ public:
class ListInit : public TypedInit {
std::vector<Init*> Values;
public:
typedef std::vector<Init*>::iterator iterator;
typedef std::vector<Init*>::const_iterator const_iterator;
explicit ListInit(std::vector<Init*> &Vs, RecTy *EltTy)
: TypedInit(ListRecTy::get(EltTy)) {
Values.swap(Vs);
}
explicit ListInit(iterator Start, iterator End, RecTy *EltTy)
: TypedInit(ListRecTy::get(EltTy)), Values(Start, End) {}
explicit ListInit(ArrayRef<Init *> Range, RecTy *EltTy)
: TypedInit(ListRecTy::get(EltTy)), Values(Range.begin(), Range.end()) {}
unsigned getSize() const { return Values.size(); }
Init *getElement(unsigned i) const {
@ -784,9 +783,7 @@ public:
ArrayRef<Init*> getValues() const { return Values; }
inline iterator begin() { return Values.begin(); }
inline const_iterator begin() const { return Values.begin(); }
inline iterator end () { return Values.end(); }
inline const_iterator end () const { return Values.end(); }
inline size_t size () const { return Values.size(); }
@ -1177,22 +1174,16 @@ public:
virtual std::string getAsString() const;
typedef std::vector<Init*>::iterator arg_iterator;
typedef std::vector<Init*>::const_iterator const_arg_iterator;
typedef std::vector<std::string>::iterator name_iterator;
typedef std::vector<std::string>::const_iterator const_name_iterator;
inline arg_iterator arg_begin() { return Args.begin(); }
inline const_arg_iterator arg_begin() const { return Args.begin(); }
inline arg_iterator arg_end () { return Args.end(); }
inline const_arg_iterator arg_end () const { return Args.end(); }
inline size_t arg_size () const { return Args.size(); }
inline bool arg_empty() const { return Args.empty(); }
inline name_iterator name_begin() { return ArgNames.begin(); }
inline const_name_iterator name_begin() const { return ArgNames.begin(); }
inline name_iterator name_end () { return ArgNames.end(); }
inline const_name_iterator name_end () const { return ArgNames.end(); }
inline size_t name_size () const { return ArgNames.size(); }