[PATCH] D132256: [clang-format] Add DefinitionBlockSpacing option

Alecto Irene Perez via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 19 11:24:03 PDT 2022


alecto created this revision.
alecto added reviewers: Richard, smith.
Herald added a project: All.
alecto requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/57180

Given configuration:

  SeparateDefinitionBlocks: Always
  DefinitionBlockSpacing: 2

Two spaces will be inserted between definition blocks. Code before
formatting:

  /// f is a function
  void f() {
      // Some code
      // More code
      return;
  }
  /// g is another function
  void g() {
      // Some other code
  }

Versus code after formatting:

  /// f is a function
  void f() {
      // Some code
      // More code
      return;
  }
  ​
  ​
  /// g is another function
  void g() {
      // Some other code
  }

Note: two zero width spaces were inserted into the commit message in
order to prevent git from removing the additional lines inside the
commit. These will not appear in formatted code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132256

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/DefinitionBlockSeparator.cpp
  clang/lib/Format/Format.cpp
  clang/unittests/Format/DefinitionBlockSeparatorTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132256.454070.patch
Type: text/x-patch
Size: 5738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220819/36b65e78/attachment.bin>


More information about the cfe-commits mailing list