Author: Kazu Hirata Date: 2024-06-29T16:12:18-07:00 New Revision: eb5dbaf8d013839a66691e954a58d22a41f3c027
URL: https://github.com/llvm/llvm-project/commit/eb5dbaf8d013839a66691e954a58d22a41f3c027 DIFF: https://github.com/llvm/llvm-project/commit/eb5dbaf8d013839a66691e954a58d22a41f3c027.diff LOG: [clang] Use std::make_unique (NFC) (#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. Added: Modified: clang/lib/CodeGen/CGCoroutine.cpp clang/lib/Interpreter/CodeCompletion.cpp Removed: ################################################################################ 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits