[llvm] r205437 - [C++11, ARM64] Range based for loops in address type promotion.

David Blaikie dblaikie at gmail.com
Wed Apr 2 11:25:39 PDT 2014


On Wed, Apr 2, 2014 at 11:18 AM, Tim Northover <t.p.northover at gmail.com> wrote:
> Hi Jim,
>
>> +    for (auto Inst : Insts) {
>
> Not really a comment on this patch specifically, but how we do C++11
> in general. When I saw this I was worried that you'd just created a
> copy of a MachineInstr and should have taken it by reference.
>
> Might it be better to use the actual type if the for header will still
> fit on one line?

Something like this came up in previous threads - the minimum
requested here is that if it's a pointer (I'm assuming it is) we
should use "auto *" to indicate that. So for loops would generally be
"auto &" or "auto *" and rarely unadorned "auto".

If these are sufficiently commonly used types that it's obvious what
they are, I'm OK with the use of auto (but this isn't my code, etc).
That's a judgement call that I don't have the context for here.

> Even ignoring the auto thing, I tend to think a long loop header has
> more "authority" in delineating significant blocks of code. Though
> perhaps that's just me being used to C++03 loops.

Yep - hopefully we'll become more used to the terse headers with time.
If this encourages us to pull loop bodies into separate functions to
make the loop body similarly terse/small so the headers aren't lost in
the noise, I'm OK with that.



More information about the llvm-commits mailing list