From 513f0c09b40f4474ed6beb4427aa409c94a8e38b 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}; }; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@237568 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 3 ++- unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index d0a8cfbe69..2331305cc5 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 00c23b5bcc..0bb1bc151a 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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(); -- 2.40.0