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

ksyx via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 27 09:25:21 PST 2021


ksyx added a comment.

Test code:

  // 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) {
      // ...
    }
    int method3(int par) {}
  };
  class C {
  }
  }
  namespace Ns2 {
  
  }

Tests ran:

  # pwd = build directory
  bin/clang-format test.cpp # LLVM Style
  bin/clang-format -style='{SeparateDefinitionBlocks: false}' test.cpp # Disable functionality
  bin/clang-format -style='{BasedOnStyle: Google}' test.cpp # Disable by default
  bin/clang-format -style='{BasedOnStyle: Google, SeparateDefinitionBlocks: true}' test.cpp # Override default
  bin/clang-format -style='{BasedOnStyle: WebKit}' test.cpp # Opening bracket in new line (WebKit style has this functionality enabled)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116314



More information about the cfe-commits mailing list