r195417 - clang-format: Recognize braced lists with trailing function call.
Daniel Jasper
djasper at google.com
Thu Nov 21 23:26:53 PST 2013
Author: djasper
Date: Fri Nov 22 01:26:53 2013
New Revision: 195417
URL: http://llvm.org/viewvc/llvm-project?rev=195417&view=rev
Log:
clang-format: Recognize braced lists with trailing function call.
Before:
int count = set<int> { f(), g(), h() }
.size();
After:
int count = set<int>{f(), g(), h()}.size();
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=195417&r1=195416&r2=195417&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Nov 22 01:26:53 2013
@@ -322,7 +322,7 @@ void UnwrappedLineParser::calculateBrace
// (for example while parsing lambdas).
//
// We exclude + and - as they can be ObjC visibility modifiers.
- if (NextTok->isOneOf(tok::comma, tok::semi, tok::r_paren,
+ if (NextTok->isOneOf(tok::comma, tok::semi, tok::r_paren, tok::period,
tok::r_square, tok::l_brace, tok::colon) ||
(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=195417&r1=195416&r2=195417&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Nov 22 01:26:53 2013
@@ -4671,6 +4671,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
verifyFormat("new int[3]{ 1, 2, 3 };");
verifyFormat("return { arg1, arg2 };");
verifyFormat("return { arg1, SomeType{ parameter } };");
+ verifyFormat("int count = set<int>{ f(), g(), h() }.size();");
verifyFormat("new T{ arg1, arg2 };");
verifyFormat("f(MyMap[{ composite, key }]);");
verifyFormat("class Class {\n"
@@ -4706,6 +4707,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
verifyFormat("new int[3]{1, 2, 3};", NoSpaces);
verifyFormat("return {arg1, arg2};", NoSpaces);
verifyFormat("return {arg1, SomeType{parameter}};", NoSpaces);
+ verifyFormat("int count = set<int>{f(), g(), h()}.size();", NoSpaces);
verifyFormat("new T{arg1, arg2};", NoSpaces);
verifyFormat("f(MyMap[{composite, key}]);", NoSpaces);
verifyFormat("class Class {\n"
More information about the cfe-commits
mailing list