diff --git a/llvm/include/llvm/BinaryFormat/MsgPackDocument.h b/llvm/include/llvm/BinaryFormat/MsgPackDocument.h index 09091264cac2d..183d055ff2b81 100644 --- a/llvm/include/llvm/BinaryFormat/MsgPackDocument.h +++ b/llvm/include/llvm/BinaryFormat/MsgPackDocument.h @@ -437,7 +437,7 @@ class Document { /// Copy a string into the Document's strings list, and return the copy that /// is owned by the Document. StringRef addString(StringRef S) { - Strings.push_back(std::unique_ptr(new char[S.size()])); + Strings.push_back(std::make_unique(S.size())); memcpy(&Strings.back()[0], S.data(), S.size()); return StringRef(&Strings.back()[0], S.size()); } diff --git a/llvm/include/llvm/CodeGen/RegAllocPBQP.h b/llvm/include/llvm/CodeGen/RegAllocPBQP.h index 234f1c6ff115a..7bd8216c79c0e 100644 --- a/llvm/include/llvm/CodeGen/RegAllocPBQP.h +++ b/llvm/include/llvm/CodeGen/RegAllocPBQP.h @@ -210,7 +210,7 @@ class NodeMetadata { void setup(const Vector& Costs) { NumOpts = Costs.getLength() - 1; - OptUnsafeEdges = std::unique_ptr(new unsigned[NumOpts]()); + OptUnsafeEdges = std::make_unique(NumOpts); } ReductionState getReductionState() const { return RS; } diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h index f55022fbff07c..39c6c8ab48335 100644 --- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h +++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h @@ -474,9 +474,7 @@ createFunctionToLoopPassAdaptor(LoopNestPassT &&Pass, bool UseMemorySSA = false, LoopStandardAnalysisResults &, LPMUpdater &>; // Do not use make_unique, it causes too many template instantiations, // causing terrible compile times. - return FunctionToLoopPassAdaptor( - std::unique_ptr( - new PassModelT(std::move(LPM))), + return FunctionToLoopPassAdaptor(std::make_unique(std::move(LPM)), UseMemorySSA, UseBlockFrequencyInfo, UseBranchProbabilityInfo, true); } @@ -495,9 +493,7 @@ createFunctionToLoopPassAdaptor( bool LoopNestMode = (LPM.getNumLoopPasses() == 0); // Do not use make_unique, it causes too many template instantiations, // causing terrible compile times. - return FunctionToLoopPassAdaptor( - std::unique_ptr( - new PassModelT(std::move(LPM))), + return FunctionToLoopPassAdaptor(std::make_unique(std::move(LPM)), UseMemorySSA, UseBlockFrequencyInfo, UseBranchProbabilityInfo, LoopNestMode); } diff --git a/llvm/lib/CodeGen/DetectDeadLanes.cpp b/llvm/lib/CodeGen/DetectDeadLanes.cpp index 86e9f3abe010d..549a8db8a1b2d 100644 --- a/llvm/lib/CodeGen/DetectDeadLanes.cpp +++ b/llvm/lib/CodeGen/DetectDeadLanes.cpp @@ -42,7 +42,7 @@ DeadLaneDetector::DeadLaneDetector(const MachineRegisterInfo *MRI, const TargetRegisterInfo *TRI) : MRI(MRI), TRI(TRI) { unsigned NumVirtRegs = MRI->getNumVirtRegs(); - VRegInfos = std::unique_ptr(new VRegInfo[NumVirtRegs]); + VRegInfos = std::make_unique(NumVirtRegs); WorklistMembers.resize(NumVirtRegs); DefinedByCopy.resize(NumVirtRegs); } diff --git a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp index f1fec547ebd60..3c808cc8f4a5c 100644 --- a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp @@ -215,8 +215,7 @@ bool RegBankSelect::repairReg( // TODO: // Check if MI is legal. if not, we need to legalize all the // instructions we are going to insert. - std::unique_ptr NewInstrs( - new MachineInstr *[RepairPt.getNumInsertPoints()]); + auto NewInstrs = std::make_unique(RepairPt.getNumInsertPoints()); bool IsFirst = true; unsigned Idx = 0; for (const std::unique_ptr &InsertPt : RepairPt) { diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp index 8571ca632f52b..6d2d73e175261 100644 --- a/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/NativeExeSymbol.cpp @@ -36,7 +36,7 @@ std::unique_ptr NativeExeSymbol::findChildren(PDB_SymType Type) const { switch (Type) { case PDB_SymType::Compiland: { - return std::unique_ptr(new NativeEnumModules(Session)); + return std::make_unique(Session); break; } case PDB_SymType::ArrayType: diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp index 7db3f1c631288..4819409640a38 100644 --- a/llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/NativeTypeFunctionSig.cpp @@ -138,8 +138,7 @@ NativeTypeFunctionSig::findChildren(PDB_SymType Type) const { auto NET = std::make_unique(Session, /* copy */ ArgList.ArgIndices); - return std::unique_ptr( - new NativeEnumFunctionArgs(Session, std::move(NET))); + return std::make_unique(Session, std::move(NET)); } SymIndexId NativeTypeFunctionSig::getClassParentId() const { diff --git a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp index 95b95a5bbc509..e531b8adea60d 100644 --- a/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp +++ b/llvm/lib/DebugInfo/PDB/Native/SymbolCache.cpp @@ -98,8 +98,7 @@ SymbolCache::createTypeEnumerator(std::vector Kinds) { return nullptr; } auto &Types = Tpi->typeCollection(); - return std::unique_ptr( - new NativeEnumTypes(Session, Types, std::move(Kinds))); + return std::make_unique(Session, Types, std::move(Kinds)); } std::unique_ptr diff --git a/llvm/lib/InterfaceStub/IFSHandler.cpp b/llvm/lib/InterfaceStub/IFSHandler.cpp index e80a59a572d88..6ff406980d556 100644 --- a/llvm/lib/InterfaceStub/IFSHandler.cpp +++ b/llvm/lib/InterfaceStub/IFSHandler.cpp @@ -178,7 +178,7 @@ bool usesTriple(StringRef Buf) { Expected> ifs::readIFSFromBuffer(StringRef Buf) { yaml::Input YamlIn(Buf); - std::unique_ptr Stub(new IFSStubTriple()); + auto Stub = std::make_unique(); if (usesTriple(Buf)) { YamlIn >> *Stub; } else { diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 8a2dddce4892c..aa85e6b096424 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -275,8 +275,7 @@ static void runNewPMPasses(const Config &Conf, Module &Mod, TargetMachine *TM, RegisterPassPlugins(Conf.PassPlugins, PB); - std::unique_ptr TLII( - new TargetLibraryInfoImpl(Triple(TM->getTargetTriple()))); + auto TLII = std::make_unique (Triple(TM->getTargetTriple())); if (Conf.Freestanding) TLII->disableAllFunctions(); FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 189f2876b61c0..9821594a08994 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -251,8 +251,7 @@ static void optimizeModule(Module &TheModule, TargetMachine &TM, PTO.SLPVectorization = true; PassBuilder PB(&TM, PTO, PGOOpt, &PIC); - std::unique_ptr TLII( - new TargetLibraryInfoImpl(Triple(TM.getTargetTriple()))); + auto TLII = std::make_unique(Triple(TM.getTargetTriple())); if (Freestanding) TLII->disableAllFunctions(); FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); diff --git a/llvm/lib/MC/MCDisassembler/Disassembler.cpp b/llvm/lib/MC/MCDisassembler/Disassembler.cpp index 684413e1e3a53..f9b13a6d8bc83 100644 --- a/llvm/lib/MC/MCDisassembler/Disassembler.cpp +++ b/llvm/lib/MC/MCDisassembler/Disassembler.cpp @@ -72,8 +72,8 @@ LLVMCreateDisasmCPUFeatures(const char *TT, const char *CPU, return nullptr; // Set up the MCContext for creating symbols and MCExpr's. - std::unique_ptr Ctx( - new MCContext(Triple(TT), MAI.get(), MRI.get(), STI.get())); + auto Ctx = std::make_unique( + Triple(TT), MAI.get(), MRI.get(), STI.get()); if (!Ctx) return nullptr; diff --git a/llvm/lib/Object/GOFFObjectFile.cpp b/llvm/lib/Object/GOFFObjectFile.cpp index db1e7e704f62e..02f09525465aa 100644 --- a/llvm/lib/Object/GOFFObjectFile.cpp +++ b/llvm/lib/Object/GOFFObjectFile.cpp @@ -27,7 +27,7 @@ using namespace llvm; Expected> ObjectFile::createGOFFObjectFile(MemoryBufferRef Object) { Error Err = Error::success(); - std::unique_ptr Ret(new GOFFObjectFile(Object, Err)); + auto Ret = std::make_unique(Object, Err); if (Err) return std::move(Err); return std::move(Ret); diff --git a/llvm/lib/Object/MachOUniversal.cpp b/llvm/lib/Object/MachOUniversal.cpp index 31bb2a619ff33..0094d4b2fa8f0 100644 --- a/llvm/lib/Object/MachOUniversal.cpp +++ b/llvm/lib/Object/MachOUniversal.cpp @@ -121,8 +121,7 @@ void MachOUniversalBinary::anchor() { } Expected> MachOUniversalBinary::create(MemoryBufferRef Source) { Error Err = Error::success(); - std::unique_ptr Ret( - new MachOUniversalBinary(Source, Err)); + auto Ret = std::make_unique(Source, Err); if (Err) return std::move(Err); return std::move(Ret); diff --git a/llvm/lib/Object/SymbolicFile.cpp b/llvm/lib/Object/SymbolicFile.cpp index e87ecb1491090..49f94391ec2f3 100644 --- a/llvm/lib/Object/SymbolicFile.cpp +++ b/llvm/lib/Object/SymbolicFile.cpp @@ -70,7 +70,7 @@ SymbolicFile::createSymbolicFile(MemoryBufferRef Object, file_magic Type, case file_magic::wasm_object: return ObjectFile::createObjectFile(Object, Type, InitContent); case file_magic::coff_import_library: - return std::unique_ptr(new COFFImportFile(Object)); + return std::make_unique(Object); case file_magic::elf_relocatable: case file_magic::macho_object: case file_magic::coff_object: { diff --git a/llvm/lib/Object/TapiUniversal.cpp b/llvm/lib/Object/TapiUniversal.cpp index 74e0c519ddfdb..3614a57caaf66 100644 --- a/llvm/lib/Object/TapiUniversal.cpp +++ b/llvm/lib/Object/TapiUniversal.cpp @@ -53,7 +53,7 @@ TapiUniversal::ObjectForArch::getAsObjectFile() const { Expected> TapiUniversal::create(MemoryBufferRef Source) { Error Err = Error::success(); - std::unique_ptr Ret(new TapiUniversal(Source, Err)); + auto Ret = std::make_unique(Source, Err); if (Err) return std::move(Err); return std::move(Ret); diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp index e489282281d26..785141b4d505d 100644 --- a/llvm/lib/Support/VirtualFileSystem.cpp +++ b/llvm/lib/Support/VirtualFileSystem.cpp @@ -1093,8 +1093,7 @@ InMemoryFileSystem::openFileForRead(const Twine &Path) { // When we have a file provide a heap-allocated wrapper for the memory buffer // to match the ownership semantics for File. if (auto *F = dyn_cast(*Node)) - return std::unique_ptr( - new detail::InMemoryFileAdaptor(*F, Path.str())); + return std::make_unique(*F, Path.str()); // FIXME: errc::not_a_file? return make_error_code(llvm::errc::invalid_argument); diff --git a/llvm/lib/Target/SPIRV/SPIRVAPI.cpp b/llvm/lib/Target/SPIRV/SPIRVAPI.cpp index 95c9b0e520060..8fbe445a663ec 100644 --- a/llvm/lib/Target/SPIRV/SPIRVAPI.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVAPI.cpp @@ -158,8 +158,7 @@ SPIRVTranslateModule(Module *M, std::string &SpirvObj, std::string &ErrMsg, TargetLibraryInfoImpl TLII(Triple(M->getTargetTriple())); legacy::PassManager PM; PM.add(new TargetLibraryInfoWrapperPass(TLII)); - std::unique_ptr MMIWP( - new MachineModuleInfoWrapperPass(Target.get())); + auto MMIWP = std::make_unique(Target.get()); const_cast(Target->getObjFileLowering()) ->Initialize(MMIWP.get()->getMMI().getContext(), *Target); diff --git a/llvm/lib/TextAPI/InterfaceFile.cpp b/llvm/lib/TextAPI/InterfaceFile.cpp index ce2feb65c9ec9..0e4980fc0bc8e 100644 --- a/llvm/lib/TextAPI/InterfaceFile.cpp +++ b/llvm/lib/TextAPI/InterfaceFile.cpp @@ -310,7 +310,7 @@ InterfaceFile::extract(Architecture Arch) const { inconvertibleErrorCode()); } - std::unique_ptr IF(new InterfaceFile()); + auto IF = std::make_unique(); IF->setFileType(getFileType()); IF->setPath(getPath()); IF->addTargets(targets(Arch)); diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp index d8e36de59bcb4..4615c76ba6aa1 100644 --- a/llvm/tools/llvm-as/llvm-as.cpp +++ b/llvm/tools/llvm-as/llvm-as.cpp @@ -82,8 +82,7 @@ static void WriteOutputFile(const Module *M, const ModuleSummaryIndex *Index) { } std::error_code EC; - std::unique_ptr Out( - new ToolOutputFile(OutputFilename, EC, sys::fs::OF_None)); + auto Out = std::make_unique(OutputFilename, EC, sys::fs::OF_None); if (EC) { errs() << EC.message() << '\n'; exit(1); diff --git a/llvm/tools/llvm-dis/llvm-dis.cpp b/llvm/tools/llvm-dis/llvm-dis.cpp index 49acc9cd456ff..40c71868b39ed 100644 --- a/llvm/tools/llvm-dis/llvm-dis.cpp +++ b/llvm/tools/llvm-dis/llvm-dis.cpp @@ -262,8 +262,8 @@ int main(int argc, char **argv) { } std::error_code EC; - std::unique_ptr Out( - new ToolOutputFile(FinalFilename, EC, sys::fs::OF_TextWithCRLF)); + auto Out = std::make_unique( + FinalFilename, EC, sys::fs::OF_TextWithCRLF); if (EC) { errs() << EC.message() << '\n'; return 1; diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp index 0f4a4d57427a5..95623a457b03a 100644 --- a/llvm/tools/llvm-link/llvm-link.cpp +++ b/llvm/tools/llvm-link/llvm-link.cpp @@ -176,7 +176,7 @@ static std::unique_ptr loadFile(const char *argv0, static std::unique_ptr loadArFile(const char *Argv0, std::unique_ptr Buffer, LLVMContext &Context) { - std::unique_ptr Result(new Module("ArchiveModule", Context)); + auto Result = std::make_unique("ArchiveModule", Context); StringRef ArchiveName = Buffer->getBufferIdentifier(); if (Verbose) errs() << "Reading library archive file '" << ArchiveName diff --git a/llvm/tools/llvm-modextract/llvm-modextract.cpp b/llvm/tools/llvm-modextract/llvm-modextract.cpp index 50f503ae0ac4c..384260a26716d 100644 --- a/llvm/tools/llvm-modextract/llvm-modextract.cpp +++ b/llvm/tools/llvm-modextract/llvm-modextract.cpp @@ -63,8 +63,7 @@ int main(int argc, char **argv) { } std::error_code EC; - std::unique_ptr Out( - new ToolOutputFile(OutputFilename, EC, sys::fs::OF_None)); + auto Out = std::make_unique(OutputFilename, EC, sys::fs::OF_None); ExitOnErr(errorCodeToError(EC)); if (BinaryExtract) { diff --git a/llvm/tools/llvm-sim/llvm-sim.cpp b/llvm/tools/llvm-sim/llvm-sim.cpp index d09e51561253a..abd9591824401 100644 --- a/llvm/tools/llvm-sim/llvm-sim.cpp +++ b/llvm/tools/llvm-sim/llvm-sim.cpp @@ -63,8 +63,7 @@ exportToFile(const StringRef FilePath, const SimilarityGroupList &SimSections, const DenseMap &LLVMInstNum) { std::error_code EC; - std::unique_ptr Out( - new ToolOutputFile(FilePath, EC, sys::fs::OF_None)); + auto Out = std::make_unique(FilePath, EC, sys::fs::OF_None); if (EC) return EC; diff --git a/llvm/tools/llvm-split/llvm-split.cpp b/llvm/tools/llvm-split/llvm-split.cpp index 1b1f97f44e274..4d46e2f0521b4 100644 --- a/llvm/tools/llvm-split/llvm-split.cpp +++ b/llvm/tools/llvm-split/llvm-split.cpp @@ -105,8 +105,7 @@ int main(int argc, char **argv) { unsigned I = 0; const auto HandleModulePart = [&](std::unique_ptr MPart) { std::error_code EC; - std::unique_ptr Out( - new ToolOutputFile(OutputFilename + utostr(I++), EC, sys::fs::OF_None)); + auto Out = std::make_unique(OutputFilename + utostr(I++), EC, sys::fs::OF_None); if (EC) { errs() << EC.message() << '\n'; exit(1); diff --git a/llvm/tools/obj2yaml/obj2yaml.cpp b/llvm/tools/obj2yaml/obj2yaml.cpp index 63c8cc55ee2d4..4168160e28e2e 100644 --- a/llvm/tools/obj2yaml/obj2yaml.cpp +++ b/llvm/tools/obj2yaml/obj2yaml.cpp @@ -107,8 +107,7 @@ int main(int argc, char *argv[]) { nullptr, /*LongOptionsUseDoubleDash=*/true); std::error_code EC; - std::unique_ptr Out( - new ToolOutputFile(OutputFilename, EC, sys::fs::OF_Text)); + auto Out = std::make_unique(OutputFilename, EC, sys::fs::OF_Text); if (EC) { WithColor::error(errs(), "obj2yaml") << "failed to open '" + OutputFilename + "': " + EC.message() << '\n'; diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index 4a060e1aad427..39aff22dc6e8f 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -122,8 +122,7 @@ int main(int argc, char **argv) { }; std::error_code EC; - std::unique_ptr Out( - new ToolOutputFile(OutputFilename, EC, sys::fs::OF_None)); + auto Out = std::make_unique(OutputFilename, EC, sys::fs::OF_None); if (EC) { ErrHandler("failed to open '" + OutputFilename + "': " + EC.message()); return 1;