[PATCH] clang-format: Support @synchronized.

Daniel Jasper djasper at google.com
Thu Jun 11 01:23:25 PDT 2015


I can't see the changes to tests at the moment. Trying to fix that issue with SVN/Phabricator (it's unrelated to you patch).


================
Comment at: docs/ClangFormatStyleOptions.rst:422-424
@@ -421,1 +421,5 @@
 
+**ObjCSpaceAfterSynchronized** (``bool``)
+  Add a space after ``@synchronized`` in Objective-C, i.e. use
+  ``\@synchronized (lock)`` instead of ``@synchronized(lock)``.
+
----------------
Don't write these by hand. They should be auto-generated with cfe/docs/tools/dump_format_style.py.

================
Comment at: include/clang/Format/Format.h:405
@@ +404,3 @@
+  /// \brief Defines in which cases to put a space before opening parentheses.
+  bool ObjCSpaceAfterSynchronized;
+
----------------
This should go together with ObjCSpaceAfterProperty.

================
Comment at: include/clang/Format/Format.h:496
@@ -492,2 +495,3 @@
            SpaceBeforeParens == R.SpaceBeforeParens &&
+           ObjCSpaceAfterSynchronized == R.ObjCSpaceAfterSynchronized &&
            SpaceBeforeAssignmentOperators == R.SpaceBeforeAssignmentOperators &&
----------------
Sort this to the right place.

================
Comment at: lib/Format/FormatToken.h:287
@@ -286,1 +286,3 @@
   }
+  bool is(clang::tok::ObjCKeywordKind Kind) const {
+    return Tok.getObjCKeywordID() == Kind;
----------------
remove clang::

Also, do you mind cleaning up the other usage of getObjCKeywordID() ==. There shouldn't be that many, so this can be done in the same patch.

================
Comment at: lib/Format/TokenAnnotator.cpp:1850-1851
@@ -1848,2 +1849,4 @@
               (!Left.Previous || Left.Previous->isNot(tok::period))))) ||
+           (Style.ObjCSpaceAfterSynchronized &&
+            Left.is(tok::objc_synchronized)) ||
            (Style.SpaceBeforeParens == FormatStyle::SBPO_Always &&
----------------
Can you swap the operand order? I would find that easier to read.

http://reviews.llvm.org/D10371

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






More information about the cfe-commits mailing list