<div dir="ltr"><div class="gmail_default" style>On Fri, Jan 11, 2013 at 7:47 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br></div><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"><div class="im">On Fri, Jan 11, 2013 at 10:28 AM, Manuel Klimek <<a href="mailto:klimek@google.com">klimek@google.com</a>> wrote:<br>

> Author: klimek<br>
> Date: Fri Jan 11 12:28:36 2013<br>
> New Revision: 172232<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=172232&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=172232&view=rev</a><br>
> Log:<br>
> Fix crash on invalid.<br>
><br>
> if { foo; }<br>
> would previously crash clang-format.<br>
<br>
</div>Thanks!<br>
<br>
parseSwitch() and parseForOrWhileLoop() have the same issue from what<br>
I can tell.<br></blockquote><div><br></div><div style>Good catch! Fixed, thanks.</div><div style> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><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=172232&r1=172231&r2=172232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=172232&r1=172231&r2=172232&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)<br>
> +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Jan 11 12:28:36 2013<br>
> @@ -404,7 +404,8 @@<br>
>  void UnwrappedLineParser::parseIfThenElse() {<br>
>    assert(<a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::kw_if) && "'if' expected");<br>
>    nextToken();<br>
> -  parseParens();<br>
> +  if (<a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::l_paren))<br>
> +    parseParens();<br>
>    bool NeedsUnwrappedLine = false;<br>
>    if (<a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::l_brace)) {<br>
>      parseBlock();<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=172232&r1=172231&r2=172232&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172232&r1=172231&r2=172232&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
> +++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jan 11 12:28:36 2013<br>
> @@ -1108,6 +1108,10 @@<br>
>                 "}");<br>
>  }<br>
><br>
> +TEST_F(FormatTest, IncorrectIf) {<br>
> +  verifyFormat("if {\n  foo;\n  foo();\n}");<br>
> +}<br>
> +<br>
>  TEST_F(FormatTest, DoesNotTouchUnwrappedLinesWithErrors) {<br>
>    verifyFormat("namespace {\n"<br>
>                 "class Foo {  Foo  ( }; }  // comment");<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>
</div></div></blockquote></div><br></div></div>