[clang-format] Fix support for ObjC blocks with pointer return types
authorJared Grubb <jaredgrubb+github@gmail.com>
Fri, 14 Jul 2023 17:26:09 +0000 (10:26 -0700)
committerEgor Zhdan <e_zhdan@apple.com>
Mon, 17 Jul 2023 13:47:49 +0000 (14:47 +0100)
commit63d6659a045d2e014d53ae890eec8b3cd96e5805
treed12baa5cb132af093ecf89053167d443480d3b55
parentedab068de4c23a627c2a137f5e055239ef30eb44
[clang-format] Fix support for ObjC blocks with pointer return types

The ObjC-block detection code only supports a single token as the return type. Add support to detect pointers, too (ObjC has lots of object-pointers).

For example, using `BasedOnStyle: WebKit`, the following is stable output:

```
int* p = ^int*(void)
{ //
    return nullptr;
}
();
```

After the patch, this is stable:

```
int* p = ^int*(void) { //
    return nullptr;
}();
```

Differential Review: https://reviews.llvm.org/D146434
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp
clang/unittests/Format/FormatTestObjC.cpp