diff options
| author | Daniel Jasper <djasper@google.com> | 2013-11-08 02:08:01 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-11-08 02:08:01 +0000 |
| commit | b302f9a0fb8596c49899cbe5ad0c736b580a5753 (patch) | |
| tree | aa28a83d3f0ffd79e5b91c124b49f4492ce36351 /clang | |
| parent | c8f7fd10a943e647a2e1e0b03ece70f021a9516d (diff) | |
| download | bcm5719-llvm-b302f9a0fb8596c49899cbe5ad0c736b580a5753.tar.gz bcm5719-llvm-b302f9a0fb8596c49899cbe5ad0c736b580a5753.zip | |
clang-format: Properly indent ObjC calls wrapped before first selector
Before:
[self // break
a:a
aa:aa
aaaaa:aaa];
After:
[self // break
a:a
aa:aa
aaaaa:aaa];
llvm-svn: 194241
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 6 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 442f9fa8505..d075c7482d0 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -375,7 +375,11 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, State.Line->StartsDefinition))) { State.Column = State.Stack.back().Indent; } else if (Current.Type == TT_ObjCSelectorName) { - if (State.Stack.back().ColonPos > Current.ColumnWidth) { + if (State.Stack.back().ColonPos == 0) { + State.Stack.back().ColonPos = + State.Stack.back().Indent + Current.LongestObjCSelectorName; + State.Column = State.Stack.back().ColonPos - Current.ColumnWidth; + } else if (State.Stack.back().ColonPos > Current.ColumnWidth) { State.Column = State.Stack.back().ColonPos - Current.ColumnWidth; } else { State.Column = State.Stack.back().Indent; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e6757c5d2a4..776bf49a4aa 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -5474,6 +5474,9 @@ TEST_F(FormatTest, FormatObjCMethodExpr) { "[self aaaaaaaaaaaaa:aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaa, aaaaaaaaaaaaaaa];"); + verifyFormat("[self // break\n" + " a:a\n" + " aaa:aaa];"); } TEST_F(FormatTest, ObjCAt) { |

