diff options
| -rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 1 | ||||
| -rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index ee9172227b0..58a1eeb5a6d 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1061,6 +1061,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) { Style.BreakConstructorInitializersBeforeComma) { Current->MustBreakBefore = true; } else if (Current->Previous->BlockKind == BK_Block && + Current->Previous->isNot(tok::r_brace) && Current->isNot(tok::r_brace)) { Current->MustBreakBefore = true; } else if (Current->is(tok::l_brace) && (Current->BlockKind == BK_Block)) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 2dfc4059e66..3c295259c8f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -351,6 +351,11 @@ TEST_F(FormatTest, ParseIfElse) { "else {\n" " i();\n" "}"); + verifyFormat("void f() {\n" + " if (a) {\n" + " } else {\n" + " }\n" + "}"); } TEST_F(FormatTest, ElseIf) { |

