clang-format: Fix line breaking bug after empty ifs.
Before: if () { } else { } After: if () { } else { } This fixed llvm.org/PR17262. llvm-svn: 190855
This commit is contained in:
parent
0de8efa63d
commit
88f9222c4e
|
@ -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)) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue