[PATCH] clang-format: Support @synchronized.
strager
strager.nds at gmail.com
Thu Jun 11 14:20:07 PDT 2015
================
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)``.
+
----------------
djasper wrote:
> Don't write these by hand. They should be auto-generated with cfe/docs/tools/dump_format_style.py.
Good to know. I assume that applies for my other diffs as well.
================
Comment at: include/clang/Format/Format.h:405
@@ +404,3 @@
+ /// \brief Defines in which cases to put a space before opening parentheses.
+ bool ObjCSpaceAfterSynchronized;
+
----------------
djasper wrote:
> This should go together with ObjCSpaceAfterProperty.
Yup. (I originally named it `SpaceAfterObjCSynchronized`, which is why it's placed here.)
================
Comment at: lib/Format/FormatToken.h:287
@@ -286,1 +286,3 @@
}
+ bool is(clang::tok::ObjCKeywordKind Kind) const {
+ return Tok.getObjCKeywordID() == Kind;
----------------
djasper wrote:
> 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.
Sure. I'll do it in a separate patch, along with similar types like preprocessor keywords.
================
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 &&
----------------
djasper wrote:
> Can you swap the operand order? I would find that easier to read.
You mean:
````
(Left.is(tok::objc_synchronized) &&
Style.ObjCSpaceAfterSynchronized)
````
?
I was keeping consistent with lines 1852 and 1844, where the `Style` check comes first.
http://reviews.llvm.org/D10371
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list