From 2eabcc988f636cd98e9bb2c5c5e3ad5913e7267c Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 9 Feb 2016 18:52:09 +0000 Subject: 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) llvm-svn: 260246 --- clang/lib/Lex/Pragma.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'clang/lib/Lex/Pragma.cpp') diff --git a/clang/lib/Lex/Pragma.cpp b/clang/lib/Lex/Pragma.cpp index afb41a24077..fea66daa5f8 100644 --- a/clang/lib/Lex/Pragma.cpp +++ b/clang/lib/Lex/Pragma.cpp @@ -938,13 +938,13 @@ struct PragmaDebugHandler : public PragmaHandler { } SourceLocation NameLoc = Tok.getLocation(); - Token *Toks = PP.getPreprocessorAllocator().Allocate(1); - Toks->startToken(); - Toks->setKind(tok::annot_pragma_captured); - Toks->setLocation(NameLoc); + MutableArrayRef Toks( + PP.getPreprocessorAllocator().Allocate(1), 1); + Toks[0].startToken(); + Toks[0].setKind(tok::annot_pragma_captured); + Toks[0].setLocation(NameLoc); - PP.EnterTokenStream(Toks, 1, /*DisableMacroExpansion=*/true, - /*OwnsTokens=*/false); + PP.EnterTokenStream(Toks, /*DisableMacroExpansion=*/true); } // Disable MSVC warning about runtime stack overflow. -- cgit v1.2.3