<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><div dir="ltr">lg</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Dec 4, 2012 at 4:26 PM, Alexander Kornienko <span dir="ltr"><<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi klimek,<br>
<br>
<a href="http://llvm-reviews.chandlerc.com/D163" target="_blank">http://llvm-reviews.chandlerc.com/D163</a><br>
<br>
Files:<br>
lib/Format/UnwrappedLineParser.cpp<br>
unittests/Format/FormatTest.cpp<br>
<br>
Index: lib/Format/UnwrappedLineParser.cpp<br>
===================================================================<br>
--- lib/Format/UnwrappedLineParser.cpp<br>
+++ lib/Format/UnwrappedLineParser.cpp<br>
@@ -72,7 +72,10 @@<br>
parseLevel();<br>
if (!IsNamespace)<br>
--Line.Level;<br>
- assert(<a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::r_brace) && "expected '}'");<br>
+ // FIXME: Add error handling.<br>
+ if (!<a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::r_brace))<br>
+ return;<br>
+<br>
nextToken();<br>
if (<a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::semi))<br>
nextToken();<br>
@@ -218,7 +221,12 @@<br>
--Line.Level;<br>
}<br>
<br>
- assert(<a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::kw_while) && "'while' expected");<br>
+ // FIXME: Add error handling.<br>
+ if (!<a href="http://FormatTok.Tok.is" target="_blank">FormatTok.Tok.is</a>(tok::kw_while)) {<br>
+ addUnwrappedLine();<br>
+ return;<br>
+ }<br>
+<br>
nextToken();<br>
parseStatement();<br>
}<br>
Index: unittests/Format/FormatTest.cpp<br>
===================================================================<br>
--- unittests/Format/FormatTest.cpp<br>
+++ unittests/Format/FormatTest.cpp<br>
@@ -363,5 +363,23 @@<br>
// "};");<br>
//}<br>
<br>
+TEST_F(FormatTest, IncorrectCodeUnbalancedBraces) {<br>
+ verifyFormat("{");<br>
+}<br>
+<br>
+TEST_F(FormatTest, IncorrectCodeDoNoWhile) {<br>
+ verifyFormat("do {\n"<br>
+ "};");<br>
+ verifyFormat("do {\n"<br>
+ "};\n"<br>
+ "f();");<br>
+ verifyFormat("do {\n"<br>
+ "}\n"<br>
+ "wheeee(fun);");<br>
+ verifyFormat("do {\n"<br>
+ " f();\n"<br>
+ "};");<br>
+}<br>
+<br>
} // end namespace tooling<br>
} // end namespace clang<br>
</blockquote></div><br></div></div>