[PATCH] D72276: [clang-format] Add IndentCaseBlocks option

Nicolas Capens via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 6 08:25:16 PST 2020


capn created this revision.
capn added a reviewer: clang-format.
capn added a project: clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The documentation for IndentCaseLabels claimed that the "Switch
statement body is always indented one level more than case labels". This
is technically false for the code block immediately following the label.
Its closing bracket aligns with the start of the label.

If the case label are not indented, it leads to a style where the
closing bracket of the block aligns with the closing bracket of the
switch statement, which can be hard to parse.

This change introduces a new option, IndentCaseBlocks, which when true
treats the block as a scope block (which it technically is).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72276

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72276.236375.patch
Type: text/x-patch
Size: 7027 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200106/e263a83e/attachment.bin>


More information about the cfe-commits mailing list