[PATCH] D43183: clang-format: introduce `CaseBlockIndent` to control indent in switch
Francois Ferrand via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 13 07:15:06 PST 2018
Typz added a comment.
It is explicitly documented in google style guide: https://google.github.io/styleguide/cppguide.html#Loops_and_Switch_Statements :
> case blocks in switch statements can have curly braces or not, depending on your preference. If you do include curly braces they should be placed as shown below.
>
> If not conditional on an enumerated value, switch statements should always have a default case (in the case of an enumerated value, the compiler will warn you if any values are not handled). If the default case should never execute, simply assert:
>
> switch (var) {
> case 0: { // 2 space indent
> ... // 4 space indent
> break;
> }
> case 1: {
> ...
> break;
> }
> default: {
> assert(false);
> }
> }
So IMHO we cannot just change the current (or default) behaviour.
Repository:
rC Clang
https://reviews.llvm.org/D43183
More information about the cfe-commits
mailing list