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

Ted Kremenek kremenek at apple.com
Thu Nov 20 00:12:24 PST 2008

On Nov 19, 2008, at 11:32 PM, Chris Lattner wrote:

> 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

Sounds good.  I'll look into doing this after the PTHLexer becomes  
more usuable.

More information about the cfe-commits mailing list