[PATCH] D93846: [clang-format] PR16518 Add flag to suppress empty line insertion before access modifier

Albertas Vyšniauskas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 6 13:01:55 PST 2021


thezbyg updated this revision to Diff 314962.
thezbyg added a comment.

Switched `EmptyLineBeforeAccessModifierStyle` option from bool to enum.
`EmptyLineBeforeAccessModifierStyle` option can now have one of four values: `Never`, `DontModify`, `LogicalBlock`, `Always`.
`Never` removes all empty lines before access modifiers.
`DontModify` keeps existing empty lines.
`LogicalBlock` adds empty line only when access modifier starts a new logical block (current clang-format behavior).
`Always` adds empty line before all access modifiers except when access modifier is at the start of class/struct definition.

Updated tests to test all four option values. When testing `DontModify` option, some of the tests use `EXPECT_EQ()` instead of `verifyFormat()`. This is because empty lines are not preserved in `verifyFormat()` due to `test::messUp()`.


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

https://reviews.llvm.org/D93846

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/test/Format/access-modifiers.cpp
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93846.314962.patch
Type: text/x-patch
Size: 18670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210106/0663caa3/attachment-0001.bin>


More information about the cfe-commits mailing list