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 | 2eabcc988f636cd98e9bb2c5c5e3ad5913e7267c (patch) | |
tree | 5155a49f343e8e5b3726ffadc53f2165d4acf64c /clang/lib/Frontend/PrintPreprocessedOutput.cpp | |
parent | cb1175c7db87175ce4231555ad9eb75b762bb0d1 (diff) | |
download | bcm5719-llvm-2eabcc988f636cd98e9bb2c5c5e3ad5913e7267c.tar.gz bcm5719-llvm-2eabcc988f636cd98e9bb2c5c5e3ad5913e7267c.zip |
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
Diffstat (limited to 'clang/lib/Frontend/PrintPreprocessedOutput.cpp')
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index eee9da8594b..8a90b56ff36 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -580,11 +580,10 @@ struct UnknownPragmaHandler : public PragmaHandler { if (ShouldExpandTokens) { // The first token does not have expanded macros. Expand them, if // required. - Token *Toks = new Token[1]; + auto Toks = llvm::make_unique<Token[]>(1); Toks[0] = PragmaTok; - PP.EnterTokenStream(Toks, /*NumToks=*/1, - /*DisableMacroExpansion=*/false, - /*OwnsTokens=*/true); + PP.EnterTokenStream(std::move(Toks), /*NumToks=*/1, + /*DisableMacroExpansion=*/false); PP.Lex(PragmaTok); } Token PrevToken; |