diff options
author | David Blaikie <dblaikie@gmail.com> | 2016-02-09 18:52:09 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2016-02-09 18:52:09 +0000 |
commit | a31043191688f3dce6f7f24908cc260965de47d1 (patch) | |
tree | d287fceb321dddd046f6c2e336ed49e04776c7f4 /lib/Parse/ParseCXXInlineMethods.cpp | |
parent | 703b2cb63cb1de7acb8ece35a0d5733e3411f377 (diff) | |
download | clang-a31043191688f3dce6f7f24908cc260965de47d1.tar.gz |
Simplify EnterTokenStream API to make it more robust for memory management
While this won't help fix things like the bug that r260219 addressed, it
seems like good tidy up to have anyway.
(it might be nice if "makeArrayRef" always produced a MutableArrayRef &
let it decay to an ArrayRef when needed - then I'd use that for the
MutableArrayRefs in this patch)
If we had std::dynarray I'd use that instead of unique_ptr+size_t,
ideally (but then it'd have to be threaded down through the Preprocessor
all the way - no idea how painful that would be)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260246 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseCXXInlineMethods.cpp')
-rw-r--r-- | lib/Parse/ParseCXXInlineMethods.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index e536644d5b..89ef35c88b 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -325,7 +325,7 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) { // Parse the default argument from its saved token stream. Toks->push_back(Tok); // So that the current token doesn't get lost - PP.EnterTokenStream(&Toks->front(), Toks->size(), true, false); + PP.EnterTokenStream(*Toks, true); // Consume the previously-pushed token. ConsumeAnyToken(); @@ -399,7 +399,7 @@ void Parser::ParseLexedMethodDeclaration(LateParsedMethodDeclaration &LM) { // Parse the default argument from its saved token stream. Toks->push_back(Tok); // So that the current token doesn't get lost - PP.EnterTokenStream(&Toks->front(), Toks->size(), true, false); + PP.EnterTokenStream(*Toks, true); // Consume the previously-pushed token. ConsumeAnyToken(); @@ -504,7 +504,7 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) { // Append the current token at the end of the new token stream so that it // doesn't get lost. LM.Toks.push_back(Tok); - PP.EnterTokenStream(LM.Toks.data(), LM.Toks.size(), true, false); + PP.EnterTokenStream(LM.Toks, true); // Consume the previously pushed token. ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true); @@ -617,7 +617,7 @@ void Parser::ParseLexedMemberInitializer(LateParsedMemberInitializer &MI) { // Append the current token at the end of the new token stream so that it // doesn't get lost. MI.Toks.push_back(Tok); - PP.EnterTokenStream(MI.Toks.data(), MI.Toks.size(), true, false); + PP.EnterTokenStream(MI.Toks, true); // Consume the previously pushed token. ConsumeAnyToken(/*ConsumeCodeCompletionTok=*/true); @@ -971,10 +971,10 @@ public: // Put back the original tokens. Self.SkipUntil(EndKind, StopAtSemi | StopBeforeMatch); if (Toks.size()) { - Token *Buffer = new Token[Toks.size()]; - std::copy(Toks.begin() + 1, Toks.end(), Buffer); + auto Buffer = llvm::make_unique<Token[]>(Toks.size()); + std::copy(Toks.begin() + 1, Toks.end(), Buffer.get()); Buffer[Toks.size() - 1] = Self.Tok; - Self.PP.EnterTokenStream(Buffer, Toks.size(), true, /*Owned*/true); + Self.PP.EnterTokenStream(std::move(Buffer), Toks.size(), true); Self.Tok = Toks.front(); } |