This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix regression merging comments across newlines.
ClosedPublic

Authored by krasimir on Jan 31 2017, 2:38 AM.

Details

Summary

This fixes a regression that causes example:

enum A {
  a, // line a

  // line b
  b
};

to be formatted as follows:

enum A {
  a, // line a
     // line b
  b
};

Event Timeline

krasimir created this revision.Jan 31 2017, 2:38 AM
krasimir updated this revision to Diff 86401.Jan 31 2017, 2:39 AM
  • Remove newline
klimek added inline comments.Jan 31 2017, 2:45 AM
lib/Format/BreakableToken.cpp
685

Could we put them as children into the higher level UnwrappedLine instead?

krasimir added inline comments.Jan 31 2017, 3:04 AM
lib/Format/BreakableToken.cpp
685

Putting them as children looks cleaner; will try that.

krasimir updated this revision to Diff 86410.Jan 31 2017, 4:51 AM
  • Add a FIXME for separating line comment sections into child lines
krasimir marked an inline comment as done.Jan 31 2017, 4:53 AM
krasimir added inline comments.
lib/Format/BreakableToken.cpp
685

For now, I'm adding a FIXME, since this putting the sections into children has some undesired ripple effects in other places and needs more in-depth analysis.

klimek accepted this revision.Jan 31 2017, 4:58 AM

lg minus adding the FIXME to the place where we need the change.

lib/Format/UnwrappedLineParser.cpp
2127–2130

Can you also add a FIXME here (as this is where it'd probably need to happen :)

This revision is now accepted and ready to land.Jan 31 2017, 4:58 AM
krasimir updated this revision to Diff 86412.Jan 31 2017, 5:38 AM
krasimir marked an inline comment as done.
  • Add a FIXME also in the parser
krasimir added inline comments.Jan 31 2017, 5:38 AM
lib/Format/UnwrappedLineParser.cpp
2127–2130

Done.

This revision was automatically updated to reflect the committed changes.