[cfe-commits] r138704 - in /cfe/trunk: include/clang/Basic/IdentifierTable.h include/clang/Lex/Preprocessor.h lib/Lex/Preprocessor.cpp test/Modules/lookup.cpp

Douglas Gregor dgregor at apple.com
Wed Sep 7 16:13:35 PDT 2011


On Sep 6, 2011, at 10:59 AM, Argyrios Kyrtzidis wrote:

> On Aug 26, 2011, at 11:37 PM, Douglas Gregor wrote:
> 
>> Author: dgregor
>> Date: Sat Aug 27 01:37:51 2011
>> New Revision: 138704
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=138704&view=rev
>> Log:
>> Take an entirely different approach to handling the "parsing" of
>> __import__ within the preprocessor, since the prior one foolishly
>> assumed that Preprocessor::Lex() was re-entrant. We now handle
>> __import__ at the top level (only), after macro expansion. This should
>> fix the buildbot failures.
>> 
> 
> [...]
> 
>>  /// Lex - To lex a token from the preprocessor, just pull a token from the
>>  /// current lexer or macro object.
>>  void Lex(Token &Result) {
>> +    ++LexDepth;
>>    if (CurLexer)
>>      CurLexer->Lex(Result);
>>    else if (CurPTHLexer)
>> @@ -539,6 +543,11 @@
>>      CurTokenLexer->Lex(Result);
>>    else
>>      CachingLex(Result);
>> +    --LexDepth;
>> +    
>> +    // If we have the __import__ keyword, handle the module import now.
>> +    if (Result.getKind() == tok::kw___import__ && LexDepth == 0)
>> +      HandleModuleImport(Result);
>>  }
> 
> Lex() is one of those super hot methods, is it possible to avoid this modification ? I get about -5.5% for -Eonly of Cocoa.h if I remove the additions in Lex().


Fixed in r139265, thanks!

	- Doug



More information about the cfe-commits mailing list