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/LTO/LTOModule.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'lib/LTO/LTOModule.cpp') 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."; -- cgit v1.2.3