r182614 - More tests and a fix for braced init lists.
Daniel Jasper
djasper at google.com
Thu May 23 14:35:49 PDT 2013
Author: djasper
Date: Thu May 23 16:35:49 2013
New Revision: 182614
URL: http://llvm.org/viewvc/llvm-project?rev=182614&view=rev
Log:
More tests and a fix for braced init lists.
Before: f(new vector<int> { 1, 2, 3 });
After: f(new vector<int>{ 1, 2, 3 });
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=182614&r1=182613&r2=182614&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Thu May 23 16:35:49 2013
@@ -1095,8 +1095,8 @@ bool TokenAnnotator::spaceRequiredBetwee
if (Right.Type == TT_UnaryOperator)
return !Left.isOneOf(tok::l_paren, tok::l_square, tok::at) &&
(Left.isNot(tok::colon) || Left.Type != TT_ObjCMethodExpr);
- if (Left.is(tok::identifier) && Right.is(tok::l_brace) &&
- Right.getNextNoneComment())
+ if (Left.isOneOf(tok::identifier, tok::greater, tok::r_square) &&
+ Right.is(tok::l_brace) && Right.getNextNoneComment())
return false;
if (Right.is(tok::ellipsis))
return false;
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182614&r1=182613&r2=182614&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu May 23 16:35:49 2013
@@ -3159,6 +3159,8 @@ TEST_F(FormatTest, LayoutCxx11Constructo
verifyFormat("auto v = Foo{ 1 };");
verifyFormat("f({ 1, 2 }, { { 2, 3 }, { 4, 5 } }, c, { d });");
verifyFormat("Class::Class : member{ 1, 2, 3 } {}");
+ verifyFormat("new vector<int>{ 1, 2, 3 };");
+ verifyFormat("new int[3]{ 1, 2, 3 };");
verifyFormat("return { arg1, arg2 };");
verifyFormat("new T{ arg1, arg2 };");
verifyFormat("class Class {\n"
@@ -3173,6 +3175,8 @@ TEST_F(FormatTest, LayoutCxx11Constructo
verifyFormat("auto v = Foo{-1};", NoSpaces);
verifyFormat("f({1, 2}, {{2, 3}, {4, 5}}, c, {d});", NoSpaces);
verifyFormat("Class::Class : member{1, 2, 3} {}", NoSpaces);
+ verifyFormat("new vector<int>{1, 2, 3};", NoSpaces);
+ verifyFormat("new int[3]{1, 2, 3};", NoSpaces);
verifyFormat("return {arg1, arg2};", NoSpaces);
verifyFormat("new T{arg1, arg2};", NoSpaces);
verifyFormat("class Class {\n"
More information about the cfe-commits
mailing list