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 | 6137dc99ef0c2b14050631367057758b0d596cb3 (patch) | |
tree | da6d2e34ff9d91f5e85d4b2e3ca78c4d0a5e21fb /lib/Lex/PPLexerChange.cpp | |
parent | be1ee79d20db9cec7ef81d7a22ba2eaddc9c95b5 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60437 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index 5129d58bd7..bb2536d1e6 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/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. |