[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 02:30:50 PDT 2021


darwin added a comment.

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

> Just so I'm clear are you proposing that a newlines should always be added or that single blank lines should be ignored? I can't tell if the bug is that the line isn't being removed or sometimes not being added, either way there will be someone who wants it the other way around correct?

If there is no linefeed at all, or there is only one line feed. The clang-format works fine.

The issue is, if there are empty lines between the line of namespace and the first line of statement, those empty lines will be removed.

For example, I want to to have code like this:

  01 namespace MyLibrary
  02 {
  03
  04 class Tool
  05 {
  06 };
  07 
  08 }

There is an empty line 03.

If I format this with clang-format, I will got this:

  01 namespace MyLibrary
  02 {
  03 class Tool
  04 {
  05 };
  06 
  07 }

The empty line between line 02 and line 03 is removed. This asymmetry is very annoying.


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