This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix breaking of comment sections in unwrapped lines containing newlines.
ClosedPublic

Authored by krasimir on Feb 2 2017, 5:02 AM.

Details

Summary

The breaking of line comment sections was misaligning the case where the first comment line is on an unwrapped line containing newlines. In this case, the breaking column must be based on the source column of the last token that is preceded by a newline, not on the first token of the unwrapped line.

source:

enum A {
  a, // line 1
  // line 2
};

format before:

enum A {
  a, // line 1
     // line 2
};

format after:

enum A {
  a, // line 1
  // line 2
};

Diff Detail

Repository
rL LLVM

Event Timeline

krasimir created this revision.Feb 2 2017, 5:02 AM
krasimir updated this revision to Diff 86790.Feb 2 2017, 5:08 AM
  • Add tests for comments in the end of enums.
krasimir edited the summary of this revision. (Show Details)Feb 2 2017, 5:08 AM
krasimir added a reviewer: djasper.
krasimir added a subscriber: cfe-commits.
djasper accepted this revision.Feb 2 2017, 6:02 AM

Nice :)

This revision is now accepted and ready to land.Feb 2 2017, 6:02 AM
This revision was automatically updated to reflect the committed changes.