This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Break non-trailing block comments
ClosedPublic

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

Details

Summary

This patch is an alternative to https://reviews.llvm.org/D36614, by resolving a
non-idempotency issue by breaking non-trailing comments:

Consider formatting the following code with column limit at V:

                    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:

                    V
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:

                    V
const /* comment
         comment */
    A = B;

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

Diff Detail

Repository
rL LLVM

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.