[PATCH] D104044: [clang-format] Fix the issue of no empty line after namespace

Darwin Xu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 11 09:54:40 PDT 2021


darwin added a comment.

In D104044#2813491 <https://reviews.llvm.org/D104044#2813491>, @MyDeveloperDay wrote:

> Devils advocate how is this any different from
>
>   class Foo {
>   
>   class Bar {} ;
>   }
>   
>   };
>
> This would become
>
>   class Foo {
>      class Bar {};
>   };
>
> i.e. its going to remove the extra lines, just asking so we can understand if the removal of the line is the error or the fact it doesn't remove the line in the first place?

It is different, the issue I mentioned is about the empty lines in namespace.

As for class, clang-format always removes the empty lines in class:

  darwin at Darwins-iMac temp % cat f.cpp 
  class Foo {
  
  class Bar {} ;
  
  };
  darwin at Darwins-iMac temp % clang-format f.cpp -style="{BasedOnStyle: google, BreakBeforeBraces: Custom, BraceWrapping: {AfterClass: true}}" 
  class Foo
  {
    class Bar
    {
    };
  };
  darwin at Darwins-iMac temp % clang-format f.cpp -style="{BasedOnStyle: google, BreakBeforeBraces: Custom, BraceWrapping: {AfterClass: false}}"
  class Foo {
    class Bar {};
  };

Except for when `KeepEmptyLinesAtTheStartOfBlocks` is true:

  darwin at Darwins-iMac temp % clang-format f.cpp -style="{BasedOnStyle: google, BreakBeforeBraces: Custom, BraceWrapping: {AfterClass: false}, KeepEmptyLinesAtTheStartOfBlocks: true}"
  class Foo {
  
    class Bar {};
  };


Repository:
  rZORG LLVM Github Zorg

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104044/new/

https://reviews.llvm.org/D104044



More information about the cfe-commits mailing list