<div dir="ltr">On Tue, May 28, 2013 at 8:50 PM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: djasper<br>
Date: Tue May 28 13:50:02 2013<br>
New Revision: 182788<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=182788&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=182788&view=rev</a><br>
Log:<br>
Support uniform inits in braced lists.<br>
<br>
This made it necessary to remove an error detection which would let us<br>
bail out of braced lists in certain situations of missing "}". However,<br>
as we always entirely escape from the braced list on finding ";", this<br>
should not be a big problem.<br>
<br>
With this, we can no format braced lists with uniformat inits:<br>
<br>
return { arg1, SomeType { parameter } };<br>
<br>
Modified:<br>
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp<br>
    cfe/trunk/unittests/Format/FormatTest.cpp<br>
<br>
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=182788&r1=182787&r2=182788&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=182788&r1=182787&r2=182788&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)<br>
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue May 28 13:50:02 2013<br>
@@ -634,11 +634,6 @@ void UnwrappedLineParser::parseBracedLis<br>
     // might be to just implement a more or less complete expression parser.<br>
     switch (FormatTok->Tok.getKind()) {<br>
     case tok::l_brace:<br>
-      if (!StartOfExpression) {<br></blockquote><div><br></div><div style>Delete StartOfExpression now? Or am I missing a use?</div><div style> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

-        // Probably a missing closing brace. Bail out.<br>
-        addUnwrappedLine();<br>
-        return;<br>
-      }<br>
       parseBracedList();<br>
       StartOfExpression = false;<br>
       break;<br>
<br>
Modified: cfe/trunk/unittests/Format/FormatTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182788&r1=182787&r2=182788&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=182788&r1=182787&r2=182788&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue May 28 13:50:02 2013<br>
@@ -3386,6 +3386,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo<br>
     verifyFormat("new vector<int>{ 1, 2, 3 };");<br>
     verifyFormat("new int[3]{ 1, 2, 3 };");<br>
     verifyFormat("return { arg1, arg2 };");<br>
+    verifyFormat("return { arg1, SomeType{ parameter } };");<br>
     verifyFormat("new T{ arg1, arg2 };");<br>
     verifyFormat("class Class {\n"<br>
                  "  T member = { arg1, arg2 };\n"<br>
@@ -3402,6 +3403,7 @@ TEST_F(FormatTest, LayoutCxx11Constructo<br>
     verifyFormat("new vector<int>{1, 2, 3};", NoSpaces);<br>
     verifyFormat("new int[3]{1, 2, 3};", NoSpaces);<br>
     verifyFormat("return {arg1, arg2};", NoSpaces);<br>
+    verifyFormat("return {arg1, SomeType{parameter}};", NoSpaces);<br>
     verifyFormat("new T{arg1, arg2};", NoSpaces);<br>
     verifyFormat("class Class {\n"<br>
                  "  T member = {arg1, arg2};\n"<br>
@@ -4161,15 +4163,8 @@ TEST_F(FormatTest, ObjCLiterals) {<br>
   verifyFormat("return @{ @\"one\" : @1 };");<br>
   verifyFormat("@{ @\"one\" : @1, }");<br>
<br>
-  // FIXME: Breaking in cases where we think there's a structural error<br>
-  // showed that we're incorrectly parsing this code. We need to fix the<br>
-  // parsing here.<br>
-  verifyFormat("@{ @\"one\" : @\n"<br>
-               "{ @2 : @1 }\n"<br>
-               "}");<br>
-  verifyFormat("@{ @\"one\" : @\n"<br>
-               "{ @2 : @1 },\n"<br>
-               "}");<br>
+  verifyFormat("@{ @\"one\" : @{ @2 : @1 } }");<br>
+  verifyFormat("@{ @\"one\" : @{ @2 : @1 }, }");<br>
<br>
   verifyFormat("@{ 1 > 2 ? @\"one\" : @\"two\" : 1 > 2 ? @1 : @2 }");<br>
   verifyFormat("[self setDict:@{}");<br>
@@ -4458,10 +4453,8 @@ TEST_F(FormatTest, DoNotCreateUnreasonab<br>
   verifyFormat("if (foo)\n"<br>
                "  return { forgot_closing_brace();\n"<br>
                "test();");<br>
-  verifyFormat("int a[] = { void forgot_closing_brace()\n"<br>
-               "{\n"<br>
-               "  f();\n"<br>
-               "  g();\n"<br>
+  verifyFormat("int a[] = { void forgot_closing_brace() { f();\n"<br>
+               "g();\n"<br>
                "}");<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>