r189353 - clang-format: Format segments of builder-type calls one per line.

Tobias Grosser tobias at grosser.es
Thu Sep 5 16:20:12 PDT 2013


On 08/27/2013 07:24 AM, Daniel Jasper wrote:
> Author: djasper
> Date: Tue Aug 27 09:24:43 2013
> New Revision: 189353
>
> URL: http://llvm.org/viewvc/llvm-project?rev=189353&view=rev
> Log:
> clang-format: Format segments of builder-type calls one per line.
>
> This fixes llvm.org/PR14818.
>
> Before:
>    return llvm::StringSwitch<Reference::Kind>(name)
>               .StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
>               .StartsWith(".eh_frame", ORDER_EH_FRAME)
>               .StartsWith(".init", ORDER_INIT).StartsWith(".fini", ORDER_FINI)
>               .StartsWith(".hash", ORDER_HASH).Default(ORDER_TEXT);
>
> After:
>    return llvm::StringSwitch<Reference::Kind>(name)
>               .StartsWith(".eh_frame_hdr", ORDER_EH_FRAMEHDR)
>               .StartsWith(".eh_frame", ORDER_EH_FRAME)
>               .StartsWith(".init", ORDER_INIT)
>               .StartsWith(".fini", ORDER_FINI)
>               .StartsWith(".hash", ORDER_HASH)
>               .Default(ORDER_TEXT);

This change introduced the following regression:

Before:

int foo() {
   if (1)
     if (1)
       if (1)
         O.indent(2 * (depth + 1))
             << "Node"
             << static_cast<void *>(RI->getTopLevelRegion()->getBBNode(*BI))
             << ";\n";
}

After:

int foo() {
   if (1)
     if (1)
       if (1)
         O.indent(2 * (depth + 1)) << "Node"
                                   << static_cast<void 
*>(RI->getTopLevelRegion()

->getBBNode(*BI))
                                   << ";\n";
}

I believe moving the << to a new line is better to read than adding a 
line break before the call to ->getBBNode().

Cheers,
Tobias



More information about the cfe-commits mailing list