[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
Tue Feb 7 05:31:19 PST 2017
When adding more tests, an issue with this approach was found using scopes:
switch (x) {
case 1:
break;
case (2):
break;
case 3: {
break;
} // <-- Seems we should offset this by 2
}
I'll look into getting this behavior and update the patch.
~Ryan
________________________________
From: Ryan Livingston
Sent: Monday, February 6, 2017 7:28:54 AM
To: cfe-commits at lists.llvm.org
Subject: [PATCH] [clang-format]: Add support for changing case/default indent/outdent with clang-format
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/20170207/067d952b/attachment.html>
More information about the cfe-commits
mailing list