[tor-bugs] #32921 [Core Tor/Tor]: Code and script changes to run clang-format without breaking checkSpaces or coccinelle

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Feb 10 18:03:17 UTC 2020


#32921: Code and script changes to run clang-format without breaking checkSpaces or
coccinelle
----------------------------+------------------------------------
 Reporter:  nickm           |          Owner:  nickm
     Type:  enhancement     |         Status:  needs_review
 Priority:  Medium          |      Milestone:  Tor: 0.4.3.x-final
Component:  Core Tor/Tor    |        Version:
 Severity:  Normal          |     Resolution:
 Keywords:  style, 043-can  |  Actual Points:  1.5
Parent ID:  #29226          |         Points:
 Reviewer:  catalyst        |        Sponsor:
----------------------------+------------------------------------

Comment (by catalyst):

 Remaining things that I think are excessive changes by clang-format:

 * clang-format is too eager to move line breaks around so that a long
 argument list wraps with the longest-possible lines.  This can make code
 more confusing if arguments have a useful semantic grouping.  I'm not sure
 how to turn this off.  I think it might do a similar thing to long
 expressions in the controlling expressions of conditional statements?
 Maybe we can work around this by adding redundant parentheses to make
 clang-format more reluctant to break lines at certain places.  What do
 people think about that?

 * extra indentation for array initializers, e.g. clang produces
   {{{
 struct foo a[] = {
     V(x),
     V(y),
 };
 }}}
   while existing code tends to have
   {{{
 struct foo a[] = {
   V(x),
   V(y),
 };
 }}}
   I think we can fix this with `ContinuationIndentWidth: 2`, but I'm not
 sure.  (This would change to 4 once we change to a 4-column indent.)

 * clang-format doesn't retain spaces inside curly braces in one-line
 initializer items, e.g. clang produces
   {{{
 struct foo a[] = {
   {0, 0, 0},
 };
 }}}
   while existing code tends to have
   {{{
 struct foo a[] = {
   { 0, 0, 0 },
 };
 }}}
   I find the style with the internal spaces more readable.  This is not a
 strong perference.

 * clang-format doesn't have a way to maintain tabular alignment in
 initializer lists.  We have a lot of these.  The branch doesn't turn off
 clang-format in all of them.  Do we want to maintain tabular alignment?
 (I think it makes large tables more readable, but I'd like to hear other
 opinions.)

 * I don't like the way `AlignTrailingComments: false` looks.  I like
 alignment for stuff like Doxygen in-line comments for structures.  It's
 not a strong preference, though.  (Among other things, I think Doxygen
 might do its own alignment in its HTML output.)

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/32921#comment:20>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list