Page MenuHomePhabricator

[clang-format] Add support to SpacesBeforeTrailingComments to add spaces before Block comments.
Needs RevisionPublic

Authored by Manikishan on Aug 2 2019, 5:56 AM.



Patch: SpacesBeforeTrailingBlockComments

This patch is to support `spacesBeforeTrailingComments``` to support spaces before Trailing BlockComments. According to the Documentation, this was not implemented because block comments have different usage patterns and a various number of special cases. I am trying to cover as many cases as possible which can be useful.
This patch covers some cases such as Declarations, definitions, and Includes

This is also under the Project of Adding NetBSD-KNF support to clang-format.

Example for supported cases:

Int a;	\*foo *\
int b;	\*bar *\
Int c;	\*baz *\

#include ads.h		\*foo *\
#include bar.h		\*bar *\

These following tests fail for this patch:

  1. FormatTests/FormatTestComments.UnderstandsBlockComments
  2. FormatTests/FormatTestJS.AddsLastLinePenaltyIfEndingIsBroken
  3. FormatTests/FormatTestJS.TemplateStrings

I have to discuss whether to add support to those cases because I think the tests need to be modified while implementing this style.

I would like to discuss more one this specific style to know which cases I could work on, as it was chosen not to support.
It will be good if I can get more inputs on the cases I could cover.

Diff Detail

rC Clang

Event Timeline

Manikishan created this revision.Aug 2 2019, 5:56 AM
lebedev.ri resigned from this revision.Aug 2 2019, 7:50 AM
MyDeveloperDay requested changes to this revision.Aug 5 2019, 2:56 AM
MyDeveloperDay added inline comments.



would a test that shows why it should not be used after TT_TemplateCloser or tok::l_paren help?


this feels odd, suggesting those using google style will get reformatted changes?

This revision now requires changes to proceed.Aug 5 2019, 2:56 AM
Manikishan marked an inline comment as done.Aug 6 2019, 12:05 PM
Manikishan added inline comments.

Yes, so in that case shall I add a new style variable like spacesBeforeTrailingBlockComments. Using which they can enable the style. This also supports new styles which need. spaces before Block Comments and styles which doesn't need spaces.

Manikishan added a project: Restricted Project.Sep 25 2019, 1:48 AM