r209428 - clang-format: Fix incorrect braced init identification.
Daniel Jasper
djasper at google.com
Thu May 22 05:11:13 PDT 2014
Author: djasper
Date: Thu May 22 07:11:13 2014
New Revision: 209428
URL: http://llvm.org/viewvc/llvm-project?rev=209428&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=209428&r1=209427&r2=209428&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu May 22 07:11:13 2014
@@ -348,7 +348,8 @@ void UnwrappedLineParser::calculateBrace
// 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));
}
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=209428&r1=209427&r2=209428&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu May 22 07:11:13 2014
@@ -5263,6 +5263,9 @@ TEST_F(FormatTest, LayoutCxx11BraceIniti
"};");
verifyFormat("vector<int> 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;
More information about the cfe-commits
mailing list