[PATCH] [clang-format]: Add support for changing case/default indent/outdent with clang-format

Ryan Livingston via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 6 04:28:54 PST 2017


Hi all,


First time submitting a patch here. Any feedback is appreciated.


This proposed patch adds a new configuration option CaseLabelOffset for clang-format which behaves similarly to AccessModifierOffset. Namely, it permits modifying the indent/outdent of case and default labels.


With indent level 4, IndentCaseLabels false, and CaseLabelOffset 2 you'll get a switch like:


switch (x) {
  case 1:
    break;
  case (2):
    break;
}

Our team uses this style of formatting and when investigating switching to clang-format, I couldn't find a way to accomplish it. So I thought trying a patch would be a good route.

For verification, I ran:

  make clang-test

My new tests failed and I iterated running:

  tools/clang/unittests/Format/FormatTests

until everything passed.

Thanks,
Ryan Livingston

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170206/c019fd36/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: case-label-offset.patch
Type: text/x-patch
Size: 4279 bytes
Desc: case-label-offset.patch
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170206/c019fd36/attachment.bin>


More information about the cfe-commits mailing list