From cec9ffd2a244d0001768f529da797bd141e9f214 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 18 May 2015 14:12:24 +0000 Subject: [PATCH] clang-format: Fix regression introduced by r237565. Before: class C : public D { SomeClass SC { 2 }; }; After: class C : public D { SomeClass SC{2}; }; llvm-svn: 237568 --- clang/lib/Format/UnwrappedLineParser.cpp | 3 ++- clang/unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index d0a8cfbe69f7..2331305cc539 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -351,7 +351,8 @@ void UnwrappedLineParser::calculateBraceTypes(bool ExpectClassBody) { NextTok->isOneOf(tok::comma, tok::period, tok::colon, tok::r_paren, tok::r_square, tok::l_brace, tok::l_paren, tok::ellipsis) || - (NextTok->is(tok::semi) && !ExpectClassBody) || + (NextTok->is(tok::semi) && + (!ExpectClassBody || LBraceStack.size() != 1)) || (NextTok->isBinaryOperator() && !NextIsObjCMethod); } if (ProbablyBracedList) { diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 00c23b5bcc10..0bb1bc151a0b 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -6192,6 +6192,9 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { " aaaa,\n" " },\n" "};"); + verifyFormat("class C : public D {\n" + " SomeClass SC{2};\n" + "};"); // In combination with BinPackParameters = false. FormatStyle NoBinPacking = getLLVMStyle();