[llvm-commits] [PATCH 03/20] [AVX] Remove non-const Iterators
David A. Greene
dag at cray.com
Wed Jul 20 09:02:31 PDT 2011
Jakob Stoklund Olesen <stoklund at 2pi.dk> writes:
> On Jul 19, 2011, at 1:11 PM, David Greene wrote:
>
> - 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());
>
> That comment is really scary. ArrayRef requires elements to be laid out continuously in memory. A random access iterator doesn't guarantee that.
> Think std::deque.
>
> How about adding a ListInit method that returns an ArrayRef instead?
Makes sense. Thanks!
-Dave
More information about the llvm-commits
mailing list