[PATCH] D114521: [clang-format] [PR47936] AfterControlStatement: MultiLine breaks AllowShortFunctionsOnASingleLine

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 24 07:46:02 PST 2021


MyDeveloperDay added a comment.

However if we add

  AllowShortBlocksOnASingleLine : Always

then it will be

  class Foo {
    foo() {
      if (x) bar();
      if (x) { bar(); }
    }
  };

but if we set

  BasedOnStyle: LLVM
  AllowShortIfStatementsOnASingleLine: Never
  ColumnLimit: 80
  AllowShortBlocksOnASingleLine : Always

we get

  class Foo {
    foo() {
      if (x)
        bar();
      if (x) {
        bar();
      }
    }
  };

which feels like `if(x){ bar(); }` is primarily controlled by  `AllowShortBlocksOnASingleLine`  i.e. setting it to `Never` will override the `AllowShortIfStatementsOnASingleLine` setting for if statements with braces.

However if `AllowShortBlocksOnASingleLine` is `Always` then if `AllowShortIfStatementsOnASingleLine` is set to `Never` then it wins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114521



More information about the cfe-commits mailing list