[cfe-dev] clang-format, how to align function declarations?

Daniel Jasper djasper at google.com
Wed Apr 16 11:44:21 PDT 2014


Such an alignment is quite contrary to how clang-format currently operates
and it will be a significant change to implement this. It would somewhat
relate to how we align trailing comments and escaped newlines, but
significantly more complex. You would mostly need to change
lib/Format/WhitespaceManager.cpp.

Cheers,
Daniel


On Wed, Apr 16, 2014 at 7:14 PM, Petteri Salo <petteri.salo at gmail.com>wrote:

> Hello,
>
> Can someone give me some pointers about where to look in the clang-format
> sources to make a modification which would allow alignment of the function
> names in a group of function declarations.
>
> Or tell me if it is impossible without significant re-write, in other
> words not doable after work and family.
>
> For example:
>
> class FooBar
> {
>     // these three function declarations belong to "group A"
>     char* doo();
>     const char* daa();
>     const SomeReallyLongTypeName& dii();
>     //------------------------------------------------
>
>     // these three function declarations belong to "group B"
>     void someMoreDoo();
>     int notSoMuchDaa();
>     //------------------------------------------------
> };
>
> In a real scenario the comment lines with "group x" would not be present.
>
> The end result I'm looking for is:
> - The names of the three functions in the group A would start at the same
> column, i.e. doo() and daa() would align with dii().
> - The name notSoMuchDaa() would align with someMoreDoo()
>
> the comment line with dashes (//----- ) would signify "end of group"
>
> Thanks,
>
> Petteri Salo
>
>
>
> _______________________________________________
> 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/20140416/43d0e334/attachment.html>


More information about the cfe-dev mailing list