[PATCH] D47195: [clang-format] Fix putting ObjC message arguments in one line for multiline receiver

Jacek Olesiak via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 23 01:06:22 PDT 2018


jolesiak added inline comments.


================
Comment at: unittests/Format/FormatTestObjC.cpp:815
+
+  // No line break before closing receiver's scope.
+  verifyFormat("[[obj a:42] a:42\n"
----------------
krasimir wrote:
> jolesiak wrote:
> > krasimir wrote:
> > > jolesiak wrote:
> > > > krasimir wrote:
> > > > > What's the receiver's scope in this comment referring to?
> > > > > Also, how would the old test cases be formatted?
> > > > For a receiver: `[obj a:42]` I meant `]` as a token closing the scope.
> > > > I'll rephrase the comment to be more precise.
> > > > 
> > > > Old tests were introduced in D46879. After this change the formatting will be the same as it was before D46879, i.e. the same as for last test touched in this change:
> > > > ```
> > > > [[obj aaaaaa:42
> > > >            b:42]
> > > >     cc:42
> > > >      d:42];
> > > > ```
> > > > even if
> > > > ```
> > > > [[obj aaaaaa:42
> > > >            b:42]
> > > >     cc:42 d:42];
> > > > ```
> > > > satisfies the column limit.
> > > Ah, I think  get it now: the new code should only apply to after object blocks and not after object receivers? Is this the intention?
> > The intention is to put arguments into one line if they fit but only in the same line as last character of a receiver expression, e.g.:
> > ```
> > [[object block:^{
> >   return 42;
> > }] aa:42 bb:42];
> > ```
> > instead of
> > ```
> > [[object block:^{
> >   return 42;
> > }] aa:42
> >    bb:42];
> > ```
> > but not
> > ```
> > [[obj a:42]
> >     a:42 b:42];
> > ```
> > 
> > I think it gets a little bit too complicated for no reason. Let me revert D46879 and rebase this change.
> In that case, would this be allowed?
> ```
> //      limit:       V
> [[obj a:42
>       b:42
>       c:42
>       d:42] e:42 f:42]
> ```
Yes, I added this test.


Repository:
  rC Clang

https://reviews.llvm.org/D47195





More information about the cfe-commits mailing list