[patch] Ignore KeepEmptyLinesAtTheStartOfBlocks for extern "C" blocks

Daniel Jasper djasper at google.com
Wed Nov 12 13:46:05 PST 2014


Grml... Really prefer reviews on phabricator ...

>+    } else if (Limit != 0 && Line.First->isNot(tok::kw_namespace) &&
>+               (Line.First->isNot(tok::kw_extern) ||
>+                (Line.First->Next &&
!Line.First->Next->isStringLiteral()))) {

Isn't this doing something entirely different, namely not contracting such
declaration to a single line. I'd be fine with that, but it should be
called out explicitly.. And fixes part of llvm.org/PR21419.

Also, this would prevent:

  extern "C" int f() { return 42; }

Right? Probably not what we want.

>+        PreviousLine->First->isNot(tok::kw_namespace) &&
>+        PreviousLine->First->isNot(tok::kw_extern))

!PreviousLine->First->isOneOf(tok::kw_namespace, tok::kw_extern)

Also, this prevents removing the empty line in

  extern "C" int f() {

    int i = 42;
    return i;
  }

Also not what we want, I guess.

On Wed, Nov 12, 2014 at 10:34 PM, Nico Weber <thakis at chromium.org> wrote:

> Hi,
>
> KeepEmptyLinesAtTheStartOfBlocks is ignored for namespace blocks. extern
> "C" blocks are similar to namespaces, so it should be ignored there too.
> (Requested here: http://crbug.com/432640)
>
> The attached patch implements this.
>
> Nico
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141112/74456a39/attachment.html>


More information about the cfe-commits mailing list