diff options
author | Francois Ferrand <thetypz@gmail.com> | 2018-02-27 13:48:21 +0000 |
---|---|---|
committer | Francois Ferrand <thetypz@gmail.com> | 2018-02-27 13:48:21 +0000 |
commit | ba91c3de383cbcc1f5cdb678412a622118096a78 (patch) | |
tree | 8a925a72a9d6c158cb6995ea983ef5fce2427f92 /clang/unittests/Format/FormatTestObjC.cpp | |
parent | ba43ec8702456aa4a435569ca2982c4ec444976f (diff) | |
download | bcm5719-llvm-ba91c3de383cbcc1f5cdb678412a622118096a78.tar.gz bcm5719-llvm-ba91c3de383cbcc1f5cdb678412a622118096a78.zip |
clang-format: fix formatting of ObjC @synchronized blocks
Summary:
The blocks used to be formatted using the "default" behavior, and would
thus be mistaken for function calls followed by blocks: this could lead
to unexpected inlining of the block and extra line-break before the
opening brace.
They are now formatted similarly to `@autoreleasepool` blocks, as
expected:
@synchronized(self) {
f();
}
Reviewers: krasimir, djasper, klimek
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D43114
llvm-svn: 326191
Diffstat (limited to 'clang/unittests/Format/FormatTestObjC.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestObjC.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestObjC.cpp b/clang/unittests/Format/FormatTestObjC.cpp index 40dc375d576..d592b39a482 100644 --- a/clang/unittests/Format/FormatTestObjC.cpp +++ b/clang/unittests/Format/FormatTestObjC.cpp @@ -209,6 +209,24 @@ TEST_F(FormatTestObjC, FormatObjCGenerics) { " aaaaaaaaaaaaaaaaa);\n"); } +TEST_F(FormatTestObjC, FormatObjCSynchronized) { + verifyFormat("@synchronized(self) {\n" + " f();\n" + "}\n" + "@synchronized(self) {\n" + " f();\n" + "}\n"); + Style.BreakBeforeBraces = FormatStyle::BS_Allman; + verifyFormat("@synchronized(self)\n" + "{\n" + " f();\n" + "}\n" + "@synchronized(self)\n" + "{\n" + " f();\n" + "}\n"); +} + TEST_F(FormatTestObjC, FormatObjCInterface) { verifyFormat("@interface Foo : NSObject <NSSomeDelegate> {\n" "@public\n" |