[PATCH] D43114: clang-format: fix formatting of ObjC @synchronized blocks

Francois Ferrand via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 05:26:18 PST 2018


Typz marked 4 inline comments as done.
Typz added inline comments.


================
Comment at: lib/Format/UnwrappedLineParser.cpp:1130
+        if (FormatTok->Tok.is(tok::l_brace)) {
+          if (Style.BraceWrapping.AfterObjCDeclaration)
+            addUnwrappedLine();
----------------
benhamilton wrote:
> Typz wrote:
> > benhamilton wrote:
> > > Typz wrote:
> > > > Wondering if formatting with this style is appropriate: the clang-format doc points in that direction, but it seems to me both `@synchronized` and `@autoreleasepool` are more akin to "control statements".
> > > > 
> > > > For consistency (esp. in ObjC++ code), as a user, I would tend to have these blocks indented like control statements while interfaces/implementations blocks would be indented like classes/structs.
> > > > 
> > > > So maybe it would be better to introduce a new BraceWrapping style 'AfterObjCSpecialBlock` to control these cases, matching the possibilities that are given for control statements vs classes. What do you think?
> > > Hmm, I definitely agree with that logic. I don't see them acting as declarations in any way, they are definitely like control statements.
> > > 
> > Ok, i can change this. Two questions though:
> > * Should I do this in this patch, or a separate patch? (won't be a big change in any case, but it can still be seen as 2 separate issues/changes)
> > * Should I introduce a new BraceWrapping flag (`AfterObjCSpecialBlock`), or simply apply `AfterControlStatement` to these blocks?
> Personally, I feel `AfterControlStatement` applies to these. I'm not an expert on this, though, so I will defer to others on the review.
I created another diff to change the field that is used to control brace wrapping after these blocks: https://reviews.llvm.org/D43232

This patch here should now only relate to the parsing of `@synchronized` blocks.


Repository:
  rC Clang

https://reviews.llvm.org/D43114





More information about the cfe-commits mailing list