[PATCH] clang-format: Support @synchronized.

strager strager.nds at gmail.com
Thu Jun 25 17:31:40 PDT 2015


I'll remove `ObjCSpaceAfterSynchronized` from this diff.


================
Comment at: docs/ClangFormatStyleOptions.rst:420
@@ -419,1 +419,3 @@
 
+**ObjCSpaceAfterSynchronized** (``bool``)
+  Add a space after ``@synchronized`` in Objective-C, i.e. use
----------------
djasper wrote:
> Actually, I don't think we should have this option at all (and possibly not the one above either, but I can try to deprecate that later). Would it work for you to bind this to what is selected for SpaceBeforeParens? Specifically, can we handle this like control statements? If not, can we extend SpacesBeforeParens to have more enum values?
> Would it work for you to bind this to what is selected for SpaceBeforeParens? Specifically, can we handle this like control statements?

Yes. This patch does that *and* has an option to force spaces. I can split the patch in two so it's obvious. This will cause `@synchronized` to change its formatting, though.

> Would it work for you to bind this to what is selected for SpaceBeforeParens?

Sadly, my code base doesn't work this way. =[

    @synchronized(foo) {  // No space.
        bar;
    }
    if (baz) {  // Space.
        qix;
    }

My code base seems to consistently hug `(` with Objective-C `@` keywords (`@property(...)`, `@synchronized(...)`, etc.).

> If not, can we extend SpacesBeforeParens to have more enum values?

Yeah, I think that's a better approach. I'll leave that discussion for a separate patch.

http://reviews.llvm.org/D10371

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list