[cfe-commits] r66011 - in /cfe/trunk: Driver/PrintParserCallbacks.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Wed Mar 4 05:29:49 PST 2009


On Wed, 04 Mar 2009 04:23:07 -0000, Chris Lattner <sabre at nondot.org> wrote:
> Author: lattner
> Date: Tue Mar  3 22:23:07 2009
> New Revision: 66011
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=66011&view=rev
> Log:
> Change Parser::ParseCaseStatement to use an iterative approach to parsing
> multiple sequential case statements instead of doing it with recursion. 
> This
> fixes a problem where we run out of stack space parsing 100K directly
> nested
> cases.
> 
> Sebastian, I would appreciate it if you could scrutinize the smart
pointer 
> gymnastics I do.

Looks all right. One detail below, as well as a typo.

> +  // Parsing this naively works, but is both inefficient and can cause
us
> to run
> +  // out of stack space in our recursive descent parser.  As a special
> case,
> +  // flatten this recursion into an interative loop.  This is complex
and
> gross,

Typo here.

>  
> -  return Actions.ActOnCaseStmt(CaseLoc, move(LHS), DotDotDotLoc,
> -                               move(RHS), ColonLoc, move(SubStmt));
> +  // Return the top level parsed statement tree.
> +  return OwningStmtResult(Actions, TopLevelCase.release());
>  }

Detail here:
return move(TopLevelCase);
should work.

Sebastian



More information about the cfe-commits mailing list