diff options
| author | Daniel Jasper <djasper@google.com> | 2014-10-11 08:24:56 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-10-11 08:24:56 +0000 |
| commit | ec8e838baadcb55b6986c908cb593d6fd37752b1 (patch) | |
| tree | d3a52e32c1ea4ea8de8a90aea37ced046968656a | |
| parent | 30bdfa7f99d822e1780e954caef969120eead40f (diff) | |
| download | bcm5719-llvm-ec8e838baadcb55b6986c908cb593d6fd37752b1.tar.gz bcm5719-llvm-ec8e838baadcb55b6986c908cb593d6fd37752b1.zip | |
clang-format: [ObjC] Wrap ObjC method declarations before annotations.
Before:
- (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x
y:(id<yyyyyyyyyyyyyyyyyyyy>)
y NS_DESIGNATED_INITIALIZER;
After:
- (instancetype)initXxxxxxxxxxxxxxxxxxxxxxxxx:(id<x>)x
y:(id<yyyyyyyyyyyyyyyyyyyy>)y
NS_DESIGNATED_INITIALIZER;
llvm-svn: 219564
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 5 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 4a964ed41d8..1f8ac5ee107 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1432,6 +1432,11 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line, if (Right.Type == TT_TrailingAnnotation && (!Right.Next || Right.Next->isNot(tok::l_paren))) { + // Moving trailing annotations to the next line is fine for ObjC method + // declarations. + if (Line.First->Type == TT_ObjCMethodSpecifier) + + return 10; // Generally, breaking before a trailing annotation is bad unless it is // function-like. It seems to be especially preferable to keep standard // annotations (i.e. "const", "final" and "override") on the same line. diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 4091cd5c10f..758e5042262 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6452,6 +6452,10 @@ TEST_F(FormatTest, FormatObjCMethodDeclarations) { " evenLongerKeyword:(float)theInterval\n" " error:(NSError **)theError {\n" "}"); + verifyFormat("- (instancetype)initXxxxxx:(id<x>)x\n" + " y:(id<yyyyyyyyyyyyyyyyyyyy>)y\n" + " NS_DESIGNATED_INITIALIZER;", + getLLVMStyleWithColumns(60)); } TEST_F(FormatTest, FormatObjCMethodExpr) { |

