[clang] [clang] Use std::make_unique (NFC) (PR #97176)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 29 12:04:48 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97176
This patch is based on clang-tidy's modernize-make-unique but limited
to those cases where type names are mentioned twice like
std::unique_ptr<Type>(new Type()), which is a bit mouthful.
>From 84e939e920af0c54092362d854850be2c6dd2897 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 29 Jun 2024 06:28:42 -0700
Subject: [PATCH] [clang] Use std::make_unique (NFC)
This patch is based on clang-tidy's modernize-make-unique but limited
to those cases where type names are mentioned twice like
std::unique_ptr<Type>(new Type()), which is a bit mouthful.
---
clang/lib/CodeGen/CGCoroutine.cpp | 2 +-
clang/lib/Interpreter/CodeCompletion.cpp | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/clang/lib/CodeGen/CGCoroutine.cpp b/clang/lib/CodeGen/CGCoroutine.cpp
index b4c724422c14a..a8a70186c2c5a 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -103,7 +103,7 @@ static void createCoroData(CodeGenFunction &CGF,
return;
}
- CurCoro.Data = std::unique_ptr<CGCoroData>(new CGCoroData);
+ CurCoro.Data = std::make_unique<CGCoroData>();
CurCoro.Data->CoroId = CoroId;
CurCoro.Data->CoroIdExpr = CoroIdExpr;
}
diff --git a/clang/lib/Interpreter/CodeCompletion.cpp b/clang/lib/Interpreter/CodeCompletion.cpp
index 25183ae9eeb99..791426807cb91 100644
--- a/clang/lib/Interpreter/CodeCompletion.cpp
+++ b/clang/lib/Interpreter/CodeCompletion.cpp
@@ -368,8 +368,7 @@ void ReplCodeCompleter::codeComplete(CompilerInstance *InterpCI,
llvm::SmallVector<const llvm::MemoryBuffer *, 1> tb = {};
InterpCI->getFrontendOpts().Inputs[0] = FrontendInputFile(
CodeCompletionFileName, Language::CXX, InputKind::Source);
- auto Act = std::unique_ptr<IncrementalSyntaxOnlyAction>(
- new IncrementalSyntaxOnlyAction(ParentCI));
+ auto Act = std::make_unique<IncrementalSyntaxOnlyAction>(ParentCI);
std::unique_ptr<llvm::MemoryBuffer> MB =
llvm::MemoryBuffer::getMemBufferCopy(Content, CodeCompletionFileName);
llvm::SmallVector<ASTUnit::RemappedFile, 4> RemappedFiles;
More information about the cfe-commits
mailing list