[PATCH] D116314: [Clangfmt] Add style to separate definition blocks

ksyx via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 27 18:32:17 PST 2021


ksyx updated this revision to Diff 396358.
ksyx marked an inline comment as done.
ksyx added a comment.

- Change bool type of the option to enum type
- Generate empty line for enum block

Testfile:

  // test.cpp
  #include <algorithm>
  #include <cstdio>
  #include <cstring>
  struct Foo {
    int a,b,c;
  };
  namespace Ns {
  class Bar {
  public:
    struct Foobar {
      int a;
      int b;
    };
  private:
    int t;
    int method1()
    {
      // Intentional test for different
      // line breaking mode of brackets
    }
    template<typename T>
    int method2(T x) {
      // ...
    }
    enum Foo {
      FOO,
      BAR
    };
    int method3(int par) {}
  };
  class C {
  };
  }
  namespace Ns2 {
  
  }

Tests:

  bin/clang-format test2.cpp # Test default (leave as it is)
  bin/clang-format -style='{SeparateDefinitionBlocks: Between}' test2.cpp # Test normal functionality
  bin/clang-format -style='{SeparateDefinitionBlocks: Leave}' test2.cpp # Test turning off
  bin/clang-format -style='{SeparateDefinitionBlocks: Between, BasedOnStyle: WebKit}' test2.cpp # Case: opening bracket { has   its own line


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

https://reviews.llvm.org/D116314

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116314.396358.patch
Type: text/x-patch
Size: 10772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211228/8899fdbd/attachment.bin>


More information about the cfe-commits mailing list