This is an archive of the discontinued LLVM Phabricator instance.

clang-format: Support @autoreleasepool.
ClosedPublic

Authored by strager on Jun 10 2015, 4:08 PM.

Details

Reviewers
djasper
thakis
Summary

Format @autoreleasepool properly for the Attach brace style
by recognizing @autoreleasepool as a block introducer.

Diff Detail

Event Timeline

strager updated this revision to Diff 27473.Jun 10 2015, 4:08 PM
strager retitled this revision from to clang-format: Support @autoreleasepool..
strager updated this object.
strager edited the test plan for this revision. (Show Details)
strager added a reviewer: djasper.
strager added subscribers: sas, abdulras, Unknown Object (MLST).
thakis added a subscriber: thakis.Jun 10 2015, 9:58 PM

Can you add a test?

Oh, sorry, there is one, phab just doesn't show it (and didn't mail it)
'cause it thinks FormatTest.cpp is a binary file (?)

djasper edited edge metadata.Jun 11 2015, 1:21 AM

I can't see the changes to tests at the moment. Trying to fix that issue with SVN/Phabricator (it's unrelated to you patch).

strager updated this revision to Diff 27606.Jun 12 2015, 2:47 PM
strager edited edge metadata.

Fix test diff on Phabricator.

Ping. Tests should be visible now.

The case body is mostly the same as for case tok::objc_synchronized – could they share the same code? (the paren code would just never run for autoreleasepool)

The case body is mostly the same as for case tok::objc_synchronized – could they share the same code? (the paren code would just never run for autoreleasepool)

The same could be said for while and maybe if and for, too.

Testing @autoreleasepool (foo) { and not testing @autoreleasepool { doesn't make sense anyway.

djasper added inline comments.Jun 23 2015, 4:25 AM
lib/Format/UnwrappedLineParser.cpp
659

(I think this is also what Nico means): Join this case and the next. I think it makes sense to format "@autoreleasepool (foo) {" like @synchronized, even if it might not be valid syntax. If you care about not having parens here, extend the corresponding if-statement.

strager planned changes to this revision.Jun 25 2015, 5:20 PM
strager added inline comments.
lib/Format/UnwrappedLineParser.cpp
659

Ah, I thought Nico was talking about the test cases, not this switch.

I agree.

strager updated this revision to Diff 28523.Jun 25 2015, 7:00 PM

Merge autoreleasepool and synchronized cases.

Looks good to me.

Please merge this for me.

thakis accepted this revision.Jun 27 2015, 6:06 PM
thakis added a reviewer: thakis.

Landed in r240896.

This revision is now accepted and ready to land.Jun 27 2015, 6:06 PM
strager closed this revision.Jun 29 2015, 6:03 PM