[PATCH] [clang-extra-tools] [clang-format]

Daniel Jasper djasper at google.com
Fri Aug 2 15:18:51 PDT 2013


Thanks for working on this.

A couple of thoughts:
* How is the new test in FormatsWithWebKitStyle related?
* Either collapse both parameters into a single parameter or add test cases
for all combinations.
* The parameters themselves have tests (ParsesConfiguration).

+    case tok::semi:
> +      Contexts.back().CanBeInInheritanceList = false;
> +      break;


Is this necessary? Can you create a test that breaks without it?

     case tok::l_brace:
> +      Contexts.back().CanBeInInheritanceList = false;
>        if (!parseBrace())


Is this necessary? Can you create a test that breaks without it?

+        //} else if (Contexts.size() == 1) {
> +        // FIXME: annotates switch-case colon as inheritance colon
> +        // FIXME: annotates access specifiers as inheritance colon
> +        // Tok->Type = TT_OtherColon;


Is this intentional?

       else if (Previous.Type == TT_InheritanceColon)

-        State.Stack.back().Indent = State.Column;
> +        // We had a colon on a newline. Now, if we want to align commas
> to the
> +        // colon, we indent less by -2 == length(", ")

+        if (Style.BreakClassInheritanceListsBeforeComma)
> +          State.Stack.back().Indent = State.Column - 2;
> +        else
> +          State.Stack.back().Indent = State.Column;


Remove this completely.

+    if (Current.Type == TT_InheritanceColon) {
>        State.Stack.back().AvoidBinPacking = true;
> +      if (!Style.BreakClassInheritanceListsBeforeComma)
> +        State.Stack.back().Indent = State.Column + 2;
> +    }


Change this to

if (Current.Type == TT_InheritanceColon) {
  State.Stack.back().AvoidBinPacking = true;
  State.Stack.back().Indent = State.Column;
  if (!Style.BreakClassInheritanceListsBeforeComma)
    State.Stack.back().Indent += 2;
}

Cheers,
Daniel


On Fri, Aug 2, 2013 at 10:59 AM, Curdeius Curdeius <curdeius at gmail.com>wrote:

> Hi,
>
> I've added two options to clang-format:
> * BreakClassInheritanceListsBeforeColon
> and
> * BreakClassInheritanceListsBeforeComma.
>
> They allow us to break on class inheritance lists similarly to constructor
> initializer lists.
>
> I've corrected as well the TokenAnnotator, which mistakenly annotated
> colons from switch statements ("case:") and from access modifiers
> ("public:") as TT_InheritanceColon.
>
> The patch in the attachment.
>
> Cheers,
> Marek Kurdej
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130802/d75d3605/attachment.html>


More information about the cfe-commits mailing list