diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Format/ContinuationIndenter.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 7 |
2 files changed, 9 insertions, 1 deletions
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index c1f448be56b..74cfbf0e901 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -391,7 +391,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, State.Column = State.Stack.back().Indent; // Ensure that we fall back to the continuation indent width instead of just // flushing continuations left. - if (State.Column == State.FirstIndent) + if (State.Column == State.FirstIndent && + PreviousNonComment->isNot(tok::r_brace)) State.Column += Style.ContinuationIndentWidth; } diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 639b8c89d95..5852d1c0ed4 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -374,6 +374,13 @@ TEST_F(FormatTest, ElseIf) { " g();\n" "else\n" " h();"); + verifyFormat("if (a) {\n" + " f();\n" + "}\n" + "// or else ..\n" + "else {\n" + " g()\n" + "}"); } TEST_F(FormatTest, FormatsForLoop) { |