[PATCH] Formatter: Correctly format stars in `sizeof(int**)` and similar places.

Manuel Klimek klimek at google.com
Mon Feb 11 09:28:53 PST 2013


On Mon, Feb 11, 2013 at 6:11 PM, Nico Weber <thakis at chromium.org> wrote:

>
>
> ================
> Comment at: lib/Format/TokenAnnotator.cpp:541
> @@ -540,1 +540,3 @@
> +    } else if (Current.is(tok::kw_return) || Current.is(tok::kw_throw) ||
>          (Current.is(tok::l_paren) && !Line.MustBeDeclaration &&
> +         (Current.Parent == NULL || Current.Parent->isNot(tok::kw_for))))
> {
> ----------------
> Manuel Klimek wrote:
> > Indent.
> Done.
>
> ================
> Comment at: lib/Format/TokenAnnotator.cpp:532
> @@ -529,3 +531,3 @@
>        Contexts.back().IsExpression = true;
> -      AnnotatedToken *Previous = Current.Parent;
> -      while (Previous != NULL && Previous->isNot(tok::comma)) {
> +      for (AnnotatedToken *Previous = Current.Parent;
> +           Previous && Previous->isNot(tok::comma);
> ----------------
> Manuel Klimek wrote:
> > Just out of curiosity: why do you prefer a for loop here?
> Loops of the form
>
>   init;
>   while(condition) {
>     // ...
>     update;
>   }
>   // no use of loop variable after loop
>
> read nicer as for loops for me, and Previous is slightly tighter scoped
> this way. But I can change it back if you like the old form better.
>

I don't care that much - I personally prefer while loops when it doesn't
completely fit the "you have a fixed length list" idom, which in this case
is arguable - but, as I said, no biggie - was mainly curious.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130211/14fa07c7/attachment.html>


More information about the cfe-commits mailing list