[all-commits] [llvm/llvm-project] 91b9e6: [clang-format] Fix `BraceWrapping: AfterFunction` ...

Marek Kurdej via All-commits all-commits at lists.llvm.org
Fri Jan 7 01:07:02 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 91b9e6729c11cce8cf5fea727c6cb81ab8ab5ba4
      https://github.com/llvm/llvm-project/commit/91b9e6729c11cce8cf5fea727c6cb81ab8ab5ba4
  Author: Marek Kurdej <marek.kurdej+llvm.org at gmail.com>
  Date:   2022-01-07 (Fri, 07 Jan 2022)

  Changed paths:
    M clang/lib/Format/UnwrappedLineParser.cpp
    M clang/unittests/Format/FormatTestJava.cpp

  Log Message:
  -----------
  [clang-format] Fix `BraceWrapping: AfterFunction` affecting synchronized blocks in Java.

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

Before this change, BraceWrapping: AfterFunction would affect synchronized blocks in Java, but they should be formatted w.r.t. BraceWrapping: AfterControlStatement.

Using the config:
```
BreakBeforeBraces: Custom
BraceWrapping:
  AfterControlStatement: false
  AfterFunction: true
```

would result in misformatted code like:
```
class Foo {
  void bar()
  {
    synchronized (this)
    {
      a();
      a();
    }
  }
}
```

instead of:
```
class Foo {
  void bar()
  {
    synchronized (this) {
      a();
      a();
    }
  }
}
```

Reviewed By: MyDeveloperDay, owenpan

Differential Revision: https://reviews.llvm.org/D116767




More information about the All-commits mailing list