summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Lex')
-rw-r--r--clang/lib/Lex/PPDirectives.cpp8
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp11
-rw-r--r--clang/lib/Lex/Pragma.cpp12
3 files changed, 15 insertions, 16 deletions
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index c02a0cb8d30..1c74a1702a7 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -907,7 +907,7 @@ void Preprocessor::HandleDirective(Token &Result) {
// various pseudo-ops. Just return the # token and push back the following
// token to be lexed next time.
if (getLangOpts().AsmPreprocessor) {
- Token *Toks = new Token[2];
+ auto Toks = llvm::make_unique<Token[]>(2);
// Return the # and the token after it.
Toks[0] = SavedHash;
Toks[1] = Result;
@@ -920,7 +920,7 @@ void Preprocessor::HandleDirective(Token &Result) {
// Enter this token stream so that we re-lex the tokens. Make sure to
// enable macro expansion, in case the token after the # is an identifier
// that is expanded.
- EnterTokenStream(Toks, 2, false, true);
+ EnterTokenStream(std::move(Toks), 2, false);
return;
}
@@ -1442,13 +1442,13 @@ static void EnterAnnotationToken(Preprocessor &PP,
tok::TokenKind Kind, void *AnnotationVal) {
// FIXME: Produce this as the current token directly, rather than
// allocating a new token for it.
- Token *Tok = new Token[1];
+ auto Tok = llvm::make_unique<Token[]>(1);
Tok[0].startToken();
Tok[0].setKind(Kind);
Tok[0].setLocation(Begin);
Tok[0].setAnnotationEndLoc(End);
Tok[0].setAnnotationValue(AnnotationVal);
- PP.EnterTokenStream(Tok, 1, true, true);
+ PP.EnterTokenStream(std::move(Tok), 1, true);
}
/// \brief Produce a diagnostic informing the user that a #include or similar
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 11b4a0b3d8c..69f5bc8ddcc 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -755,13 +755,12 @@ MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(Token &MacroName,
// Do not lose the EOF/EOD. Return it to the client.
MacroName = Tok;
return nullptr;
- } else {
- // Do not lose the EOF/EOD.
- Token *Toks = new Token[1];
- Toks[0] = Tok;
- EnterTokenStream(Toks, 1, true, true);
- break;
}
+ // Do not lose the EOF/EOD.
+ auto Toks = llvm::make_unique<Token[]>(1);
+ Toks[0] = Tok;
+ EnterTokenStream(std::move(Toks), 1, true);
+ break;
} else if (Tok.is(tok::r_paren)) {
// If we found the ) token, the macro arg list is done.
if (NumParens-- == 0) {
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<Token>(1);
- Toks->startToken();
- Toks->setKind(tok::annot_pragma_captured);
- Toks->setLocation(NameLoc);
+ MutableArrayRef<Token> Toks(
+ PP.getPreprocessorAllocator().Allocate<Token>(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.
OpenPOWER on IntegriCloud