diff options
author | Francois Ferrand <thetypz@gmail.com> | 2018-02-27 13:48:27 +0000 |
---|---|---|
committer | Francois Ferrand <thetypz@gmail.com> | 2018-02-27 13:48:27 +0000 |
commit | f555279b9acafade47501d48a9de2ce719d103f2 (patch) | |
tree | fe6ca4dfcf7ee0872094c1f54089398554b86761 /lib/Format/UnwrappedLineFormatter.cpp | |
parent | f75a680d85938e88e65be0c58f48a21a77f5d0b7 (diff) |
clang-format: use AfterControlStatement to format ObjC control blocks
ObjC defines `@autoreleasepool` and `@synchronized` control blocks. These
used to be formatted according to the `AfterObjCDeclaration` brace-
wrapping flag, which is not very consistent.
This patch changes the behavior to use the `AfterControlStatement` flag
instead. This should not affect the behavior unless a custom brace
wrapping mode is used.
Reviewers: krasimir, djasper, klimek, benhamilton
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D43232
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326192 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineFormatter.cpp')
-rw-r--r-- | lib/Format/UnwrappedLineFormatter.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Format/UnwrappedLineFormatter.cpp b/lib/Format/UnwrappedLineFormatter.cpp index 253f89da9d..2ce39fb04c 100644 --- a/lib/Format/UnwrappedLineFormatter.cpp +++ b/lib/Format/UnwrappedLineFormatter.cpp @@ -314,6 +314,14 @@ private: } return MergedLines; } + // Don't merge block with left brace wrapped after ObjC special blocks + if (TheLine->First->is(tok::l_brace) && I != AnnotatedLines.begin() && + I[-1]->First->is(tok::at) && I[-1]->First->Next) { + tok::ObjCKeywordKind kwId = I[-1]->First->Next->Tok.getObjCKeywordID(); + if (kwId == clang::tok::objc_autoreleasepool || + kwId == clang::tok::objc_synchronized) + return 0; + } // Try to merge a block with left brace wrapped that wasn't yet covered if (TheLine->Last->is(tok::l_brace)) { return !Style.BraceWrapping.AfterFunction || |