This is an archive of the discontinued LLVM Phabricator instance.

Also cleanup comments around redundant colons/commas in format::cleanup.
ClosedPublic

Authored by ioeric on Sep 9 2016, 8:36 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric updated this revision to Diff 70842.Sep 9 2016, 8:36 AM
ioeric retitled this revision from to Also cleanup comments around redundant colons/commas in format::cleanup..
ioeric updated this object.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
djasper added inline comments.Sep 9 2016, 10:24 AM
lib/Format/Format.cpp
1141 ↗(On Diff #70842)

Couldn't you just do:

for (auto *Tok = Left->Next; Tok && Tok != Right; Tok = Tok->Next)
  if (Tok->is(tok::comment))
    deleteToken(Comment);

That way you wouldn't have to store the comments in a vector.

ioeric updated this revision to Diff 70863.Sep 9 2016, 10:47 AM
ioeric marked an inline comment as done.
  • Addressed review comments.
djasper accepted this revision.Sep 9 2016, 10:51 AM
djasper edited edge metadata.

One remark, otherwise looks good.

lib/Format/Format.cpp
1136 ↗(On Diff #70863)

Hm. I think this "if" actually doesn't change behavior. If we remove it, we'd just add already deleted tokens to the set again, which shouldn't hurt (and we do it for comments at the moment). I'd just remove this line.

This revision is now accepted and ready to land.Sep 9 2016, 10:51 AM
ioeric updated this revision to Diff 70865.Sep 9 2016, 10:57 AM
ioeric marked an inline comment as done.
ioeric edited edge metadata.
  • Addressed review comments.
lib/Format/Format.cpp
1136 ↗(On Diff #70863)

Wow, from 20 LOC to 2 LOC! Thanks!

This revision was automatically updated to reflect the committed changes.