r182788 - Support uniform inits in braced lists.

Daniel Jasper djasper at google.com
Tue May 28 12:12:29 PDT 2013


Done in r182796.


On Tue, May 28, 2013 at 9:02 PM, Manuel Klimek <klimek at google.com> wrote:

> On Tue, May 28, 2013 at 8:50 PM, Daniel Jasper <djasper at google.com> wrote:
>
>> Author: djasper
>> Date: Tue May 28 13:50:02 2013
>> New Revision: 182788
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=182788&view=rev
>> Log:
>> Support uniform inits in braced lists.
>>
>> This made it necessary to remove an error detection which would let us
>> bail out of braced lists in certain situations of missing "}". However,
>> as we always entirely escape from the braced list on finding ";", this
>> should not be a big problem.
>>
>> With this, we can no format braced lists with uniformat inits:
>>
>> return { arg1, SomeType { parameter } };
>>
>> 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=182788&r1=182787&r2=182788&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
>> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue May 28 13:50:02 2013
>> @@ -634,11 +634,6 @@ void UnwrappedLineParser::parseBracedLis
>>      // might be to just implement a more or less complete expression
>> parser.
>>      switch (FormatTok->Tok.getKind()) {
>>      case tok::l_brace:
>> -      if (!StartOfExpression) {
>>
>
> Delete StartOfExpression now? Or am I missing a use?
>
>
>> -        // Probably a missing closing brace. Bail out.
>> -        addUnwrappedLine();
>> -        return;
>> -      }
>>        parseBracedList();
>>        StartOfExpression = false;
>>        break;
>>
>> Modified: cfe/trunk/unittests/Format/FormatTest.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182788&r1=182787&r2=182788&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
>> +++ cfe/trunk/unittests/Format/FormatTest.cpp Tue May 28 13:50:02 2013
>> @@ -3386,6 +3386,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
>>      verifyFormat("new vector<int>{ 1, 2, 3 };");
>>      verifyFormat("new int[3]{ 1, 2, 3 };");
>>      verifyFormat("return { arg1, arg2 };");
>> +    verifyFormat("return { arg1, SomeType{ parameter } };");
>>      verifyFormat("new T{ arg1, arg2 };");
>>      verifyFormat("class Class {\n"
>>                   "  T member = { arg1, arg2 };\n"
>> @@ -3402,6 +3403,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo
>>      verifyFormat("new vector<int>{1, 2, 3};", NoSpaces);
>>      verifyFormat("new int[3]{1, 2, 3};", NoSpaces);
>>      verifyFormat("return {arg1, arg2};", NoSpaces);
>> +    verifyFormat("return {arg1, SomeType{parameter}};", NoSpaces);
>>      verifyFormat("new T{arg1, arg2};", NoSpaces);
>>      verifyFormat("class Class {\n"
>>                   "  T member = {arg1, arg2};\n"
>> @@ -4161,15 +4163,8 @@ TEST_F(FormatTest, ObjCLiterals) {
>>    verifyFormat("return @{ @\"one\" : @1 };");
>>    verifyFormat("@{ @\"one\" : @1, }");
>>
>> -  // FIXME: Breaking in cases where we think there's a structural error
>> -  // showed that we're incorrectly parsing this code. We need to fix the
>> -  // parsing here.
>> -  verifyFormat("@{ @\"one\" : @\n"
>> -               "{ @2 : @1 }\n"
>> -               "}");
>> -  verifyFormat("@{ @\"one\" : @\n"
>> -               "{ @2 : @1 },\n"
>> -               "}");
>> +  verifyFormat("@{ @\"one\" : @{ @2 : @1 } }");
>> +  verifyFormat("@{ @\"one\" : @{ @2 : @1 }, }");
>>
>>    verifyFormat("@{ 1 > 2 ? @\"one\" : @\"two\" : 1 > 2 ? @1 : @2 }");
>>    verifyFormat("[self setDict:@{}");
>> @@ -4458,10 +4453,8 @@ TEST_F(FormatTest, DoNotCreateUnreasonab
>>    verifyFormat("if (foo)\n"
>>                 "  return { forgot_closing_brace();\n"
>>                 "test();");
>> -  verifyFormat("int a[] = { void forgot_closing_brace()\n"
>> -               "{\n"
>> -               "  f();\n"
>> -               "  g();\n"
>> +  verifyFormat("int a[] = { void forgot_closing_brace() { f();\n"
>> +               "g();\n"
>>                 "}");
>>  }
>>
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130528/85c65cbf/attachment.html>


More information about the cfe-commits mailing list