r190678 - clang-format: Detect braced lists in subscript expressions.
Daniel Jasper
djasper at google.com
Fri Sep 13 03:55:31 PDT 2013
Author: djasper
Date: Fri Sep 13 05:55:31 2013
New Revision: 190678
URL: http://llvm.org/viewvc/llvm-project?rev=190678&view=rev
Log:
clang-format: Detect braced lists in subscript expressions.
Before (even with Style.Cpp11BracedListStyle):
f(MyMap[{ composite, key }]);
After:
f(MyMap[{composite, key}]);
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=190678&r1=190677&r2=190678&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Sep 13 05:55:31 2013
@@ -290,7 +290,7 @@ void UnwrappedLineParser::calculateBrace
//
// We exclude + and - as they can be ObjC visibility modifiers.
if (NextTok->isOneOf(tok::comma, tok::semi, tok::r_paren,
- tok::l_brace, tok::colon) ||
+ tok::r_square, tok::l_brace, tok::colon) ||
(NextTok->isBinaryOperator() &&
!NextTok->isOneOf(tok::plus, tok::minus))) {
Tok->BlockKind = BK_BracedInit;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=190678&r1=190677&r2=190678&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Sep 13 05:55:31 2013
@@ -4271,6 +4271,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
verifyFormat("return { arg1, arg2 };");
verifyFormat("return { arg1, SomeType{ parameter } };");
verifyFormat("new T{ arg1, arg2 };");
+ verifyFormat("f(MyMap[{ composite, key }]);");
verifyFormat("class Class {\n"
" T member = { arg1, arg2 };\n"
"};");
@@ -4305,6 +4306,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
verifyFormat("return {arg1, arg2};", NoSpaces);
verifyFormat("return {arg1, SomeType{parameter}};", NoSpaces);
verifyFormat("new T{arg1, arg2};", NoSpaces);
+ verifyFormat("f(MyMap[{composite, key}]);", NoSpaces);
verifyFormat("class Class {\n"
" T member = {arg1, arg2};\n"
"};",
More information about the cfe-commits
mailing list