[clang-format] Fix DefSeparator empty line issues
authorksyx <18738953+ksyx@users.noreply.github.com>
Sun, 6 Feb 2022 02:18:04 +0000 (02:18 +0000)
committerksyx <18738953+ksyx@users.noreply.github.com>
Mon, 7 Feb 2022 14:23:21 +0000 (14:23 +0000)
commita70549ae43dfa551f3eacdfa7a7f2c0df073be8e
tree9cd533cb9bff15a0cbe16379604643ddd854f553
parentd7ddad408f5b64df39a39f4af3a631275961b975
[clang-format] Fix DefSeparator empty line issues

- Add or remove empty lines surrounding union blocks.
- Fixes https://github.com/llvm/llvm-project/issues/53229, in which
  keywords like class and struct in a line ending with left brace or
  whose next line is left brace only, will be falsely recognized as
  definition line, causing extra empty lines inserted surrounding blocks
  with no need to be formatted.

Reviewed By: MyDeveloperDay, curdeius, HazardyKnusperkeks, owenpan
Differential Revision: https://reviews.llvm.org/D119067
clang/lib/Format/DefinitionBlockSeparator.cpp
clang/unittests/Format/DefinitionBlockSeparatorTest.cpp