Page MenuHomePhabricator

[clang-format] Break non-trailing block comments

Authored by krasimir on Aug 22 2017, 5:00 AM.



This patch is an alternative to, by resolving a
non-idempotency issue by breaking non-trailing comments:

Consider formatting the following code with column limit at V:

const /* comment comment */ A = B;

The comment is not a trailing comment, breaking before it doesn't bring it under
the column limit. The formatter breaks after it, resulting in:

const /* comment comment */
    A = B;

For a next reformat, the formatter considers the comment as a trailing comment,
so it is free to break it further, resulting in:

const /* comment
         comment */
    A = B;

This patch improves the situation by directly producing the third case.

Diff Detail


Event Timeline

krasimir created this revision.Aug 22 2017, 5:00 AM
krasimir added a subscriber: cfe-commits.
djasper accepted this revision.Aug 22 2017, 7:37 AM

If no tests break with this, lets just go for it. We can follow up and fix individual cases if we find undesired behavior.

This revision is now accepted and ready to land.Aug 22 2017, 7:37 AM
This revision was automatically updated to reflect the committed changes.