diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-18 00:43:07 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-18 00:43:07 +0000 |
commit | 59e003e538465782cc0239ba0cc85211d07e2f86 (patch) | |
tree | 1ce36e6a516e9c08225c57a6d57d784a863a03b7 /clang/lib/Lex/PPDirectives.cpp | |
parent | f1e932920952a75058f3cb304f1f646a918d7750 (diff) | |
download | bcm5719-llvm-59e003e538465782cc0239ba0cc85211d07e2f86.tar.gz bcm5719-llvm-59e003e538465782cc0239ba0cc85211d07e2f86.zip |
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).
llvm-svn: 59477
Diffstat (limited to 'clang/lib/Lex/PPDirectives.cpp')
-rw-r--r-- | clang/lib/Lex/PPDirectives.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp index 1a19a1a26c6..22178739867 100644 --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -150,7 +150,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, // directive mode. Tell the lexer this so any newlines we see will be // converted into an EOM token (this terminates the macro). CurPPLexer->ParsingPreprocessorDirective = true; - CurLexer->SetCommentRetentionState(false); + if (CurLexer) CurLexer->SetCommentRetentionState(false); // Read the next token, the directive flavor. @@ -161,7 +161,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, if (Tok.isNot(tok::identifier)) { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. - CurLexer->SetCommentRetentionState(KeepComments); + if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments); continue; } @@ -176,7 +176,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, FirstChar != 'i' && FirstChar != 'e') { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. - CurLexer->SetCommentRetentionState(KeepComments); + if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments); continue; } @@ -197,7 +197,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, if (IdLen >= 20) { CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. - CurLexer->SetCommentRetentionState(KeepComments); + if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments); continue; } memcpy(Directive, &DirectiveStr[0], IdLen); @@ -278,7 +278,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation IfTokenLoc, CurPPLexer->ParsingPreprocessorDirective = false; // Restore comment saving mode. - CurLexer->SetCommentRetentionState(KeepComments); + if (CurLexer) CurLexer->SetCommentRetentionState(KeepComments); } // Finally, if we are out of the conditional (saw an #endif or ran off the end @@ -828,7 +828,7 @@ void Preprocessor::HandleDefineDirective(Token &DefineTok) { // If we are supposed to keep comments in #defines, reenable comment saving // mode. - CurLexer->SetCommentRetentionState(KeepMacroComments); + if (CurLexer) CurLexer->SetCommentRetentionState(KeepMacroComments); // Create the new macro. MacroInfo *MI = new MacroInfo(MacroNameTok.getLocation()); |