[cfe-dev] Clang-format: Braces Indent Style Whitesmiths
Daniel Jasper
djasper at google.com
Fri Dec 26 11:14:20 PST 2014
On Fri, Dec 26, 2014 at 7:53 PM, JVApen <JVApen at gmail.com> wrote:
> Hi all,
>
> I was looking into the clang tools to experiment with; hoping to convince
> some colleagues that tooling can save us time.
> Anyhow; since I was trying to take baby steps; clang format looked like a
> very good start.
> Unfortunately, we would not be programmers if we wouldn't do things a bit
> different than the rest of the world.
>
> The current code; with too many files; uses the Whitesmiths style
> <http://en.wikipedia.org/wiki/Indent_style#Whitesmiths_style> at most
> places.
> Though this is not yet supported by clang format.
> Going through the code, adding support for it did not look like a big
> thing; since Allman and GNU are very similar.
> The thing I did not realize is that both of them indent all code by one
> level compared to the {,
> which is not done by Whitesmiths style.
>
That actually shouldn't matter much. The whether or not to break before the
"{" is controlled by calling addUnwrappedLine() one more time whereas the
indentation is controlled by changing Line->Level. Basically all you should
need to do is to change the order of "addUnwrappedLine(); ++Line->Level;"
for the addUnwrappedLine() call for the "{". Unfortunately, there is no
nice abstraction for this and you'll need to look at how to do this for the
different kinds of syntactic elements individually. I can look into it and
give more help if you get stuck.
I already wrote a unit test, based on the Allman unit test; useful for test
> driven development
> and experimented already with the code in
> lib/Format/UnwrappedLineParser.cpp
> Though can't seem to find out how to prevent the extra indent;
> does anyone with more codebase experience have an idea where to start?
>
> JVApen
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141226/bc3a499e/attachment.html>
More information about the cfe-dev
mailing list