[llvm-dev] ilist/iplist are broken (maybe I'll fix them?)

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 20 21:24:08 PDT 2015


> On Oct 20, 2015, at 7:39 PM, Justin Bogner via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> "Duncan P. N. Exon Smith via llvm-dev" <llvm-dev at lists.llvm.org> writes:
>>> On 2015-Oct-20, at 11:23, Reid Kleckner <rnk at google.com> wrote:
>>> 
>>> I think the implicit iterator conversions are much less important
>>> now that we have range based for loops, but I still like having
>>> them.
>> 
>> IMO, if a developer has an ilist iterator and wants a pointer, they
>> should explicitly use `&*I` to make the assumption that "`I` isn't the
>> end iterator" explicit in the code.  Similarly, in the other direction,
>> `N->getIterator()` makes it clear that `N` is definitely not `nullptr`
>> and is therefore safe to compare to an iterator.
> 
> +1. The convenience of the implicit conversion isn't worthwhile here.
> While I'm not a huge fan of writing `&*I`, it's at least very obvious
> that you need to check that I's valid. OTOH, N->getIterator() is very
> clear (and is probably usually written as `auto I = N->getIterator()`,
> which looks pretty nice).

+1 for explicitness.

-Chris


More information about the llvm-dev mailing list