[cfe-commits] r59477 - /cfe/trunk/lib/Lex/PPDirectives.cpp

Chris Lattner clattner at apple.com
Wed Nov 19 23:30:17 PST 2008


On Nov 17, 2008, at 4:43 PM, Ted Kremenek wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=59477&view=rev
> Log:
> Added conditional guard 'if (CurLexer)' when using  
> SetCommentRetentionState().
> This is because the PTHLexer will not support this method.  
> Performance testing
> on preprocessing Cocoa.h shows that this results in a negligible  
> performance
> difference (less than 1%).
>
> I tried making Lexer::SetCommentRetentionState() an out-of-line  
> function (a
> precursor to making it a virtual function in PreprocessorLexer) and  
> noticed a 1%
> decrease in speed (it is called in a hot part of the Preprocessor).

I'd suggest a different approach.  Just move ExtendedTokenMode up to  
PreprocessorLexer, and make SetCommentRetentionState a non-virtual  
method there.  That way the PP Can just unconditionally call the  
method, and everything is happy.  The tricky part is to write the  
doxygen comment for ExtendedTokenMode/SetCommentRetentionState to  
properly explain what they do on the generic PPLexer.

The benefit of doing this is that the conditionals disappear.

-Chris




More information about the cfe-commits mailing list