From f4ccd110750a3f3fe6a107d5c74c649c2a0dc407 Mon Sep 17 00:00:00 2001 From: Ahmed Charles Date: Thu, 6 Mar 2014 05:51:42 +0000 Subject: Replace OwningPtr with std::unique_ptr. This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203083 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/MemoryDependenceAnalysis.cpp | 2 +- lib/AsmParser/Parser.cpp | 5 ++-- lib/Bitcode/Reader/BitcodeReader.h | 2 +- lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp | 12 ++++----- lib/CodeGen/AsmPrinter/DwarfUnit.h | 3 +-- lib/CodeGen/LLVMTargetMachine.cpp | 5 ++-- lib/CodeGen/LiveRegMatrix.cpp | 2 +- lib/CodeGen/MachineScheduler.cpp | 5 ++-- lib/CodeGen/RegAllocBase.h | 1 - lib/CodeGen/RegAllocBasic.cpp | 2 +- lib/CodeGen/RegAllocGreedy.cpp | 6 ++--- lib/CodeGen/RegAllocPBQP.cpp | 24 ++++++++--------- lib/CodeGen/RegisterCoalescer.cpp | 1 - lib/CodeGen/TailDuplication.cpp | 3 +-- lib/DebugInfo/DWARFContext.cpp | 10 ++++---- lib/DebugInfo/DWARFContext.h | 13 +++++----- lib/DebugInfo/DWARFUnit.h | 7 +++-- lib/ExecutionEngine/ExecutionEngine.cpp | 2 +- .../IntelJITEvents/IntelJITEventListener.cpp | 3 +-- lib/ExecutionEngine/JIT/JITEmitter.cpp | 1 - lib/ExecutionEngine/MCJIT/MCJIT.cpp | 10 ++++---- lib/ExecutionEngine/MCJIT/MCJIT.h | 2 +- .../OProfileJIT/OProfileJITEventListener.cpp | 4 +-- lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp | 2 +- lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp | 1 - .../RuntimeDyld/RuntimeDyldMachO.cpp | 1 - lib/IR/AsmWriter.h | 3 +-- lib/IR/Core.cpp | 4 +-- lib/IR/GCOV.cpp | 3 +-- lib/IR/Module.cpp | 2 +- lib/IRReader/IRReader.cpp | 5 ++-- lib/LTO/LTOCodeGenerator.cpp | 2 +- lib/LTO/LTOModule.cpp | 30 ++++++++++------------ lib/MC/ELFObjectWriter.cpp | 3 +-- lib/MC/MCAsmStreamer.cpp | 7 +++-- lib/MC/MCDisassembler.cpp | 26 +++++++------------ lib/MC/MCDisassembler/Disassembler.cpp | 9 +++---- lib/MC/MCDisassembler/Disassembler.h | 17 ++++++------ lib/MC/MCExternalSymbolizer.cpp | 2 +- lib/MC/MCModuleYAML.cpp | 2 +- lib/MC/MCObjectSymbolizer.cpp | 30 ++++++++++------------ lib/MC/MCSymbolizer.cpp | 6 ++--- lib/MC/WinCOFFObjectWriter.cpp | 3 +-- lib/Object/Binary.cpp | 4 +-- lib/Object/COFFObjectFile.cpp | 3 ++- lib/Object/ELFObjectFile.cpp | 2 +- lib/Object/IRObjectFile.cpp | 2 +- lib/Object/MachOObjectFile.cpp | 2 +- lib/Object/MachOUniversal.cpp | 10 ++++---- lib/Object/ObjectFile.cpp | 3 +-- lib/Support/CommandLine.cpp | 3 +-- lib/Support/Compression.cpp | 13 +++++----- lib/Support/FileUtilities.cpp | 5 ++-- lib/Support/LockFileManager.cpp | 2 +- lib/Support/SourceMgr.cpp | 3 +-- lib/Support/StringRef.cpp | 1 - lib/Support/Timer.cpp | 1 - lib/Support/Windows/Program.inc | 3 +-- lib/Support/YAMLParser.cpp | 14 ++++------ lib/TableGen/Main.cpp | 3 +-- .../Instrumentation/AddressSanitizer.cpp | 5 ++-- .../Instrumentation/DataFlowSanitizer.cpp | 2 +- lib/Transforms/Instrumentation/DebugIR.cpp | 12 ++++----- lib/Transforms/Instrumentation/DebugIR.h | 5 ++-- lib/Transforms/Instrumentation/GCOVProfiling.cpp | 2 +- lib/Transforms/Instrumentation/MemorySanitizer.cpp | 4 +-- lib/Transforms/Instrumentation/ThreadSanitizer.cpp | 2 +- lib/Transforms/Scalar/SampleProfile.cpp | 7 +++-- lib/Transforms/Utils/SpecialCaseList.cpp | 5 ++-- 69 files changed, 174 insertions(+), 227 deletions(-) (limited to 'lib') diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp index 29c8513cab..015ded18d9 100644 --- a/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -59,7 +59,7 @@ INITIALIZE_PASS_END(MemoryDependenceAnalysis, "memdep", "Memory Dependence Analysis", false, true) MemoryDependenceAnalysis::MemoryDependenceAnalysis() -: FunctionPass(ID), PredCache(0) { + : FunctionPass(ID), PredCache() { initializeMemoryDependenceAnalysisPass(*PassRegistry::getPassRegistry()); } MemoryDependenceAnalysis::~MemoryDependenceAnalysis() { diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index 67e9c256eb..a1da5e1163 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -13,7 +13,6 @@ #include "llvm/AsmParser/Parser.h" #include "LLParser.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/IR/Module.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SourceMgr.h" @@ -34,7 +33,7 @@ Module *llvm::ParseAssembly(MemoryBuffer *F, return LLParser(F, SM, Err, M).Run() ? 0 : M; // Otherwise create a new module. - OwningPtr M2(new Module(F->getBufferIdentifier(), Context)); + std::unique_ptr M2(new Module(F->getBufferIdentifier(), Context)); if (LLParser(F, SM, Err, M2.get()).Run()) return 0; return M2.release(); @@ -42,7 +41,7 @@ Module *llvm::ParseAssembly(MemoryBuffer *F, Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err, LLVMContext &Context) { - OwningPtr File; + std::unique_ptr File; if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { Err = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + ec.message()); diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h index 1337da1025..15be31f039 100644 --- a/lib/Bitcode/Reader/BitcodeReader.h +++ b/lib/Bitcode/Reader/BitcodeReader.h @@ -127,7 +127,7 @@ class BitcodeReader : public GVMaterializer { Module *TheModule; MemoryBuffer *Buffer; bool BufferOwned; - OwningPtr StreamFile; + std::unique_ptr StreamFile; BitstreamCursor Stream; DataStreamer *LazyStreamer; uint64_t NextUnreadBit; diff --git a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp index 27f009915e..567b6e3b18 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp @@ -13,7 +13,6 @@ #define DEBUG_TYPE "asm-printer" #include "llvm/CodeGen/AsmPrinter.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/CodeGen/MachineBasicBlock.h" @@ -118,16 +117,15 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode, // Tell SrcMgr about this buffer, it takes ownership of the buffer. SrcMgr.AddNewSourceBuffer(Buffer, SMLoc()); - OwningPtr Parser(createMCAsmParser(SrcMgr, - OutContext, OutStreamer, - *MAI)); + std::unique_ptr Parser( + createMCAsmParser(SrcMgr, OutContext, OutStreamer, *MAI)); // Initialize the parser with a fresh subtarget info. It is better to use a // new STI here because the parser may modify it and we do not want those // modifications to persist after parsing the inlineasm. The modifications // made by the parser will be seen by the code emitters because it passes // the current STI down to the EncodeInstruction() method. - OwningPtr STI(TM.getTarget().createMCSubtargetInfo( + std::unique_ptr STI(TM.getTarget().createMCSubtargetInfo( TM.getTargetTriple(), TM.getTargetCPU(), TM.getTargetFeatureString())); // Preserve a copy of the original STI because the parser may modify it. For @@ -136,8 +134,8 @@ void AsmPrinter::EmitInlineAsm(StringRef Str, const MDNode *LocMDNode, // emitInlineAsmEnd(). MCSubtargetInfo STIOrig = *STI; - OwningPtr - TAP(TM.getTarget().createMCAsmParser(*STI, *Parser, *MII)); + std::unique_ptr TAP( + TM.getTarget().createMCAsmParser(*STI, *Parser, *MII)); if (!TAP) report_fatal_error("Inline asm not supported by this streamer because" " we don't have an asm parser for this target\n"); diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h index 3a3f1660c9..937a607fa8 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h @@ -18,7 +18,6 @@ #include "DwarfDebug.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringMap.h" #include "llvm/IR/DIBuilder.h" #include "llvm/IR/DebugInfo.h" @@ -71,7 +70,7 @@ protected: DICompileUnit CUNode; /// Unit debug information entry. - const OwningPtr UnitDie; + const std::unique_ptr UnitDie; /// Offset of the UnitDie from beginning of debug info section. unsigned DebugInfoOffset; diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index e77acce74f..77f8377d9b 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/TargetMachine.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineFunctionAnalysis.h" #include "llvm/CodeGen/MachineModuleInfo.h" @@ -174,7 +173,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, const MCRegisterInfo &MRI = *getRegisterInfo(); const MCInstrInfo &MII = *getInstrInfo(); const MCSubtargetInfo &STI = getSubtarget(); - OwningPtr AsmStreamer; + std::unique_ptr AsmStreamer; switch (FileType) { case CGFT_AssemblyFile: { @@ -281,7 +280,7 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM, if (MCE == 0 || MAB == 0) return true; - OwningPtr AsmStreamer; + std::unique_ptr AsmStreamer; AsmStreamer.reset(getTarget().createMCObjectStreamer( getTargetTriple(), *Ctx, *MAB, Out, MCE, STI, hasMCRelaxAll(), hasMCNoExecStack())); diff --git a/lib/CodeGen/LiveRegMatrix.cpp b/lib/CodeGen/LiveRegMatrix.cpp index 7c94378663..7f797beec8 100644 --- a/lib/CodeGen/LiveRegMatrix.cpp +++ b/lib/CodeGen/LiveRegMatrix.cpp @@ -67,7 +67,7 @@ void LiveRegMatrix::releaseMemory() { Matrix[i].clear(); // No need to clear Queries here, since LiveIntervalUnion::Query doesn't // have anything important to clear and LiveRegMatrix's runOnFunction() - // does a OwningPtr::reset anyways. + // does a std::unique_ptr::reset anyways. } } diff --git a/lib/CodeGen/MachineScheduler.cpp b/lib/CodeGen/MachineScheduler.cpp index e8b8713d1e..06b64e2b72 100644 --- a/lib/CodeGen/MachineScheduler.cpp +++ b/lib/CodeGen/MachineScheduler.cpp @@ -15,7 +15,6 @@ #define DEBUG_TYPE "misched" #include "llvm/CodeGen/MachineScheduler.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/PriorityQueue.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" @@ -321,7 +320,7 @@ bool MachineScheduler::runOnMachineFunction(MachineFunction &mf) { // Instantiate the selected scheduler for this target, function, and // optimization level. - OwningPtr Scheduler(createMachineScheduler()); + std::unique_ptr Scheduler(createMachineScheduler()); scheduleRegions(*Scheduler); DEBUG(LIS->dump()); @@ -342,7 +341,7 @@ bool PostMachineScheduler::runOnMachineFunction(MachineFunction &mf) { // Instantiate the selected scheduler for this target, function, and // optimization level. - OwningPtr Scheduler(createPostMachineScheduler()); + std::unique_ptr Scheduler(createPostMachineScheduler()); scheduleRegions(*Scheduler); if (VerifyScheduling) diff --git a/lib/CodeGen/RegAllocBase.h b/lib/CodeGen/RegAllocBase.h index c17a8d96ef..68bd4b5b63 100644 --- a/lib/CodeGen/RegAllocBase.h +++ b/lib/CodeGen/RegAllocBase.h @@ -37,7 +37,6 @@ #ifndef LLVM_CODEGEN_REGALLOCBASE #define LLVM_CODEGEN_REGALLOCBASE -#include "llvm/ADT/OwningPtr.h" #include "llvm/CodeGen/LiveInterval.h" #include "llvm/CodeGen/RegisterClassInfo.h" diff --git a/lib/CodeGen/RegAllocBasic.cpp b/lib/CodeGen/RegAllocBasic.cpp index 6768e45c6c..fbb9b69cff 100644 --- a/lib/CodeGen/RegAllocBasic.cpp +++ b/lib/CodeGen/RegAllocBasic.cpp @@ -64,7 +64,7 @@ class RABasic : public MachineFunctionPass, public RegAllocBase MachineFunction *MF; // state - OwningPtr SpillerInstance; + std::unique_ptr SpillerInstance; std::priority_queue, CompSpillWeight> Queue; diff --git a/lib/CodeGen/RegAllocGreedy.cpp b/lib/CodeGen/RegAllocGreedy.cpp index b9cc2fec8d..1621faad97 100644 --- a/lib/CodeGen/RegAllocGreedy.cpp +++ b/lib/CodeGen/RegAllocGreedy.cpp @@ -101,7 +101,7 @@ class RAGreedy : public MachineFunctionPass, LiveDebugVariables *DebugVars; // state - OwningPtr SpillerInstance; + std::unique_ptr SpillerInstance; PQueue Queue; unsigned NextCascade; @@ -196,8 +196,8 @@ class RAGreedy : public MachineFunctionPass, }; // splitting state. - OwningPtr SA; - OwningPtr SE; + std::unique_ptr SA; + std::unique_ptr SE; /// Cached per-block interference maps InterferenceCache IntfCache; diff --git a/lib/CodeGen/RegAllocPBQP.cpp b/lib/CodeGen/RegAllocPBQP.cpp index c9588db738..0273ad09d2 100644 --- a/lib/CodeGen/RegAllocPBQP.cpp +++ b/lib/CodeGen/RegAllocPBQP.cpp @@ -34,7 +34,6 @@ #include "llvm/CodeGen/RegAllocPBQP.h" #include "RegisterCoalescer.h" #include "Spiller.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/CodeGen/CalcSpillWeights.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" @@ -88,7 +87,7 @@ public: static char ID; /// Construct a PBQP register allocator. - RegAllocPBQP(OwningPtr &b, char *cPassID=0) + RegAllocPBQP(std::unique_ptr &b, char *cPassID=0) : MachineFunctionPass(ID), builder(b.release()), customPassID(cPassID) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); initializeLiveIntervalsPass(*PassRegistry::getPassRegistry()); @@ -117,8 +116,7 @@ private: typedef std::map CoalesceMap; typedef std::set RegSet; - - OwningPtr builder; + std::unique_ptr builder; char *customPassID; @@ -129,7 +127,7 @@ private: MachineRegisterInfo *mri; const MachineBlockFrequencyInfo *mbfi; - OwningPtr spiller; + std::unique_ptr spiller; LiveIntervals *lis; LiveStacks *lss; VirtRegMap *vrm; @@ -191,7 +189,7 @@ PBQPRAProblem *PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis, MachineRegisterInfo *mri = &mf->getRegInfo(); const TargetRegisterInfo *tri = mf->getTarget().getRegisterInfo(); - OwningPtr p(new PBQPRAProblem()); + std::unique_ptr p(new PBQPRAProblem()); PBQPRAGraph &g = p->getGraph(); RegSet pregs; @@ -314,7 +312,7 @@ PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf, const MachineBlockFrequencyInfo *mbfi, const RegSet &vregs) { - OwningPtr p(PBQPBuilder::build(mf, lis, mbfi, vregs)); + std::unique_ptr p(PBQPBuilder::build(mf, lis, mbfi, vregs)); PBQPRAGraph &g = p->getGraph(); const TargetMachine &tm = mf->getTarget(); @@ -587,8 +585,8 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { while (!pbqpAllocComplete) { DEBUG(dbgs() << " PBQP Regalloc round " << round << ":\n"); - OwningPtr problem( - builder->build(mf, lis, mbfi, vregsToAlloc)); + std::unique_ptr problem( + builder->build(mf, lis, mbfi, vregsToAlloc)); #ifndef NDEBUG if (pbqpDumpGraphs) { @@ -622,14 +620,14 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { return true; } -FunctionPass* llvm::createPBQPRegisterAllocator( - OwningPtr &builder, - char *customPassID) { +FunctionPass * +llvm::createPBQPRegisterAllocator(std::unique_ptr &builder, + char *customPassID) { return new RegAllocPBQP(builder, customPassID); } FunctionPass* llvm::createDefaultPBQPRegisterAllocator() { - OwningPtr Builder; + std::unique_ptr Builder; if (pbqpCoalescing) Builder.reset(new PBQPBuilderWithCoalescing()); else diff --git a/lib/CodeGen/RegisterCoalescer.cpp b/lib/CodeGen/RegisterCoalescer.cpp index cbec942273..43a841ad69 100644 --- a/lib/CodeGen/RegisterCoalescer.cpp +++ b/lib/CodeGen/RegisterCoalescer.cpp @@ -15,7 +15,6 @@ #define DEBUG_TYPE "regalloc" #include "RegisterCoalescer.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" diff --git a/lib/CodeGen/TailDuplication.cpp b/lib/CodeGen/TailDuplication.cpp index c493171a8c..df0e52926c 100644 --- a/lib/CodeGen/TailDuplication.cpp +++ b/lib/CodeGen/TailDuplication.cpp @@ -15,7 +15,6 @@ #define DEBUG_TYPE "tailduplication" #include "llvm/CodeGen/Passes.h" #include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" @@ -65,7 +64,7 @@ namespace { const MachineBranchProbabilityInfo *MBPI; MachineModuleInfo *MMI; MachineRegisterInfo *MRI; - OwningPtr RS; + std::unique_ptr RS; bool PreRegAlloc; // SSAUpdateVRs - A list of virtual registers for which to update SSA form. diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index 5cce8df521..37e86bd92d 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/lib/DebugInfo/DWARFContext.cpp @@ -301,7 +301,7 @@ void DWARFContext::parseCompileUnits() { const DataExtractor &DIData = DataExtractor(getInfoSection().Data, isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - OwningPtr CU(new DWARFCompileUnit( + std::unique_ptr CU(new DWARFCompileUnit( getDebugAbbrev(), getInfoSection().Data, getAbbrevSection(), getRangeSection(), getStringSection(), StringRef(), getAddrSection(), &getInfoSection().Relocs, isLittleEndian())); @@ -321,7 +321,7 @@ void DWARFContext::parseTypeUnits() { const DataExtractor &DIData = DataExtractor(I->second.Data, isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - OwningPtr TU(new DWARFTypeUnit( + std::unique_ptr TU(new DWARFTypeUnit( getDebugAbbrev(), I->second.Data, getAbbrevSection(), getRangeSection(), getStringSection(), StringRef(), getAddrSection(), &I->second.Relocs, isLittleEndian())); @@ -338,7 +338,7 @@ void DWARFContext::parseDWOCompileUnits() { const DataExtractor &DIData = DataExtractor(getInfoDWOSection().Data, isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - OwningPtr DWOCU(new DWARFCompileUnit( + std::unique_ptr DWOCU(new DWARFCompileUnit( getDebugAbbrevDWO(), getInfoDWOSection().Data, getAbbrevDWOSection(), getRangeDWOSection(), getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(), @@ -359,7 +359,7 @@ void DWARFContext::parseDWOTypeUnits() { const DataExtractor &DIData = DataExtractor(I->second.Data, isLittleEndian(), 0); while (DIData.isValidOffset(offset)) { - OwningPtr TU(new DWARFTypeUnit( + std::unique_ptr TU(new DWARFTypeUnit( getDebugAbbrevDWO(), I->second.Data, getAbbrevDWOSection(), getRangeDWOSection(), getStringDWOSection(), getStringOffsetDWOSection(), getAddrSection(), &I->second.Relocs, @@ -629,7 +629,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) : if (!zlib::isAvailable() || !consumeCompressedDebugSectionHeader(data, OriginalSize)) continue; - OwningPtr UncompressedSection; + std::unique_ptr UncompressedSection; if (zlib::uncompress(data, UncompressedSection, OriginalSize) != zlib::StatusOK) continue; diff --git a/lib/DebugInfo/DWARFContext.h b/lib/DebugInfo/DWARFContext.h index 823e98a6b3..96eaa70bd5 100644 --- a/lib/DebugInfo/DWARFContext.h +++ b/lib/DebugInfo/DWARFContext.h @@ -18,7 +18,6 @@ #include "DWARFDebugRangeList.h" #include "DWARFTypeUnit.h" #include "llvm/ADT/MapVector.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/DebugInfo/DIContext.h" @@ -31,15 +30,15 @@ namespace llvm { class DWARFContext : public DIContext { SmallVector CUs; SmallVector TUs; - OwningPtr Abbrev; - OwningPtr Loc; - OwningPtr Aranges; - OwningPtr Line; - OwningPtr DebugFrame; + std::unique_ptr Abbrev; + std::unique_ptr Loc; + std::unique_ptr Aranges; + std::unique_ptr Line; + std::unique_ptr DebugFrame; SmallVector DWOCUs; SmallVector DWOTUs; - OwningPtr AbbrevDWO; + std::unique_ptr AbbrevDWO; DWARFContext(DWARFContext &) LLVM_DELETED_FUNCTION; DWARFContext &operator=(DWARFContext &) LLVM_DELETED_FUNCTION; diff --git a/lib/DebugInfo/DWARFUnit.h b/lib/DebugInfo/DWARFUnit.h index d7d9aa27a8..5b4cf0905b 100644 --- a/lib/DebugInfo/DWARFUnit.h +++ b/lib/DebugInfo/DWARFUnit.h @@ -14,7 +14,6 @@ #include "DWARFDebugInfoEntry.h" #include "DWARFDebugRangeList.h" #include "DWARFRelocMap.h" -#include "llvm/ADT/OwningPtr.h" #include namespace llvm { @@ -50,14 +49,14 @@ class DWARFUnit { std::vector DieArray; class DWOHolder { - OwningPtr DWOFile; - OwningPtr DWOContext; + std::unique_ptr DWOFile; + std::unique_ptr DWOContext; DWARFUnit *DWOU; public: DWOHolder(object::ObjectFile *DWOFile); DWARFUnit *getUnit() const { return DWOU; } }; - OwningPtr DWO; + std::unique_ptr DWO; protected: virtual bool extractImpl(DataExtractor debug_info, uint32_t *offset_ptr); diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index fee1526780..30185d78cb 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -443,7 +443,7 @@ ExecutionEngine *ExecutionEngine::createJIT(Module *M, } ExecutionEngine *EngineBuilder::create(TargetMachine *TM) { - OwningPtr TheTM(TM); // Take ownership. + std::unique_ptr TheTM(TM); // Take ownership. // Make sure we can resolve symbols in the program as well. The zero arg // to the function tells DynamicLibrary to load the program, not a library. diff --git a/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp b/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp index 150ef1fff9..2ca4e3e411 100644 --- a/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp +++ b/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp @@ -20,7 +20,6 @@ #include "llvm/IR/Function.h" #include "llvm/IR/Metadata.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/ExecutionEngine/ObjectImage.h" @@ -40,7 +39,7 @@ namespace { class IntelJITEventListener : public JITEventListener { typedef DenseMap MethodIDMap; - OwningPtr Wrapper; + std::unique_ptr Wrapper; MethodIDMap MethodIDs; FilenameCache Filenames; diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 64cee037a0..b0e48cae18 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -15,7 +15,6 @@ #define DEBUG_TYPE "jit" #include "JIT.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp index ce746a546b..aa5f724024 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp +++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp @@ -146,7 +146,7 @@ ObjectBufferStream* MCJIT::emitObject(Module *M) { PM.add(new DataLayoutPass(M)); // The RuntimeDyld will take ownership of this shortly - OwningPtr CompiledObject(new ObjectBufferStream()); + std::unique_ptr CompiledObject(new ObjectBufferStream()); // Turn the machine code intermediate representation into bytes in memory // that may be executed. @@ -164,7 +164,7 @@ ObjectBufferStream* MCJIT::emitObject(Module *M) { if (ObjCache) { // MemoryBuffer is a thin wrapper around the actual memory, so it's OK // to create a temporary object here and delete it after the call. - OwningPtr MB(CompiledObject->getMemBuffer()); + std::unique_ptr MB(CompiledObject->getMemBuffer()); ObjCache->notifyObjectCompiled(M, MB.get()); } @@ -183,10 +183,10 @@ void MCJIT::generateCodeForModule(Module *M) { if (OwnedModules.hasModuleBeenLoaded(M)) return; - OwningPtr ObjectToLoad; + std::unique_ptr ObjectToLoad; // Try to load the pre-compiled object from cache if possible if (0 != ObjCache) { - OwningPtr PreCompiledObject(ObjCache->getObject(M)); + std::unique_ptr PreCompiledObject(ObjCache->getObject(M)); if (0 != PreCompiledObject.get()) ObjectToLoad.reset(new ObjectBuffer(PreCompiledObject.release())); } @@ -304,7 +304,7 @@ uint64_t MCJIT::getSymbolAddress(const std::string &Name, // Look for our symbols in each Archive object::Archive::child_iterator ChildIt = A->findSym(Name); if (ChildIt != A->child_end()) { - OwningPtr ChildBin; + std::unique_ptr ChildBin; // FIXME: Support nested archives? if (!ChildIt->getAsBinary(ChildBin) && ChildBin->isObject()) { object::ObjectFile *OF = reinterpret_cast( diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.h b/lib/ExecutionEngine/MCJIT/MCJIT.h index 09c1bae24e..8fb7474357 100644 --- a/lib/ExecutionEngine/MCJIT/MCJIT.h +++ b/lib/ExecutionEngine/MCJIT/MCJIT.h @@ -76,7 +76,7 @@ public: private: MCJIT *ParentEngine; - OwningPtr ClientMM; + std::unique_ptr ClientMM; }; // About Module states: added->loaded->finalized. diff --git a/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp b/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp index f71b3ea4a4..87cef2e076 100644 --- a/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp +++ b/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp @@ -18,7 +18,6 @@ #define DEBUG_TYPE "oprofile-jit-event-listener" #include "llvm/IR/DebugInfo.h" #include "llvm/IR/Function.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/ExecutionEngine/ObjectImage.h" #include "llvm/ExecutionEngine/OProfileWrapper.h" @@ -229,7 +228,8 @@ void OProfileJITEventListener::NotifyFreeingObject(const ObjectImage &Obj) { namespace llvm { JITEventListener *JITEventListener::createOProfileJITEventListener() { - static OwningPtr JITProfilingWrapper(new OProfileWrapper); + static std::unique_ptr JITProfilingWrapper( + new OProfileWrapper); return new OProfileJITEventListener(*JITProfilingWrapper); } diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 6055ffe823..d45b47218a 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -96,7 +96,7 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectBuffer *InputBuffer) { ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) { MutexGuard locked(lock); - OwningPtr Obj(InputObject); + std::unique_ptr Obj(InputObject); if (!Obj) return NULL; diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index c3736691c2..6ca7fd38d2 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -16,7 +16,6 @@ #include "JITRegistrar.h" #include "ObjectImageCommon.h" #include "llvm/ADT/IntervalMap.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" diff --git a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index be80cbcfda..62de7b707c 100644 --- a/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -13,7 +13,6 @@ #define DEBUG_TYPE "dyld" #include "RuntimeDyldMachO.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" using namespace llvm; diff --git a/lib/IR/AsmWriter.h b/lib/IR/AsmWriter.h index 8f4a37777e..222d3a490f 100644 --- a/lib/IR/AsmWriter.h +++ b/lib/IR/AsmWriter.h @@ -16,7 +16,6 @@ #define LLVM_IR_ASSEMBLYWRITER_H #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/TypeFinder.h" @@ -67,7 +66,7 @@ protected: const Module *TheModule; private: - OwningPtr ModuleSlotTracker; + std::unique_ptr ModuleSlotTracker; SlotTracker &Machine; TypePrinting TypePrinter; AssemblyAnnotationWriter *AnnotationWriter; diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index efca2bffbf..6c012736de 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -2536,7 +2536,7 @@ LLVMBool LLVMCreateMemoryBufferWithContentsOfFile( LLVMMemoryBufferRef *OutMemBuf, char **OutMessage) { - OwningPtr MB; + std::unique_ptr MB; error_code ec; if (!(ec = MemoryBuffer::getFile(Path, MB))) { *OutMemBuf = wrap(MB.release()); @@ -2549,7 +2549,7 @@ LLVMBool LLVMCreateMemoryBufferWithContentsOfFile( LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, char **OutMessage) { - OwningPtr MB; + std::unique_ptr MB; error_code ec; if (!(ec = MemoryBuffer::getSTDIN(MB))) { *OutMemBuf = wrap(MB.release()); diff --git a/lib/IR/GCOV.cpp b/lib/IR/GCOV.cpp index a0591fffb9..dc9cb4b2a8 100644 --- a/lib/IR/GCOV.cpp +++ b/lib/IR/GCOV.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/GCOV.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FileSystem.h" @@ -472,7 +471,7 @@ void FileInfo::print(StringRef GCNOFile, StringRef GCDAFile) { for (StringMap::const_iterator I = LineInfo.begin(), E = LineInfo.end(); I != E; ++I) { StringRef Filename = I->first(); - OwningPtr Buff; + std::unique_ptr Buff; if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, Buff)) { errs() << Filename << ": " << ec.message() << "\n"; return; diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp index 6093d35689..6a3a38f60b 100644 --- a/lib/IR/Module.cpp +++ b/lib/IR/Module.cpp @@ -43,7 +43,7 @@ template class llvm::SymbolTableListTraits; // Module::Module(StringRef MID, LLVMContext &C) - : Context(C), Materializer(NULL), ModuleID(MID), DL("") { + : Context(C), Materializer(), ModuleID(MID), DL("") { ValSymTab = new ValueSymbolTable(); NamedMDSymTab = new StringMap(); Context.addModule(this); diff --git a/lib/IRReader/IRReader.cpp b/lib/IRReader/IRReader.cpp index 29a70403ae..8be8ab882e 100644 --- a/lib/IRReader/IRReader.cpp +++ b/lib/IRReader/IRReader.cpp @@ -10,7 +10,6 @@ #include "llvm/IRReader/IRReader.h" #include "llvm-c/Core.h" #include "llvm-c/IRReader.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/AsmParser/Parser.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/LLVMContext.h" @@ -53,7 +52,7 @@ Module *llvm::getLazyIRModule(MemoryBuffer *Buffer, SMDiagnostic &Err, Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err, LLVMContext &Context) { - OwningPtr File; + std::unique_ptr File; if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { Err = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + ec.message()); @@ -86,7 +85,7 @@ Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err, Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err, LLVMContext &Context) { - OwningPtr File; + std::unique_ptr File; if (error_code ec = MemoryBuffer::getFileOrSTDIN(Filename, File)) { Err = SMDiagnostic(Filename, SourceMgr::DK_Error, "Could not open input file: " + ec.message()); diff --git a/lib/LTO/LTOCodeGenerator.cpp b/lib/LTO/LTOCodeGenerator.cpp index 4e28c328ad..cdb4f95276 100644 --- a/lib/LTO/LTOCodeGenerator.cpp +++ b/lib/LTO/LTOCodeGenerator.cpp @@ -264,7 +264,7 @@ const void* LTOCodeGenerator::compile(size_t* length, delete NativeObjectFile; // read .o file into memory buffer - OwningPtr BuffPtr; + std::unique_ptr BuffPtr; if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) { errMsg = ec.message(); sys::fs::remove(NativeObjectPath); diff --git a/lib/LTO/LTOModule.cpp b/lib/LTO/LTOModule.cpp index 4e71be8b4b..90de83270c 100644 --- a/lib/LTO/LTOModule.cpp +++ b/lib/LTO/LTOModule.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "llvm/LTO/LTOModule.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/Triple.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/Constants.h" @@ -80,7 +79,7 @@ bool LTOModule::isBitcodeFileForTarget(const void *mem, size_t length, bool LTOModule::isBitcodeFileForTarget(const char *path, const char *triplePrefix) { - OwningPtr buffer; + std::unique_ptr buffer; if (MemoryBuffer::getFile(path, buffer)) return false; return isTargetMatch(buffer.release(), triplePrefix); @@ -98,7 +97,7 @@ bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) { /// the buffer. LTOModule *LTOModule::makeLTOModule(const char *path, TargetOptions options, std::string &errMsg) { - OwningPtr buffer; + std::unique_ptr buffer; if (error_code ec = MemoryBuffer::getFile(path, buffer)) { errMsg = ec.message(); return NULL; @@ -117,7 +116,7 @@ LTOModule *LTOModule::makeLTOModule(int fd, const char *path, off_t offset, TargetOptions options, std::string &errMsg) { - OwningPtr buffer; + std::unique_ptr buffer; if (error_code ec = MemoryBuffer::getOpenFileSlice(fd, path, buffer, map_size, offset)) { errMsg = ec.message(); @@ -129,7 +128,7 @@ LTOModule *LTOModule::makeLTOModule(int fd, const char *path, LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length, TargetOptions options, std::string &errMsg, StringRef path) { - OwningPtr buffer(makeBuffer(mem, length, path)); + std::unique_ptr buffer(makeBuffer(mem, length, path)); if (!buffer) return NULL; return makeLTOModule(buffer.release(), options, errMsg); @@ -146,7 +145,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer, delete buffer; return NULL; } - OwningPtr m(ModuleOrErr.get()); + std::unique_ptr m(ModuleOrErr.get()); std::string TripleStr = m->getTargetTriple(); if (TripleStr.empty()) @@ -725,20 +724,19 @@ bool LTOModule::addAsmGlobalSymbols(std::string &errMsg) { if (inlineAsm.empty()) return false; - OwningPtr Streamer(new RecordStreamer(_context)); + std::unique_ptr Streamer(new RecordStreamer(_context)); MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(inlineAsm); SourceMgr SrcMgr; SrcMgr.AddNewSourceBuffer(Buffer, SMLoc()); - OwningPtr Parser(createMCAsmParser(SrcMgr, - _context, *Streamer, - *_target->getMCAsmInfo())); + std::unique_ptr Parser( + createMCAsmParser(SrcMgr, _context, *Streamer, *_target->getMCAsmInfo())); const Target &T = _target->getTarget(); - OwningPtr MCII(T.createMCInstrInfo()); - OwningPtr - STI(T.createMCSubtargetInfo(_target->getTargetTriple(), - _target->getTargetCPU(), - _target->getTargetFeatureString())); - OwningPtr TAP(T.createMCAsmParser(*STI, *Parser.get(), *MCII)); + std::unique_ptr MCII(T.createMCInstrInfo()); + std::unique_ptr STI(T.createMCSubtargetInfo( + _target->getTargetTriple(), _target->getTargetCPU(), + _target->getTargetFeatureString())); + std::unique_ptr TAP( + T.createMCAsmParser(*STI, *Parser.get(), *MCII)); if (!TAP) { errMsg = "target " + std::string(T.getName()) + " does not define AsmParser."; diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 8b2ab02bec..edece8b63d 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCELFObjectWriter.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" @@ -79,7 +78,7 @@ class ELFObjectWriter : public MCObjectWriter { }; /// The target specific ELF writer instance. - llvm::OwningPtr TargetObjectWriter; + std::unique_ptr TargetObjectWriter; SmallPtrSet UsedInReloc; SmallPtrSet WeakrefUsedInReloc; diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index 8f0a702fb1..d9a04575ff 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCStreamer.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" @@ -41,9 +40,9 @@ protected: formatted_raw_ostream &OS; const MCAsmInfo *MAI; private: - OwningPtr InstPrinter; - OwningPtr Emitter; - OwningPtr AsmBackend; + std::unique_ptr InstPrinter; + std::unique_ptr Emitter; + std::unique_ptr AsmBackend; SmallString<128> CommentToEmit; raw_svector_ostream CommentStream; diff --git a/lib/MC/MCDisassembler.cpp b/lib/MC/MCDisassembler.cpp index e365c37c32..afd3cb7ff0 100644 --- a/lib/MC/MCDisassembler.cpp +++ b/lib/MC/MCDisassembler.cpp @@ -16,13 +16,9 @@ using namespace llvm; MCDisassembler::~MCDisassembler() { } -void -MCDisassembler::setupForSymbolicDisassembly( - LLVMOpInfoCallback GetOpInfo, - LLVMSymbolLookupCallback SymbolLookUp, - void *DisInfo, - MCContext *Ctx, - OwningPtr &RelInfo) { +void MCDisassembler::setupForSymbolicDisassembly( + LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, + void *DisInfo, MCContext *Ctx, std::unique_ptr &RelInfo) { this->GetOpInfo = GetOpInfo; this->SymbolLookUp = SymbolLookUp; this->DisInfo = DisInfo; @@ -33,16 +29,12 @@ MCDisassembler::setupForSymbolicDisassembly( SymbolLookUp, DisInfo)); } -void -MCDisassembler::setupForSymbolicDisassembly( - LLVMOpInfoCallback GetOpInfo, - LLVMSymbolLookupCallback SymbolLookUp, - void *DisInfo, - MCContext *Ctx, - std::unique_ptr &RelInfo) { - OwningPtr MCRI; +void MCDisassembler::setupForSymbolicDisassembly( + LLVMOpInfoCallback GetOpInfo, LLVMSymbolLookupCallback SymbolLookUp, + void *DisInfo, MCContext *Ctx, OwningPtr &RelInfo) { + std::unique_ptr MCRI; setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo, Ctx, MCRI); - RelInfo = MCRI.take_unique(); + RelInfo = std::move(MCRI); } bool MCDisassembler::tryAddingSymbolicOperand(MCInst &Inst, int64_t Value, @@ -63,6 +55,6 @@ void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value, Symbolizer->tryAddingPcLoadReferenceComment(cStream, Value, Address); } -void MCDisassembler::setSymbolizer(OwningPtr &Symzer) { +void MCDisassembler::setSymbolizer(std::unique_ptr &Symzer) { Symbolizer.reset(Symzer.release()); } diff --git a/lib/MC/MCDisassembler/Disassembler.cpp b/lib/MC/MCDisassembler/Disassembler.cpp index 3302f8c8ab..4e4bad1430 100644 --- a/lib/MC/MCDisassembler/Disassembler.cpp +++ b/lib/MC/MCDisassembler/Disassembler.cpp @@ -77,14 +77,13 @@ LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU, if (!DisAsm) return 0; - OwningPtr RelInfo( - TheTarget->createMCRelocationInfo(Triple, *Ctx)); + std::unique_ptr RelInfo( + TheTarget->createMCRelocationInfo(Triple, *Ctx)); if (!RelInfo) return 0; - OwningPtr Symbolizer( - TheTarget->createMCSymbolizer(Triple, GetOpInfo, SymbolLookUp, DisInfo, - Ctx, RelInfo.release())); + std::unique_ptr Symbolizer(TheTarget->createMCSymbolizer( + Triple, GetOpInfo, SymbolLookUp, DisInfo, Ctx, RelInfo.release())); DisAsm->setSymbolizer(Symbolizer); DisAsm->setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo, Ctx, RelInfo); diff --git a/lib/MC/MCDisassembler/Disassembler.h b/lib/MC/MCDisassembler/Disassembler.h index 4855af27dd..d1d40cd238 100644 --- a/lib/MC/MCDisassembler/Disassembler.h +++ b/lib/MC/MCDisassembler/Disassembler.h @@ -18,7 +18,6 @@ #define LLVM_MC_DISASSEMBLER_H #include "llvm-c/Disassembler.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/raw_ostream.h" #include @@ -56,23 +55,23 @@ private: // LLVMDisasmInstruction(). // // The LLVM target corresponding to the disassembler. - // FIXME: using llvm::OwningPtr causes a malloc error + // FIXME: using std::unique_ptr causes a malloc error // when this LLVMDisasmContext is deleted. const Target *TheTarget; // The assembly information for the target architecture. - llvm::OwningPtr MAI; + std::unique_ptr MAI; // The register information for the target architecture. - llvm::OwningPtr MRI; + std::unique_ptr MRI; // The subtarget information for the target architecture. - llvm::OwningPtr MSI; + std::unique_ptr MSI; // The instruction information for the target architecture. - llvm::OwningPtr MII; + std::unique_ptr MII; // The assembly context for creating symbols and MCExprs. - llvm::OwningPtr Ctx; + std::unique_ptr Ctx; // The disassembler for the target architecture. - llvm::OwningPtr DisAsm; + std::unique_ptr DisAsm; // The instruction printer for the target architecture. - llvm::OwningPtr IP; + std::unique_ptr IP; // The options used to set up the disassembler. uint64_t Options; // The CPU string. diff --git a/lib/MC/MCExternalSymbolizer.cpp b/lib/MC/MCExternalSymbolizer.cpp index 9cd5f6b68c..660a11c274 100644 --- a/lib/MC/MCExternalSymbolizer.cpp +++ b/lib/MC/MCExternalSymbolizer.cpp @@ -191,7 +191,7 @@ MCSymbolizer *createMCSymbolizer(StringRef TT, LLVMOpInfoCallback GetOpInfo, MCRelocationInfo *RelInfo) { assert(Ctx != 0 && "No MCContext given for symbolic disassembly"); - OwningPtr RelInfoOwingPtr(RelInfo); + std::unique_ptr RelInfoOwingPtr(RelInfo); return new MCExternalSymbolizer(*Ctx, RelInfoOwingPtr, GetOpInfo, SymbolLookUp, DisInfo); } diff --git a/lib/MC/MCModuleYAML.cpp b/lib/MC/MCModuleYAML.cpp index e2de57849b..102971b732 100644 --- a/lib/MC/MCModuleYAML.cpp +++ b/lib/MC/MCModuleYAML.cpp @@ -442,7 +442,7 @@ StringRef mcmodule2yaml(raw_ostream &OS, const MCModule &MCM, return ""; } -StringRef yaml2mcmodule(OwningPtr &MCM, StringRef YamlContent, +StringRef yaml2mcmodule(std::unique_ptr &MCM, StringRef YamlContent, const MCInstrInfo &MII, const MCRegisterInfo &MRI) { MCM.reset(new MCModule); YAML2MCModule Parser(*MCM); diff --git a/lib/MC/MCObjectSymbolizer.cpp b/lib/MC/MCObjectSymbolizer.cpp index 7653fece41..8aafcf6ee7 100644 --- a/lib/MC/MCObjectSymbolizer.cpp +++ b/lib/MC/MCObjectSymbolizer.cpp @@ -34,7 +34,8 @@ class MCMachObjectSymbolizer : public MCObjectSymbolizer { uint64_t StubsIndSymIndex; public: - MCMachObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo, + MCMachObjectSymbolizer(MCContext &Ctx, + std::unique_ptr &RelInfo, const MachOObjectFile *MOOF); StringRef findExternalFunctionAt(uint64_t Addr) override; @@ -44,12 +45,11 @@ public: }; } // End unnamed namespace - -MCMachObjectSymbolizer:: -MCMachObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo, - const MachOObjectFile *MOOF) - : MCObjectSymbolizer(Ctx, RelInfo, MOOF), MOOF(MOOF), - StubsStart(0), StubsCount(0), StubSize(0), StubsIndSymIndex(0) { +MCMachObjectSymbolizer::MCMachObjectSymbolizer( + MCContext &Ctx, std::unique_ptr &RelInfo, + const MachOObjectFile *MOOF) + : MCObjectSymbolizer(Ctx, RelInfo, MOOF), MOOF(MOOF), StubsStart(0), + StubsCount(0), StubSize(0), StubsIndSymIndex(0) { for (section_iterator SI = MOOF->section_begin(), SE = MOOF->section_end(); SI != SE; ++SI) { @@ -120,11 +120,10 @@ tryAddingPcLoadReferenceComment(raw_ostream &cStream, int64_t Value, //===- MCObjectSymbolizer -------------------------------------------------===// -MCObjectSymbolizer::MCObjectSymbolizer(MCContext &Ctx, - OwningPtr &RelInfo, - const ObjectFile *Obj) - : MCSymbolizer(Ctx, RelInfo), Obj(Obj), SortedSections(), AddrToReloc() { -} +MCObjectSymbolizer::MCObjectSymbolizer( + MCContext &Ctx, std::unique_ptr &RelInfo, + const ObjectFile *Obj) + : MCSymbolizer(Ctx, RelInfo), Obj(Obj), SortedSections(), AddrToReloc() {} bool MCObjectSymbolizer:: tryAddingSymbolicOperand(MCInst &MI, raw_ostream &cStream, @@ -188,10 +187,9 @@ StringRef MCObjectSymbolizer::findExternalFunctionAt(uint64_t Addr) { return StringRef(); } -MCObjectSymbolizer * -MCObjectSymbolizer::createObjectSymbolizer(MCContext &Ctx, - OwningPtr &RelInfo, - const ObjectFile *Obj) { +MCObjectSymbolizer *MCObjectSymbolizer::createObjectSymbolizer( + MCContext &Ctx, std::unique_ptr &RelInfo, + const ObjectFile *Obj) { if (const MachOObjectFile *MOOF = dyn_cast(Obj)) return new MCMachObjectSymbolizer(Ctx, RelInfo, MOOF); return new MCObjectSymbolizer(Ctx, RelInfo, Obj); diff --git a/lib/MC/MCSymbolizer.cpp b/lib/MC/MCSymbolizer.cpp index d3c7311e01..6395b11351 100644 --- a/lib/MC/MCSymbolizer.cpp +++ b/lib/MC/MCSymbolizer.cpp @@ -12,9 +12,9 @@ using namespace llvm; -MCSymbolizer::MCSymbolizer(MCContext &Ctx, OwningPtr &RelInfo) - : Ctx(Ctx), RelInfo(RelInfo.release()) { -} +MCSymbolizer::MCSymbolizer(MCContext &Ctx, + std::unique_ptr &RelInfo) + : Ctx(Ctx), RelInfo(RelInfo.release()) {} MCSymbolizer::~MCSymbolizer() { } diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index 381fe0ee03..d0a014cca9 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -15,7 +15,6 @@ #include "llvm/MC/MCWinCOFFObjectWriter.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" @@ -125,7 +124,7 @@ public: typedef DenseMap symbol_map; typedef DenseMap section_map; - llvm::OwningPtr TargetObjectWriter; + std::unique_ptr TargetObjectWriter; // Root level file contents. COFF::header Header; diff --git a/lib/Object/Binary.cpp b/lib/Object/Binary.cpp index 673a34e98a..63fd3ed011 100644 --- a/lib/Object/Binary.cpp +++ b/lib/Object/Binary.cpp @@ -43,7 +43,7 @@ StringRef Binary::getFileName() const { ErrorOr object::createBinary(MemoryBuffer *Source, LLVMContext *Context) { - OwningPtr scopedSource(Source); + std::unique_ptr scopedSource(Source); sys::fs::file_magic Type = sys::fs::identify_magic(Source->getBuffer()); switch (Type) { @@ -80,7 +80,7 @@ ErrorOr object::createBinary(MemoryBuffer *Source, } ErrorOr object::createBinary(StringRef Path) { - OwningPtr File; + std::unique_ptr File; if (error_code EC = MemoryBuffer::getFileOrSTDIN(Path, File)) return EC; return createBinary(File.release()); diff --git a/lib/Object/COFFObjectFile.cpp b/lib/Object/COFFObjectFile.cpp index 95faa13256..6ef2fbfed5 100644 --- a/lib/Object/COFFObjectFile.cpp +++ b/lib/Object/COFFObjectFile.cpp @@ -1068,7 +1068,8 @@ error_code ExportDirectoryEntryRef::getSymbolName(StringRef &Result) const { ErrorOr ObjectFile::createCOFFObjectFile(MemoryBuffer *Object, bool BufferOwned) { error_code EC; - OwningPtr Ret(new COFFObjectFile(Object, EC, BufferOwned)); + std::unique_ptr Ret( + new COFFObjectFile(Object, EC, BufferOwned)); if (EC) return EC; return Ret.release(); diff --git a/lib/Object/ELFObjectFile.cpp b/lib/Object/ELFObjectFile.cpp index 17b615e017..a2c4df2007 100644 --- a/lib/Object/ELFObjectFile.cpp +++ b/lib/Object/ELFObjectFile.cpp @@ -24,7 +24,7 @@ ErrorOr ObjectFile::createELFObjectFile(MemoryBuffer *Obj, 1ULL << countTrailingZeros(uintptr_t(Obj->getBufferStart())); error_code EC; - OwningPtr R; + std::unique_ptr R; if (Ident.first == ELF::ELFCLASS32 && Ident.second == ELF::ELFDATA2LSB) #if !LLVM_IS_UNALIGNED_ACCESS_FAST if (MaxAlignment >= 4) diff --git a/lib/Object/IRObjectFile.cpp b/lib/Object/IRObjectFile.cpp index e8d51ecbf6..d5ea80d1d0 100644 --- a/lib/Object/IRObjectFile.cpp +++ b/lib/Object/IRObjectFile.cpp @@ -144,7 +144,7 @@ basic_symbol_iterator IRObjectFile::symbol_end_impl() const { ErrorOr llvm::object::SymbolicFile::createIRObjectFile( MemoryBuffer *Object, LLVMContext &Context, bool BufferOwned) { error_code EC; - OwningPtr Ret( + std::unique_ptr Ret( new IRObjectFile(Object, EC, Context, BufferOwned)); if (EC) return EC; diff --git a/lib/Object/MachOObjectFile.cpp b/lib/Object/MachOObjectFile.cpp index 00599efce0..5dd9e5596b 100644 --- a/lib/Object/MachOObjectFile.cpp +++ b/lib/Object/MachOObjectFile.cpp @@ -1549,7 +1549,7 @@ ErrorOr ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer, bool BufferOwned) { StringRef Magic = Buffer->getBuffer().slice(0, 4); error_code EC; - OwningPtr Ret; + std::unique_ptr Ret; if (Magic == "\xFE\xED\xFA\xCE") Ret.reset(new MachOObjectFile(Buffer, false, false, EC, BufferOwned)); else if (Magic == "\xCE\xFA\xED\xFE") diff --git a/lib/Object/MachOUniversal.cpp b/lib/Object/MachOUniversal.cpp index 3975a18c60..70baa9f63a 100644 --- a/lib/Object/MachOUniversal.cpp +++ b/lib/Object/MachOUniversal.cpp @@ -72,7 +72,7 @@ MachOUniversalBinary::ObjectForArch::ObjectForArch( } error_code MachOUniversalBinary::ObjectForArch::getAsObjectFile( - OwningPtr &Result) const { + std::unique_ptr &Result) const { if (Parent) { StringRef ParentData = Parent->getData(); StringRef ObjectData = ParentData.substr(Header.offset, Header.size); @@ -95,7 +95,8 @@ void MachOUniversalBinary::anchor() { } ErrorOr MachOUniversalBinary::create(MemoryBuffer *Source) { error_code EC; - OwningPtr Ret(new MachOUniversalBinary(Source, EC)); + std::unique_ptr Ret( + new MachOUniversalBinary(Source, EC)); if (EC) return EC; return Ret.release(); @@ -134,9 +135,8 @@ static bool getCTMForArch(Triple::ArchType Arch, MachO::CPUType &CTM) { } } -error_code -MachOUniversalBinary::getObjectForArch(Triple::ArchType Arch, - OwningPtr &Result) const { +error_code MachOUniversalBinary::getObjectForArch( + Triple::ArchType Arch, std::unique_ptr &Result) const { MachO::CPUType CTM; if (!getCTMForArch(Arch, CTM)) return object_error::arch_not_found; diff --git a/lib/Object/ObjectFile.cpp b/lib/Object/ObjectFile.cpp index 058bc3436a..d30f0cca49 100644 --- a/lib/Object/ObjectFile.cpp +++ b/lib/Object/ObjectFile.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Object/ObjectFile.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" @@ -87,7 +86,7 @@ ErrorOr ObjectFile::createObjectFile(MemoryBuffer *Object, } ErrorOr ObjectFile::createObjectFile(StringRef ObjectPath) { - OwningPtr File; + std::unique_ptr File; if (error_code EC = MemoryBuffer::getFile(ObjectPath, File)) return EC; return createObjectFile(File.release()); diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index deb5c3983d..b3c2614ec9 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -18,7 +18,6 @@ #include "llvm/Support/CommandLine.h" #include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringMap.h" @@ -620,7 +619,7 @@ void cl::TokenizeWindowsCommandLine(StringRef Src, StringSaver &Saver, static bool ExpandResponseFile(const char *FName, StringSaver &Saver, TokenizerCallback Tokenizer, SmallVectorImpl &NewArgv) { - OwningPtr MemBuf; + std::unique_ptr MemBuf; if (MemoryBuffer::getFile(FName, MemBuf)) return false; StringRef Str(MemBuf->getBufferStart(), MemBuf->getBufferSize()); diff --git a/lib/Support/Compression.cpp b/lib/Support/Compression.cpp index b5ddb7002c..5e5336144a 100644 --- a/lib/Support/Compression.cpp +++ b/lib/Support/Compression.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Compression.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/Config/config.h" #include "llvm/Support/Compiler.h" @@ -48,10 +47,10 @@ static zlib::Status encodeZlibReturnValue(int ReturnValue) { bool zlib::isAvailable() { return true; } zlib::Status zlib::compress(StringRef InputBuffer, - OwningPtr &CompressedBuffer, + std::unique_ptr &CompressedBuffer, CompressionLevel Level) { unsigned long CompressedSize = ::compressBound(InputBuffer.size()); - OwningArrayPtr TmpBuffer(new char[CompressedSize]); + std::unique_ptr TmpBuffer(new char[CompressedSize]); int CLevel = encodeZlibCompressionLevel(Level); Status Res = encodeZlibReturnValue(::compress2( (Bytef *)TmpBuffer.get(), &CompressedSize, @@ -66,9 +65,9 @@ zlib::Status zlib::compress(StringRef InputBuffer, } zlib::Status zlib::uncompress(StringRef InputBuffer, - OwningPtr &UncompressedBuffer, + std::unique_ptr &UncompressedBuffer, size_t UncompressedSize) { - OwningArrayPtr TmpBuffer(new char[UncompressedSize]); + std::unique_ptr TmpBuffer(new char[UncompressedSize]); Status Res = encodeZlibReturnValue( ::uncompress((Bytef *)TmpBuffer.get(), (uLongf *)&UncompressedSize, (const Bytef *)InputBuffer.data(), InputBuffer.size())); @@ -88,12 +87,12 @@ uint32_t zlib::crc32(StringRef Buffer) { #else bool zlib::isAvailable() { return false; } zlib::Status zlib::compress(StringRef InputBuffer, - OwningPtr &CompressedBuffer, + std::unique_ptr &CompressedBuffer, CompressionLevel Level) { return zlib::StatusUnsupported; } zlib::Status zlib::uncompress(StringRef InputBuffer, - OwningPtr &UncompressedBuffer, + std::unique_ptr &UncompressedBuffer, size_t UncompressedSize) { return zlib::StatusUnsupported; } diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 7f5d540487..b2dc47dc69 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/FileUtilities.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -177,13 +176,13 @@ int llvm::DiffFilesWithTolerance(StringRef NameA, std::string *Error) { // Now its safe to mmap the files into memory because both files // have a non-zero size. - OwningPtr F1; + std::unique_ptr F1; if (error_code ec = MemoryBuffer::getFile(NameA, F1)) { if (Error) *Error = ec.message(); return 2; } - OwningPtr F2; + std::unique_ptr F2; if (error_code ec = MemoryBuffer::getFile(NameB, F2)) { if (Error) *Error = ec.message(); diff --git a/lib/Support/LockFileManager.cpp b/lib/Support/LockFileManager.cpp index 3e23298e4f..61afb79fb2 100644 --- a/lib/Support/LockFileManager.cpp +++ b/lib/Support/LockFileManager.cpp @@ -36,7 +36,7 @@ LockFileManager::readLockFile(StringRef LockFileName) { // Read the owning host and PID out of the lock file. If it appears that the // owning process is dead, the lock file is invalid. - OwningPtr MB; + std::unique_ptr MB; if (MemoryBuffer::getFile(LockFileName, MB)) return None; diff --git a/lib/Support/SourceMgr.cpp b/lib/Support/SourceMgr.cpp index f9aef6dba6..4bfd96abe5 100644 --- a/lib/Support/SourceMgr.cpp +++ b/lib/Support/SourceMgr.cpp @@ -14,7 +14,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/SourceMgr.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Locale.h" @@ -55,7 +54,7 @@ SourceMgr::~SourceMgr() { size_t SourceMgr::AddIncludeFile(const std::string &Filename, SMLoc IncludeLoc, std::string &IncludedFile) { - OwningPtr NewBuf; + std::unique_ptr NewBuf; IncludedFile = Filename; MemoryBuffer::getFile(IncludedFile.c_str(), NewBuf); diff --git a/lib/Support/StringRef.cpp b/lib/Support/StringRef.cpp index bfae754362..bd2a37bb5e 100644 --- a/lib/Support/StringRef.cpp +++ b/lib/Support/StringRef.cpp @@ -10,7 +10,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/APInt.h" #include "llvm/ADT/Hashing.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/edit_distance.h" #include diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 0456f5d638..7cf4d372a5 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/Timer.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" diff --git a/lib/Support/Windows/Program.inc b/lib/Support/Windows/Program.inc index 1b777084c7..5827c105af 100644 --- a/lib/Support/Windows/Program.inc +++ b/lib/Support/Windows/Program.inc @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "WindowsSupport.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/Support/FileSystem.h" #include #include @@ -187,7 +186,7 @@ static bool Execute(ProcessInfo &PI, StringRef Program, const char **args, } // Now build the command line. - OwningArrayPtr command(new char[len+1]); + std::unique_ptr command(new char[len+1]); char *p = command.get(); for (unsigned i = 0; args[i]; i++) { diff --git a/lib/Support/YAMLParser.cpp b/lib/Support/YAMLParser.cpp index c3d1ff1b9e..acfc22c180 100644 --- a/lib/Support/YAMLParser.cpp +++ b/lib/Support/YAMLParser.cpp @@ -1561,12 +1561,10 @@ bool Scanner::fetchMoreTokens() { } Stream::Stream(StringRef Input, SourceMgr &SM) - : scanner(new Scanner(Input, SM)) - , CurrentDoc(0) {} + : scanner(new Scanner(Input, SM)), CurrentDoc() {} Stream::Stream(MemoryBuffer *InputBuffer, SourceMgr &SM) - : scanner(new Scanner(InputBuffer, SM)) - , CurrentDoc(0) {} + : scanner(new Scanner(InputBuffer, SM)), CurrentDoc() {} Stream::~Stream() {} @@ -1601,11 +1599,9 @@ void Stream::skip() { i->skip(); } -Node::Node(unsigned int Type, OwningPtr &D, StringRef A, StringRef T) - : Doc(D) - , TypeID(Type) - , Anchor(A) - , Tag(T) { +Node::Node(unsigned int Type, std::unique_ptr &D, StringRef A, + StringRef T) + : Doc(D), TypeID(Type), Anchor(A), Tag(T) { SMLoc Start = SMLoc::getFromPointer(peekNext().Range.begin()); SourceRange = SMRange(Start, Start); } diff --git a/lib/TableGen/Main.cpp b/lib/TableGen/Main.cpp index e45679b060..fd81ab4f2b 100644 --- a/lib/TableGen/Main.cpp +++ b/lib/TableGen/Main.cpp @@ -16,7 +16,6 @@ //===----------------------------------------------------------------------===// #include "TGParser.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/ToolOutputFile.h" @@ -81,7 +80,7 @@ int TableGenMain(char *argv0, TableGenMainFn *MainFn) { RecordKeeper Records; // Parse the input file. - OwningPtr File; + std::unique_ptr File; if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename, File)) { errs() << "Could not open input file '" << InputFilename << "': " diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index beeb49465d..e8d2e0a008 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -19,7 +19,6 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DepthFirstIterator.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" @@ -349,7 +348,7 @@ struct AddressSanitizer : public FunctionPass { Function *AsanHandleNoReturnFunc; Function *AsanCovFunction; Function *AsanPtrCmpFunction, *AsanPtrSubFunction; - OwningPtr BL; + std::unique_ptr BL; // This array is indexed by AccessIsWrite and log2(AccessSize). Function *AsanErrorCallback[2][kNumberOfAccessSizes]; // This array is indexed by AccessIsWrite. @@ -386,7 +385,7 @@ class AddressSanitizerModule : public ModulePass { bool CheckInitOrder; SmallString<64> BlacklistFile; - OwningPtr BL; + std::unique_ptr BL; SetOfDynamicallyInitializedGlobals DynamicallyInitializedGlobals; Type *IntptrTy; LLVMContext *C; diff --git a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp index dd44a006bc..3f473a96b0 100644 --- a/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ b/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -190,7 +190,7 @@ class DataFlowSanitizer : public ModulePass { Constant *DFSanSetLabelFn; Constant *DFSanNonzeroLabelFn; MDNode *ColdCallWeights; - OwningPtr ABIList; + std::unique_ptr ABIList; DenseMap UnwrappedFnMap; AttributeSet ReadOnlyNoneAttrs; diff --git a/lib/Transforms/Instrumentation/DebugIR.cpp b/lib/Transforms/Instrumentation/DebugIR.cpp index 241baba8bd..45e2c11c15 100644 --- a/lib/Transforms/Instrumentation/DebugIR.cpp +++ b/lib/Transforms/Instrumentation/DebugIR.cpp @@ -503,7 +503,7 @@ bool DebugIR::updateExtension(StringRef NewExtension) { return true; } -void DebugIR::generateFilename(OwningPtr &fd) { +void DebugIR::generateFilename(std::unique_ptr &fd) { SmallVector PathVec; fd.reset(new int); sys::fs::createTemporaryFile("debug-ir", "ll", *fd, PathVec); @@ -524,7 +524,7 @@ std::string DebugIR::getPath() { } void DebugIR::writeDebugBitcode(const Module *M, int *fd) { - OwningPtr Out; + std::unique_ptr Out; std::string error; if (!fd) { @@ -542,12 +542,12 @@ void DebugIR::writeDebugBitcode(const Module *M, int *fd) { Out->close(); } -void DebugIR::createDebugInfo(Module &M, OwningPtr &DisplayM) { +void DebugIR::createDebugInfo(Module &M, std::unique_ptr &DisplayM) { if (M.getFunctionList().size() == 0) // no functions -- no debug info needed return; - OwningPtr VMap; + std::unique_ptr VMap; if (WriteSourceToDisk && (HideDebugIntrinsics || HideDebugMetadata)) { VMap.reset(new ValueToValueMapTy); @@ -566,7 +566,7 @@ void DebugIR::createDebugInfo(Module &M, OwningPtr &DisplayM) { bool DebugIR::isMissingPath() { return Filename.empty() || Directory.empty(); } bool DebugIR::runOnModule(Module &M) { - OwningPtr fd; + std::unique_ptr fd; if (isMissingPath() && !getSourceInfo(M)) { if (!WriteSourceToDisk) @@ -585,7 +585,7 @@ bool DebugIR::runOnModule(Module &M) { // file name from the DICompileUnit descriptor. DebugMetadataRemover::process(M, !ParsedPath); - OwningPtr DisplayM; + std::unique_ptr DisplayM; createDebugInfo(M, DisplayM); if (WriteSourceToDisk) { Module *OutputM = DisplayM.get() ? DisplayM.get() : &M; diff --git a/lib/Transforms/Instrumentation/DebugIR.h b/lib/Transforms/Instrumentation/DebugIR.h index a6852bf6e3..3f57da570e 100644 --- a/lib/Transforms/Instrumentation/DebugIR.h +++ b/lib/Transforms/Instrumentation/DebugIR.h @@ -16,7 +16,6 @@ #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_DEBUGIR_H #define LLVM_TRANSFORMS_INSTRUMENTATION_DEBUGIR_H -#include "llvm/ADT/OwningPtr.h" #include "llvm/Pass.h" namespace llvm { @@ -79,11 +78,11 @@ private: bool updateExtension(llvm::StringRef NewExtension); /// Generate a temporary filename and open an fd - void generateFilename(llvm::OwningPtr &fd); + void generateFilename(std::unique_ptr &fd); /// Creates DWARF CU/Subroutine metadata void createDebugInfo(llvm::Module &M, - llvm::OwningPtr &DisplayM); + std::unique_ptr &DisplayM); /// Returns true if either Directory or Filename is missing, false otherwise. bool isMissingPath(); diff --git a/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/lib/Transforms/Instrumentation/GCOVProfiling.cpp index d990de2a18..d04a5bf8ca 100644 --- a/lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ b/lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -687,7 +687,7 @@ GlobalVariable *GCOVProfiler::buildEdgeLookupTable( Type *Int64PtrTy = Type::getInt64PtrTy(*Ctx); ArrayType *EdgeTableTy = ArrayType::get(Int64PtrTy, TableSize); - OwningArrayPtr EdgeTable(new Constant*[TableSize]); + std::unique_ptr EdgeTable(new Constant *[TableSize]); Constant *NullValue = Constant::getNullValue(Int64PtrTy); for (size_t i = 0; i != TableSize; ++i) EdgeTable[i] = NullValue; diff --git a/lib/Transforms/Instrumentation/MemorySanitizer.cpp b/lib/Transforms/Instrumentation/MemorySanitizer.cpp index 9f7f729cfa..b4ae443475 100644 --- a/lib/Transforms/Instrumentation/MemorySanitizer.cpp +++ b/lib/Transforms/Instrumentation/MemorySanitizer.cpp @@ -272,7 +272,7 @@ class MemorySanitizer : public FunctionPass { /// \brief Path to blacklist file. SmallString<64> BlacklistFile; /// \brief The blacklist. - OwningPtr BL; + std::unique_ptr BL; /// \brief An empty volatile inline asm that prevents callback merge. InlineAsm *EmptyAsm; @@ -489,7 +489,7 @@ struct MemorySanitizerVisitor : public InstVisitor { MemorySanitizer &MS; SmallVector ShadowPHINodes, OriginPHINodes; ValueMap ShadowMap, OriginMap; - OwningPtr VAHelper; + std::unique_ptr VAHelper; // The following flags disable parts of MSan instrumentation based on // blacklist contents and command-line options. diff --git a/lib/Transforms/Instrumentation/ThreadSanitizer.cpp b/lib/Transforms/Instrumentation/ThreadSanitizer.cpp index bc022600cb..fed7508dbc 100644 --- a/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ b/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -99,7 +99,7 @@ struct ThreadSanitizer : public FunctionPass { const DataLayout *DL; Type *IntptrTy; SmallString<64> BlacklistFile; - OwningPtr BL; + std::unique_ptr BL; IntegerType *OrdTy; // Callbacks to run-time library are computed in doInitialization. Function *TsanFuncEntry; diff --git a/lib/Transforms/Scalar/SampleProfile.cpp b/lib/Transforms/Scalar/SampleProfile.cpp index dcb9376e52..d48e43d47c 100644 --- a/lib/Transforms/Scalar/SampleProfile.cpp +++ b/lib/Transforms/Scalar/SampleProfile.cpp @@ -26,7 +26,6 @@ #include "llvm/Transforms/Scalar.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringMap.h" @@ -240,7 +239,7 @@ public: static char ID; SampleProfileLoader(StringRef Name = SampleProfileFile) - : FunctionPass(ID), Profiler(0), Filename(Name) { + : FunctionPass(ID), Profiler(), Filename(Name) { initializeSampleProfileLoaderPass(*PassRegistry::getPassRegistry()); } @@ -261,7 +260,7 @@ public: protected: /// \brief Profile reader object. - OwningPtr Profiler; + std::unique_ptr Profiler; /// \brief Name of the profile file to load. StringRef Filename; @@ -399,7 +398,7 @@ void SampleModuleProfile::dump() { /// profiles for large programs, as the representation is extremely /// inefficient. void SampleModuleProfile::loadText() { - OwningPtr Buffer; + std::unique_ptr Buffer; error_code EC = MemoryBuffer::getFile(Filename, Buffer); if (EC) report_fatal_error("Could not open file " + Filename + ": " + EC.message()); diff --git a/lib/Transforms/Utils/SpecialCaseList.cpp b/lib/Transforms/Utils/SpecialCaseList.cpp index a177c82931..c318560ff8 100644 --- a/lib/Transforms/Utils/SpecialCaseList.cpp +++ b/lib/Transforms/Utils/SpecialCaseList.cpp @@ -15,7 +15,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/SpecialCaseList.h" -#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringExtras.h" @@ -55,7 +54,7 @@ SpecialCaseList *SpecialCaseList::create( const StringRef Path, std::string &Error) { if (Path.empty()) return new SpecialCaseList(); - OwningPtr File; + std::unique_ptr File; if (error_code EC = MemoryBuffer::getFile(Path, File)) { Error = (Twine("Can't open file '") + Path + "': " + EC.message()).str(); return 0; @@ -65,7 +64,7 @@ SpecialCaseList *SpecialCaseList::create( SpecialCaseList *SpecialCaseList::create( const MemoryBuffer *MB, std::string &Error) { - OwningPtr SCL(new SpecialCaseList()); + std::unique_ptr SCL(new SpecialCaseList()); if (!SCL->parse(MB, Error)) return 0; return SCL.release(); -- cgit v1.2.3