[cfe-dev] clang-format: options for formatting templates

Daniel Jasper via cfe-dev cfe-dev at lists.llvm.org
Wed Nov 25 01:10:50 PST 2015


On Wed, Nov 25, 2015 at 2:57 AM, matthew whitehead via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Similar to bug 25148
> https://llvm.org/bugs/show_bug.cgi?id=25148
>
> There seems to be no options for directly formatting large template
> declarations, instead the formatting is done mostly using the column width
> and associates penalties.
> (An example of our preferred formatting style for templates can be seen in
> example1.cpp (attached), while the current output of clang-format can be
> seen in example2.cpp).
>
> Is there any current options that would solve provide the formatting we
> require that I have overlooked please?
> if not, is there anyone currently working on implementing something like
> this?
>

I don't think so (for both questions).


> otherwise, I would potentially be interested in implementing something to
> solve this if someone can give me some guidance on where to start?
>

Sure. I need more specific questions, though. Looking at what
AlignAfterOpenBracket is doing seems to be a good starting point. Well
actually the best starting point might be to write down the exact rules
that you are trying to implement in prose and get some kind of agreement
here. Ideally you have a style guide explaining them (
http://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options
).


> our .clang-format is attached as well for reference
>
> I was thinking a potential solution would be adding an
> AlwaysBreakOnOpeningTemplate option similar to the AlignAfterOpenBracket
> option.
>

Either that or even just re-use AlignAfterOpenBracket. Seems to me that
people wanting the one likely also want the other.

Cheers,
Daniel


>
> Cheers,
> Matt
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151125/6dd95bd2/attachment.html>


More information about the cfe-dev mailing list