This is an archive of the discontinued LLVM Phabricator instance.

Remove redundant comma around parenthesis in parameter list.
ClosedPublic

Authored by ioeric on Sep 13 2016, 5:37 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

ioeric updated this revision to Diff 71149.Sep 13 2016, 5:37 AM
ioeric retitled this revision from to Remove redundant comma around parenthesis in parameter list..
ioeric updated this object.
ioeric added a reviewer: djasper.
ioeric added a subscriber: cfe-commits.
djasper added inline comments.Sep 13 2016, 5:45 AM
unittests/Format/CleanupTest.cpp
147 ↗(On Diff #71149)

Seems like it's worth to pull out a function getting (offset, input, expected output) and then doing all this. Of course doesn't *have* to be in this patch, but I guess now is as good a time as any.

Once that is done and we don't need to duplicate so much code, I think it might be worth duplicating this test to have it with and without trailing comma.

Also, I think there is actually a FIXME here. Lets assume I mark the offset that you put into ranges as X, then I think:

  • {a, b, X} should lead to {a, b}
  • {a, b, X,} should lead to {a, b,}

Does that make sense?

ioeric updated this revision to Diff 71158.Sep 13 2016, 6:35 AM
ioeric marked an inline comment as done.
  • Refactored cleanup unittest; added more test cases for trailing commas.
unittests/Format/CleanupTest.cpp
147 ↗(On Diff #71149)

Yep, make sense :)

djasper accepted this revision.Sep 13 2016, 7:52 AM
djasper edited edge metadata.

Some remarks, but looks good.

unittests/Format/CleanupTest.cpp
38 ↗(On Diff #71158)

I thin we normally just used "unsigned" instead of "unsigned int".

39 ↗(On Diff #71158)

nit: alignment.

125 ↗(On Diff #71158)

I think for such short test cases, at least, I'd just inline the string literals, e.g.:

EXPECT_EQ("class A {\nA()  {} };",
          cleanupAroundOffsets({17, 19}, "class A {\nA() : , {} };"));

But not sure whether it's better.

This revision is now accepted and ready to land.Sep 13 2016, 7:52 AM
ioeric updated this revision to Diff 71174.Sep 13 2016, 8:09 AM
ioeric marked 2 inline comments as done.
ioeric edited edge metadata.
  • Minor cleanup.
unittests/Format/CleanupTest.cpp
125 ↗(On Diff #71158)

I prefer defining variables since it is easier to read/compare and also consistent with other test cases.

This revision was automatically updated to reflect the committed changes.