Page MenuHomePhabricator

[clang-format] Parse blocks in braced lists

Authored by strager on Nov 18 2017, 7:21 PM.



clang-format completely ruins the formatting of block literal
expressions which appear inside inside braced initializer lists. For

int main() {
      ^() {
        return nil;

Teach clang-format to parse blocks inside braced lists:

int main() {
  foo({^() {
    return nil;

Event Timeline

strager created this revision.Nov 18 2017, 7:21 PM
strager edited the summary of this revision. (Show Details)Nov 18 2017, 7:22 PM
strager edited the summary of this revision. (Show Details)
compnerd added a subscriber: compnerd.
benhamilton edited reviewers, added: klimek; removed: djasper.May 23 2018, 8:38 AM

@djasper isn't available to review.

At a high level, this seems good, but I'd like @klimek to take a look.


Is it standard to return a value from these tryToParseFoo() methods, even if nobody uses it?

I think we should either check the return value somewhere, or make this return void.


Style: Remove curly braces for one-line if blocks.

strager abandoned this revision.Oct 10 2019, 6:41 PM
klimek added inline comments.Oct 11 2019, 12:34 AM

Isn't this only an Obj-C/Obj-C++ thing?
If it is, I'd call it tryToParseObjCBlockLiteral.

MyDeveloperDay added a project: Restricted Project.Oct 11 2019, 2:18 AM