diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-12-02 19:46:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-12-02 19:46:31 +0000 |
commit | af058b569680def888a75d6a1250449a0c8efbd5 (patch) | |
tree | 2cb59029e7e9e245d11095962a12463eed560b83 /clang/lib/Lex/PPLexerChange.cpp | |
parent | 498b6210fcc01faccb4b9792f27db9184ac881f9 (diff) | |
download | bcm5719-llvm-af058b569680def888a75d6a1250449a0c8efbd5.tar.gz bcm5719-llvm-af058b569680def888a75d6a1250449a0c8efbd5.zip |
Preprocessor:
- Added method "setPTHManager" that will be called by the driver to install
a PTHManager for the Preprocessor.
- Fixed some comments.
- Added EnterSourceFileWithPTH to mirror EnterSourceFileWithLexer.
llvm-svn: 60437
Diffstat (limited to 'clang/lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | clang/lib/Lex/PPLexerChange.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/clang/lib/Lex/PPLexerChange.cpp b/clang/lib/Lex/PPLexerChange.cpp index 5129d58bd7f..bb2536d1e60 100644 --- a/clang/lib/Lex/PPLexerChange.cpp +++ b/clang/lib/Lex/PPLexerChange.cpp @@ -75,6 +75,16 @@ void Preprocessor::EnterSourceFile(unsigned FileID, MaxIncludeStackDepth = IncludeMacroStack.size(); #if 1 + if (PTH) { + PTHLexer* PL = + PTH->CreateLexer(FileID, getSourceManager().getFileEntryForID(FileID)); + + if (PL) { + EnterSourceFileWithPTH(PL, CurDir); + return; + } + } + Lexer *TheLexer = new Lexer(SourceLocation::getFileLoc(FileID, 0), *this); EnterSourceFileWithLexer(TheLexer, CurDir); #else @@ -149,8 +159,8 @@ void Preprocessor::EnterSourceFile(unsigned FileID, #endif } -/// EnterSourceFile - Add a source file to the top of the include stack and -/// start lexing tokens from it instead of the current buffer. +/// EnterSourceFileWithLexer - Add a source file to the top of the include stack +/// and start lexing tokens from it instead of the current buffer. void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer, const DirectoryLookup *CurDir) { @@ -172,7 +182,27 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer, } } +/// EnterSourceFileWithPTH - Add a source file to the top of the include stack +/// and start getting tokens from it using the PTH cache. +void Preprocessor::EnterSourceFileWithPTH(PTHLexer *PL, + const DirectoryLookup *CurDir) { + + if (CurPPLexer || CurTokenLexer) + PushIncludeMacroStack(); + CurDirLookup = CurDir; + CurPTHLexer.reset(PL); + CurPPLexer = CurPTHLexer.get(); + + // Notify the client, if desired, that we are in a new source file. + if (Callbacks) { + unsigned FileID = CurPPLexer->getFileID(); + SrcMgr::CharacteristicKind FileType = + SourceMgr.getFileCharacteristic(CurPPLexer->getFileID()); + Callbacks->FileChanged(SourceLocation::getFileLoc(FileID, 0), + PPCallbacks::EnterFile, FileType); + } +} /// EnterMacro - Add a Macro to the top of the include stack and start lexing /// tokens from it instead of the current buffer. |