Page MenuHomePhabricator

[clang-format] Fix comment levels between '} else {' and PPDirective.
ClosedPublic

Authored by krasimir on Jul 24 2017, 4:33 AM.

Details

Summary

This fixes a regression exposed by r307795 and rL308725 in which the level of a
comment line between '} else {' and a preprocessor directive is incorrectly set
as the level of the '} else {' line. For example, this :

int f(int i) {
  if (i) {
    ++i;
  } else {
    // comment
#ifdef A
    --i;
#endif
  }
}

was formatted as:

int f(int i) {
  if (i) {
    ++i;
  } else {
  // comment
#ifdef A
    --i;
#endif
  }
}

Diff Detail

Repository
rL LLVM

Event Timeline

krasimir created this revision.Jul 24 2017, 4:33 AM
krasimir updated this revision to Diff 107896.Jul 24 2017, 6:51 AM
  • Make the closing brace use the same thing
krasimir updated this revision to Diff 107900.Jul 24 2017, 7:30 AM
  • Switch to relative levels
krasimir updated this revision to Diff 107901.Jul 24 2017, 7:31 AM
  • Remove unused import
klimek accepted this revision.Jul 24 2017, 7:42 AM

lg

lib/Format/UnwrappedLineParser.h
126 ↗(On Diff #107901)

s/this token/the current token/
"This token" can be interpreted as the one nextToken reads otherwise.

This revision is now accepted and ready to land.Jul 24 2017, 7:42 AM
krasimir updated this revision to Diff 107904.Jul 24 2017, 7:49 AM
  • Address review comments
This revision was automatically updated to reflect the committed changes.