From 75ca7975d7e2207aa9cdcff0e1a8e9f7d89d956c Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 22 May 2014 12:11:13 +0000 Subject: [PATCH] clang-format: Fix incorrect braced init identification. Before: int foo(int i) { return fo1 {} (i); } int foo(int i) { return fo1 {} (i); } After: int foo(int i) { return fo1{}(i); } int foo(int i) { return fo1{}(i); } This fixes llvm.org/PR19812. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209428 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 0585442550..e0106d94cf 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -348,7 +348,8 @@ void UnwrappedLineParser::calculateBraceTypes() { // We exclude + and - as they can be ObjC visibility modifiers. ProbablyBracedList = NextTok->isOneOf(tok::comma, tok::semi, tok::period, tok::colon, - tok::r_paren, tok::r_square, tok::l_brace) || + tok::r_paren, tok::r_square, tok::l_brace, + tok::l_paren) || (NextTok->isBinaryOperator() && !NextTok->isOneOf(tok::plus, tok::minus)); } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index af0b5a1cb6..f9016f4bf1 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -5263,6 +5263,9 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) { "};"); verifyFormat("vector foo = {::SomeGlobalFunction()};"); + verifyFormat("int foo(int i) { return fo1{}(i); }"); + verifyFormat("int foo(int i) { return fo1{}(i); }"); + // In combination with BinPackParameters = false. FormatStyle NoBinPacking = getLLVMStyle(); NoBinPacking.BinPackParameters = false; -- 2.40.0