[PATCH] D43183: clang-format: introduce `CaseBlockIndent` to control indent in switch

Daniel Jasper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 28 07:59:01 PST 2018


djasper added a comment.

New options for this would not be acceptable IMO. Too much cost for too little benefit.

I'd suggest to first make the change to fall back to the style with a regular block when there are statements other than break after the closing brace. That is always bad, no matter the indentation of the case labels:

  switch (x) {
    case 1: {
      doSomething();
    }
      doSomethingElse();
      break;
  }

Fixing this is good no matter what.

And then the second question is whether this style should be used or not (with IndentCaseLabels: false):

  switch (x) {
  case 1: {
    doSomething();
  }
  }

Pro: Saves horizontal and vertical space.
Con: It's weird to have to braces in the same column.

I don't personally have an opinion here, but I'll check with a few LLVM developers who work with LLVM style.


Repository:
  rC Clang

https://reviews.llvm.org/D43183





More information about the cfe-commits mailing list