[llvm-commits] [PATCH 03/20] [AVX] Remove non-const Iterators

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Jul 20 08:32:23 PDT 2011


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?

/jakob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110720/f26786af/attachment.html>


More information about the llvm-commits mailing list