[cfe-commits] r172232 - in /cfe/trunk: lib/Format/UnwrappedLineParser.cpp unittests/Format/FormatTest.cpp

Manuel Klimek klimek at google.com
Fri Jan 11 11:23:27 PST 2013


On Fri, Jan 11, 2013 at 7:47 PM, Nico Weber <thakis at chromium.org> wrote:

> On Fri, Jan 11, 2013 at 10:28 AM, Manuel Klimek <klimek at google.com> wrote:
> > Author: klimek
> > Date: Fri Jan 11 12:28:36 2013
> > New Revision: 172232
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=172232&view=rev
> > Log:
> > Fix crash on invalid.
> >
> > if { foo; }
> > would previously crash clang-format.
>
> Thanks!
>
> parseSwitch() and parseForOrWhileLoop() have the same issue from what
> I can tell.
>

Good catch! Fixed, thanks.


>
> >
> > 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=172232&r1=172231&r2=172232&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
> > +++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Fri Jan 11 12:28:36 2013
> > @@ -404,7 +404,8 @@
> >  void UnwrappedLineParser::parseIfThenElse() {
> >    assert(FormatTok.Tok.is(tok::kw_if) && "'if' expected");
> >    nextToken();
> > -  parseParens();
> > +  if (FormatTok.Tok.is(tok::l_paren))
> > +    parseParens();
> >    bool NeedsUnwrappedLine = false;
> >    if (FormatTok.Tok.is(tok::l_brace)) {
> >      parseBlock();
> >
> > Modified: cfe/trunk/unittests/Format/FormatTest.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=172232&r1=172231&r2=172232&view=diff
> >
> ==============================================================================
> > --- cfe/trunk/unittests/Format/FormatTest.cpp (original)
> > +++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jan 11 12:28:36 2013
> > @@ -1108,6 +1108,10 @@
> >                 "}");
> >  }
> >
> > +TEST_F(FormatTest, IncorrectIf) {
> > +  verifyFormat("if {\n  foo;\n  foo();\n}");
> > +}
> > +
> >  TEST_F(FormatTest, DoesNotTouchUnwrappedLinesWithErrors) {
> >    verifyFormat("namespace {\n"
> >                 "class Foo {  Foo  ( }; }  // comment");
> >
> >
> > _______________________________________________
> > 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/20130111/9f811c3c/attachment.html>


More information about the cfe-commits mailing list