[CDRIVER-1167] clang-format config Created: 21/Mar/16 Updated: 13/Dec/16 Resolved: 12/Dec/16 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | Build |
| Affects Version/s: | None |
| Fix Version/s: | 1.6.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Hannes Magnusson | Assignee: | Hannes Magnusson |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||||||||||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Lets come up with a clang-format configuration that formats the code into the ascii art of our current preference and stick to it. The server did something similar recently. We might steal their configuration if reasonable. – – http://zed0.co.uk/clang-format-configurator/ |
| Comments |
| Comment by Githook User [ 13/Dec/16 ] | ||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: | ||||||||||
| Comment by Hannes Magnusson [ 12/Dec/16 ] | ||||||||||
|
Had to explicitly disable SortIncludes as our internal include order is sensitive and not alphabetical. Other then that, worked like a charm.. Until we find issues later | ||||||||||
| Comment by Githook User [ 12/Dec/16 ] | ||||||||||
|
Author: {u'name': u'Clang Formatter', u'email': u'drivers@mongodb.com'}Message: | ||||||||||
| Comment by Githook User [ 12/Dec/16 ] | ||||||||||
|
Author: {u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}Message: | ||||||||||
| Comment by Githook User [ 12/Dec/16 ] | ||||||||||
|
Author: {u'name': u'Clang Formatter', u'email': u'drivers@mongodb.com'}Message: | ||||||||||
| Comment by Githook User [ 12/Dec/16 ] | ||||||||||
|
Author: {u'username': u'bjori', u'name': u'Hannes Magnusson', u'email': u'bjori@php.net'}Message: | ||||||||||
| Comment by Hannes Magnusson [ 12/Dec/16 ] | ||||||||||
|
Yep, thats right. Prototypes that overflow 80chars will have one parameter per line, with the pointer aligned to the variable, but the variable names no longer aligned consecutively – thats pretty much the only thing we are giving up I think. | ||||||||||
| Comment by A. Jesse Jiryu Davis [ 09/Dec/16 ] | ||||||||||
|
I'm excited to see we have an 80-char column limit. As an emeritus Python coder, I still really like 80-char columns. | ||||||||||
| Comment by A. Jesse Jiryu Davis [ 09/Dec/16 ] | ||||||||||
|
Me too. So we got pointer-alignment right, but we had to give up align consecutive declarations?:
That looks fine to me. | ||||||||||
| Comment by Hannes Magnusson [ 09/Dec/16 ] | ||||||||||
|
https://gist.github.com/bjori/335f27790b2b1c6dfaafaa2cf1bbea93 Having swallowed the ascii art bullet in the pointeralignment.. I'm actually quite happy with how this looks. | ||||||||||
| Comment by Mark Benvenuto [ 19/Jul/16 ] | ||||||||||
|
While you could make a fix upstream with the appropriate test cases, it would be cheaper to just use "uncrustify" if it just works. This is not the first time where I have seen clang-format options combinations either not work, or where one option dominates another (AlignOpenBrackets is another). | ||||||||||
| Comment by A. Jesse Jiryu Davis [ 19/Jul/16 ] | ||||||||||
|
Huh, do you think it's profitable to try to contribute a fix to clang-format for that bug, or shall we change our style to PointerAlignment "left" (yuck), or use a different tool like "uncrustify" that does support our current style? | ||||||||||
| Comment by Mark Benvenuto [ 19/Jul/16 ] | ||||||||||
|
jesse This is a bug in clang-format unfortunately with AlignConsecutiveDeclarations and PointerAlignment::Right. See the comment in the code: | ||||||||||
| Comment by A. Jesse Jiryu Davis [ 19/Jul/16 ] | ||||||||||
|
Attached clang-format (2).txt comes close to our existing style. However, it formats signatures like this:
Whereas we want this:
I've set AlignConsecutiveDeclarations "true" and PointerAlignment "right". mark.benvenuto do you know if there's a way to get the asterisks all the way to the right with aligned declarations like this? |