diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-08-29 19:36:52 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-08-29 19:36:52 +0000 |
commit | a70a52b29e9c951cc0a94f22e6653522f49b5d2d (patch) | |
tree | e835244ae6c9a5d187380da6529530632173b00b /lib/Lex/PPLexerChange.cpp | |
parent | c2cb99d6f15c283c2ea66cc8520f612f97b3851d (diff) |
unique_ptrify Preprocessor's TokenLexerCache
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216756 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PPLexerChange.cpp')
-rw-r--r-- | lib/Lex/PPLexerChange.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/Lex/PPLexerChange.cpp b/lib/Lex/PPLexerChange.cpp index 22ee971f48..1ce3796aa7 100644 --- a/lib/Lex/PPLexerChange.cpp +++ b/lib/Lex/PPLexerChange.cpp @@ -160,17 +160,17 @@ void Preprocessor::EnterSourceFileWithPTH(PTHLexer *PL, /// tokens from it instead of the current buffer. void Preprocessor::EnterMacro(Token &Tok, SourceLocation ILEnd, MacroInfo *Macro, MacroArgs *Args) { - TokenLexer *TokLexer; + std::unique_ptr<TokenLexer> TokLexer; if (NumCachedTokenLexers == 0) { - TokLexer = new TokenLexer(Tok, ILEnd, Macro, Args, *this); + TokLexer = llvm::make_unique<TokenLexer>(Tok, ILEnd, Macro, Args, *this); } else { - TokLexer = TokenLexerCache[--NumCachedTokenLexers]; + TokLexer = std::move(TokenLexerCache[--NumCachedTokenLexers]); TokLexer->Init(Tok, ILEnd, Macro, Args); } PushIncludeMacroStack(); CurDirLookup = nullptr; - CurTokenLexer.reset(TokLexer); + CurTokenLexer = std::move(TokLexer); if (CurLexerKind != CLK_LexAfterModuleImport) CurLexerKind = CLK_TokenLexer; } @@ -191,19 +191,19 @@ void Preprocessor::EnterTokenStream(const Token *Toks, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens) { // Create a macro expander to expand from the specified token stream. - TokenLexer *TokLexer; + std::unique_ptr<TokenLexer> TokLexer; if (NumCachedTokenLexers == 0) { - TokLexer = new TokenLexer(Toks, NumToks, DisableMacroExpansion, - OwnsTokens, *this); + TokLexer = llvm::make_unique<TokenLexer>( + Toks, NumToks, DisableMacroExpansion, OwnsTokens, *this); } else { - TokLexer = TokenLexerCache[--NumCachedTokenLexers]; + TokLexer = std::move(TokenLexerCache[--NumCachedTokenLexers]); TokLexer->Init(Toks, NumToks, DisableMacroExpansion, OwnsTokens); } // Save our current state. PushIncludeMacroStack(); CurDirLookup = nullptr; - CurTokenLexer.reset(TokLexer); + CurTokenLexer = std::move(TokLexer); if (CurLexerKind != CLK_LexAfterModuleImport) CurLexerKind = CLK_TokenLexer; } @@ -526,7 +526,7 @@ bool Preprocessor::HandleEndOfTokenLexer(Token &Result) { if (NumCachedTokenLexers == TokenLexerCacheSize) CurTokenLexer.reset(); else - TokenLexerCache[NumCachedTokenLexers++] = CurTokenLexer.release(); + TokenLexerCache[NumCachedTokenLexers++] = std::move(CurTokenLexer); // Handle this like a #include file being popped off the stack. return HandleEndOfFile(Result, true); @@ -543,7 +543,7 @@ void Preprocessor::RemoveTopOfLexerStack() { if (NumCachedTokenLexers == TokenLexerCacheSize) CurTokenLexer.reset(); else - TokenLexerCache[NumCachedTokenLexers++] = CurTokenLexer.release(); + TokenLexerCache[NumCachedTokenLexers++] = std::move(CurTokenLexer); } PopIncludeMacroStack(); |