When a block is started after a case label, clang-format does add extra
indent to the content of this block: the block content is indented one
level (with respect to the switch) while the closing brace is not
indented, and closes at switch level.
This gives the following code:
switch (x) { case A: { stuff(); } break; }
This makes it easy to confuse the closing brace of the 'case' with that
the whole 'switch', especially if more code is added after the brace:
switch (x) { case A: { stuff(); } moreStuff(); break; }
This patch introduces a new CaseBlockIndent switch, which provides
alternative formatting for these cases:
- CaseBlockIndent = None : default behavior, same behavior as before
- CaseBlockIndent = ClosingBrace : indent the closing brace to the
same level as its content.
switch (x) { case A: { stuff(); } break; }
- CaseBlockIndent = Block : add an extra level of indent for the
content of the block.
switch (x) { case A: { stuff(); } break; }