diff options
| author | Daniel Jasper <djasper@google.com> | 2013-09-06 21:46:41 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2013-09-06 21:46:41 +0000 |
| commit | 87f18f1128ad86c6bfcf40c648419b6a02a943cb (patch) | |
| tree | 55d6cc96b3cbfe6ed6a091996083f6b4dbb52a6f | |
| parent | 786a550b9fcc5fc2f0d7b0895ea0029877e9585c (diff) | |
| download | bcm5719-llvm-87f18f1128ad86c6bfcf40c648419b6a02a943cb.tar.gz bcm5719-llvm-87f18f1128ad86c6bfcf40c648419b6a02a943cb.zip | |
clang-format: Fix regression introduced by r190038.
Before:
Constructor()
: aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {
}
After:
Constructor()
: aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {
}
llvm-svn: 190209
| -rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 7 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index 12cfd48f5b3..40d9d2f7d29 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -225,7 +225,12 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline, Penalty += Style.PenaltyBreakFirstLessLess; if (Current.is(tok::r_brace)) { - State.Column = State.Stack[State.Stack.size() - 2].LastSpace; + if (Current.MatchingParen && + (Current.MatchingParen->BlockKind == BK_BracedInit || + !Current.MatchingParen->Children.empty())) + State.Column = State.Stack[State.Stack.size() - 2].LastSpace; + else + State.Column = State.FirstIndent; } else if (Current.is(tok::string_literal) && State.StartOfStringLiteral != 0) { State.Column = State.StartOfStringLiteral; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 79dbad79c67..10a6316054b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -2495,6 +2495,10 @@ TEST_F(FormatTest, ConstructorInitializers) { verifyFormat("Constructor(int Parameter = 0)\n" " : aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaa),\n" " aaaaaaaaaaaa(aaaaaaaaaaaaaaaaa) {}"); + verifyFormat("Constructor()\n" + " : aaaaaaaaaaaaaaaaaaaa(a), bbbbbbbbbbbbbbbbbbbbbbbb(b) {\n" + "}", + getLLVMStyleWithColumns(60)); // Here a line could be saved by splitting the second initializer onto two // lines, but that is not desireable. |

