[cfe-dev] Preprocessor::LookNext
Chris Lattner
clattner at apple.com
Mon Jul 7 23:51:24 PDT 2008
On Jul 3, 2008, at 6:14 PM, Argiris Kirtzidis wrote:
> The "nested-name-specifier '::' " syntax occurs at enough places
> that it would really simplify the code if an efficient
> Parser::GetLookAheadToken(1) could be used.
>
> I attached a Preprocessor::LookNext implementation for this (pp-
> looknext.patch).
> In the "parse-labeled" patch I use LookNext to determine a label and
> use a separate Parser::ParseLabeledStatement.
Hi Argiris,
Is there a specific problem with calling LookAhead(0)? To me, this is
a performance optimization tweak... I'd rather do this sort of thing
when more of the C++ front-end is in place. This would give us better
grounds for profiling and determine whether it is actually a win in
the end.
Adding a "LookNext()" method to the preprocessor as a helper for
LookAhead(0) would be ok if you think it would be significantly useful
though. Also, LookAhead could obviously be improved :).
Finally, are you sure it would be completely unreasonable to refactor
the C++ grammar to avoid the look-ahead in the common case? While
always having peektok available is nice, it adds significant cost to
the hotest part of the C preprocessor. I would expect a significant
slowdown from the patch on large .i files with -Eonly for example
(which spends almost all time in this code).
-Chris
More information about the cfe-dev
mailing list