[PATCH] D116316: [clang-format] Add an experimental option to remove optional control statement braces in LLVM C++ code

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 5 20:49:59 PST 2022


owenpan updated this revision to Diff 397783.
owenpan added a comment.

Fixing a couple of major bugs found by running check-clang plus minor bug fixes and cleanup:

- In `parseLevel()`, `HasOpeningBrace` and `case tok::r_brace:` don't necessarily mean the tokens are `{` and `}`, respectively.
- A pair of braces may be subject to removal even if the `}` is followed by a non-trailing comment.
- The newline before a  wrapped `{` should be deleted when removing the braces.
- `precededByCommentOrPPDirective()` should be a `const` member function.
- The assertion that a `{` of a control statement block is not parsed more than once is false.

Now this patch not only successfully builds clang but also passes check-clang (by not failing more tests than the current clang-format).


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

https://reviews.llvm.org/D116316

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116316.397783.patch
Type: text/x-patch
Size: 35767 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220106/b540fec0/attachment-0001.bin>


More information about the cfe-commits mailing list