diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-11-27 00:38:24 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-11-27 00:38:24 +0000 |
commit | 82a500b141b9a8001dac69f047478a43e2aebdff (patch) | |
tree | ae79ee34b1afe42b6cb03213a3419212aed1cc0d /lib/Lex/PPLexerChange.cpp | |
parent | 071f2aec57467027540ea849b7889c4c263dbb7d (diff) |
PTHLexer now owns the Token vector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60136 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index 5716d49207..5129d58bd7 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/lib/Lex/PPLexerChange.cpp @@ -78,6 +78,16 @@ void Preprocessor::EnterSourceFile(unsigned FileID, Lexer *TheLexer = new Lexer(SourceLocation::getFileLoc(FileID, 0), *this); EnterSourceFileWithLexer(TheLexer, CurDir); #else + if (CurPPLexer || CurTokenLexer) + PushIncludeMacroStack(); + + CurDirLookup = CurDir; + SourceLocation Loc = SourceLocation::getFileLoc(FileID, 0); + CurPTHLexer.reset(new PTHLexer(*this, Loc)); + CurPPLexer = CurPTHLexer.get(); + + // Generate the tokens. + const llvm::MemoryBuffer* B = getSourceManager().getBuffer(FileID); // Create a raw lexer. @@ -89,7 +99,7 @@ void Preprocessor::EnterSourceFile(unsigned FileID, L.SetCommentRetentionState(false); // Lex the file, populating our data structures. - std::vector<Token>* Tokens = new std::vector<Token>(); + std::vector<Token>& Tokens = CurPTHLexer->getTokens(); Token Tok; do { @@ -101,7 +111,7 @@ void Preprocessor::EnterSourceFile(unsigned FileID, else if (Tok.is(tok::hash) && Tok.isAtStartOfLine()) { // Special processing for #include. Store the '#' token and lex // the next token. - Tokens->push_back(Tok); + Tokens.push_back(Tok); L.LexFromRawLexer(Tok); // Did we see 'include'/'import'/'include_next'? @@ -116,7 +126,7 @@ void Preprocessor::EnterSourceFile(unsigned FileID, K == tok::pp_include_next) { // Save the 'include' token. - Tokens->push_back(Tok); + Tokens.push_back(Tok); // Lex the next token as an include string. L.ParsingPreprocessorDirective = true; @@ -128,15 +138,7 @@ void Preprocessor::EnterSourceFile(unsigned FileID, } } } - while (Tokens->push_back(Tok), Tok.isNot(tok::eof)); - - if (CurPPLexer || CurTokenLexer) - PushIncludeMacroStack(); - - CurDirLookup = CurDir; - SourceLocation Loc = SourceLocation::getFileLoc(FileID, 0); - CurPTHLexer.reset(new PTHLexer(*this, Loc, &(*Tokens)[0], Tokens->size())); - CurPPLexer = CurPTHLexer.get(); + while (Tokens.push_back(Tok), Tok.isNot(tok::eof)); // Notify the client, if desired, that we are in a new source file. if (Callbacks) { |