Skip to content

Commit

Permalink
[C++11] Replace OwningPtr::take() with OwningPtr::release().
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202957 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ahmedcharles committed Mar 5, 2014
1 parent 7b62be2 commit 1a6eca2
Show file tree
Hide file tree
Showing 43 changed files with 117 additions and 117 deletions.
2 changes: 1 addition & 1 deletion include/llvm/MC/MCObjectDisassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class MCObjectDisassembler {
/// somewhere not accessible in the object file.
/// This is used for dynamic disassembly (see RawMemoryObject).
void setFallbackRegion(OwningPtr<MemoryObject> &Region) {
FallbackRegion.reset(Region.take());
FallbackRegion.reset(Region.release());
}

/// \brief Set the symbolizer to use to get information on external functions.
Expand Down
4 changes: 2 additions & 2 deletions lib/AsmParser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Module *llvm::ParseAssembly(MemoryBuffer *F,
OwningPtr<Module> M2(new Module(F->getBufferIdentifier(), Context));
if (LLParser(F, SM, Err, M2.get()).Run())
return 0;
return M2.take();
return M2.release();
}

Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
Expand All @@ -49,7 +49,7 @@ Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
return 0;
}

return ParseAssembly(File.take(), 0, Err, Context);
return ParseAssembly(File.release(), 0, Err, Context);
}

Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/LLVMTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
return true;

// If successful, createAsmPrinter took ownership of AsmStreamer.
AsmStreamer.take();
AsmStreamer.release();

PM.add(Printer);

Expand Down Expand Up @@ -292,7 +292,7 @@ bool LLVMTargetMachine::addPassesToEmitMC(PassManagerBase &PM,
return true;

// If successful, createAsmPrinter took ownership of AsmStreamer.
AsmStreamer.take();
AsmStreamer.release();

PM.add(Printer);

Expand Down
6 changes: 3 additions & 3 deletions lib/CodeGen/RegAllocPBQP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class RegAllocPBQP : public MachineFunctionPass {

/// Construct a PBQP register allocator.
RegAllocPBQP(OwningPtr<PBQPBuilder> &b, char *cPassID=0)
: MachineFunctionPass(ID), builder(b.take()), customPassID(cPassID) {
: MachineFunctionPass(ID), builder(b.release()), customPassID(cPassID) {
initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
initializeLiveStacksPass(*PassRegistry::getPassRegistry());
Expand Down Expand Up @@ -280,7 +280,7 @@ PBQPRAProblem *PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis,
}
}

return p.take();
return p.release();
}

void PBQPBuilder::addSpillCosts(PBQP::Vector &costVec,
Expand Down Expand Up @@ -391,7 +391,7 @@ PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf,
}
}

return p.take();
return p.release();
}

void PBQPBuilderWithCoalescing::addPhysRegCoalesce(PBQP::Vector &costVec,
Expand Down
10 changes: 5 additions & 5 deletions lib/DebugInfo/DWARFContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void DWARFContext::parseCompileUnits() {
if (!CU->extract(DIData, &offset)) {
break;
}
CUs.push_back(CU.take());
CUs.push_back(CU.release());
offset = CUs.back()->getNextUnitOffset();
}
}
Expand All @@ -327,7 +327,7 @@ void DWARFContext::parseTypeUnits() {
&I->second.Relocs, isLittleEndian()));
if (!TU->extract(DIData, &offset))
break;
TUs.push_back(TU.take());
TUs.push_back(TU.release());
offset = TUs.back()->getNextUnitOffset();
}
}
Expand All @@ -346,7 +346,7 @@ void DWARFContext::parseDWOCompileUnits() {
if (!DWOCU->extract(DIData, &offset)) {
break;
}
DWOCUs.push_back(DWOCU.take());
DWOCUs.push_back(DWOCU.release());
offset = DWOCUs.back()->getNextUnitOffset();
}
}
Expand All @@ -366,7 +366,7 @@ void DWARFContext::parseDWOTypeUnits() {
isLittleEndian()));
if (!TU->extract(DIData, &offset))
break;
DWOTUs.push_back(TU.take());
DWOTUs.push_back(TU.release());
offset = DWOTUs.back()->getNextUnitOffset();
}
}
Expand Down Expand Up @@ -636,7 +636,7 @@ DWARFContextInMemory::DWARFContextInMemory(object::ObjectFile *Obj) :
// Make data point to uncompressed section contents and save its contents.
name = name.substr(1);
data = UncompressedSection->getBuffer();
UncompressedSections.push_back(UncompressedSection.take());
UncompressedSections.push_back(UncompressedSection.release());
}

StringRef *Section =
Expand Down
4 changes: 2 additions & 2 deletions lib/ExecutionEngine/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,12 +486,12 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
if (UseMCJIT && ExecutionEngine::MCJITCtor) {
ExecutionEngine *EE =
ExecutionEngine::MCJITCtor(M, ErrorStr, MCJMM ? MCJMM : JMM,
AllocateGVsWithCode, TheTM.take());
AllocateGVsWithCode, TheTM.release());
if (EE) return EE;
} else if (ExecutionEngine::JITCtor) {
ExecutionEngine *EE =
ExecutionEngine::JITCtor(M, ErrorStr, JMM,
AllocateGVsWithCode, TheTM.take());
AllocateGVsWithCode, TheTM.release());
if (EE) return EE;
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/ExecutionEngine/MCJIT/MCJIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ ObjectBufferStream* MCJIT::emitObject(Module *M) {
ObjCache->notifyObjectCompiled(M, MB.get());
}

return CompiledObject.take();
return CompiledObject.release();
}

void MCJIT::generateCodeForModule(Module *M) {
Expand All @@ -188,7 +188,7 @@ void MCJIT::generateCodeForModule(Module *M) {
if (0 != ObjCache) {
OwningPtr<MemoryBuffer> PreCompiledObject(ObjCache->getObject(M));
if (0 != PreCompiledObject.get())
ObjectToLoad.reset(new ObjectBuffer(PreCompiledObject.take()));
ObjectToLoad.reset(new ObjectBuffer(PreCompiledObject.release()));
}

// If the cache did not contain a suitable object, compile the object
Expand All @@ -199,7 +199,7 @@ void MCJIT::generateCodeForModule(Module *M) {

// Load the object into the dynamic linker.
// MCJIT now owns the ObjectImage pointer (via its LoadedObjects list).
ObjectImage *LoadedObject = Dyld.loadObject(ObjectToLoad.take());
ObjectImage *LoadedObject = Dyld.loadObject(ObjectToLoad.release());
LoadedObjects.push_back(LoadedObject);
if (!LoadedObject)
report_fatal_error(Dyld.getErrorString());
Expand Down Expand Up @@ -308,7 +308,7 @@ uint64_t MCJIT::getSymbolAddress(const std::string &Name,
// FIXME: Support nested archives?
if (!ChildIt->getAsBinary(ChildBin) && ChildBin->isObject()) {
object::ObjectFile *OF = reinterpret_cast<object::ObjectFile *>(
ChildBin.take());
ChildBin.release());
// This causes the object file to be loaded.
addObjectFile(OF);
// The address should be here now.
Expand Down
2 changes: 1 addition & 1 deletion lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) {
// Give the subclasses a chance to tie-up any loose ends.
finalizeLoad(LocalSections);

return Obj.take();
return Obj.release();
}

// A helper method for computeTotalAllocSize.
Expand Down
4 changes: 2 additions & 2 deletions lib/IR/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2539,7 +2539,7 @@ LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(
OwningPtr<MemoryBuffer> MB;
error_code ec;
if (!(ec = MemoryBuffer::getFile(Path, MB))) {
*OutMemBuf = wrap(MB.take());
*OutMemBuf = wrap(MB.release());
return 0;
}

Expand All @@ -2552,7 +2552,7 @@ LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf,
OwningPtr<MemoryBuffer> MB;
error_code ec;
if (!(ec = MemoryBuffer::getSTDIN(MB))) {
*OutMemBuf = wrap(MB.take());
*OutMemBuf = wrap(MB.release());
return 0;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/IRReader/IRReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Module *llvm::getLazyIRFileModule(const std::string &Filename, SMDiagnostic &Err
return 0;
}

return getLazyIRModule(File.take(), Err, Context);
return getLazyIRModule(File.release(), Err, Context);
}

Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err,
Expand Down Expand Up @@ -93,7 +93,7 @@ Module *llvm::ParseIRFile(const std::string &Filename, SMDiagnostic &Err,
return 0;
}

return ParseIR(File.take(), Err, Context);
return ParseIR(File.release(), Err, Context);
}

//===----------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion lib/LTO/LTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ const void* LTOCodeGenerator::compile(size_t* length,
sys::fs::remove(NativeObjectPath);
return NULL;
}
NativeObjectFile = BuffPtr.take();
NativeObjectFile = BuffPtr.release();

// remove temp files
sys::fs::remove(NativeObjectPath);
Expand Down
10 changes: 5 additions & 5 deletions lib/LTO/LTOModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bool LTOModule::isBitcodeFileForTarget(const char *path,
OwningPtr<MemoryBuffer> buffer;
if (MemoryBuffer::getFile(path, buffer))
return false;
return isTargetMatch(buffer.take(), triplePrefix);
return isTargetMatch(buffer.release(), triplePrefix);
}

/// isTargetMatch - Returns 'true' if the memory buffer is for the specified
Expand All @@ -103,7 +103,7 @@ LTOModule *LTOModule::makeLTOModule(const char *path, TargetOptions options,
errMsg = ec.message();
return NULL;
}
return makeLTOModule(buffer.take(), options, errMsg);
return makeLTOModule(buffer.release(), options, errMsg);
}

LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
Expand All @@ -123,7 +123,7 @@ LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
errMsg = ec.message();
return NULL;
}
return makeLTOModule(buffer.take(), options, errMsg);
return makeLTOModule(buffer.release(), options, errMsg);
}

LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
Expand All @@ -132,7 +132,7 @@ LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length, path));
if (!buffer)
return NULL;
return makeLTOModule(buffer.take(), options, errMsg);
return makeLTOModule(buffer.release(), options, errMsg);
}

LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
Expand Down Expand Up @@ -175,7 +175,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
options);
m->materializeAllPermanently();

LTOModule *Ret = new LTOModule(m.take(), target);
LTOModule *Ret = new LTOModule(m.release(), target);

// We need a MCContext set up in order to get mangled names of private
// symbols. It is a bit odd that we need to report uses and definitions
Expand Down
2 changes: 1 addition & 1 deletion lib/MC/MCDisassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
}

void MCDisassembler::setSymbolizer(OwningPtr<MCSymbolizer> &Symzer) {
Symbolizer.reset(Symzer.take());
Symbolizer.reset(Symzer.release());
}
2 changes: 1 addition & 1 deletion lib/MC/MCDisassembler/Disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ LLVMDisasmContextRef LLVMCreateDisasmCPU(const char *Triple, const char *CPU,

OwningPtr<MCSymbolizer> Symbolizer(
TheTarget->createMCSymbolizer(Triple, GetOpInfo, SymbolLookUp, DisInfo,
Ctx, RelInfo.take()));
Ctx, RelInfo.release()));
DisAsm->setSymbolizer(Symbolizer);
DisAsm->setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo,
Ctx, RelInfo);
Expand Down
2 changes: 1 addition & 1 deletion lib/MC/MCSymbolizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
using namespace llvm;

MCSymbolizer::MCSymbolizer(MCContext &Ctx, OwningPtr<MCRelocationInfo> &RelInfo)
: Ctx(Ctx), RelInfo(RelInfo.take()) {
: Ctx(Ctx), RelInfo(RelInfo.release()) {
}

MCSymbolizer::~MCSymbolizer() {
Expand Down
8 changes: 4 additions & 4 deletions lib/Object/Binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ErrorOr<Binary *> object::createBinary(MemoryBuffer *Source,

switch (Type) {
case sys::fs::file_magic::archive:
return Archive::create(scopedSource.take());
return Archive::create(scopedSource.release());
case sys::fs::file_magic::elf_relocatable:
case sys::fs::file_magic::elf_executable:
case sys::fs::file_magic::elf_shared_object:
Expand All @@ -67,10 +67,10 @@ ErrorOr<Binary *> object::createBinary(MemoryBuffer *Source,
case sys::fs::file_magic::coff_import_library:
case sys::fs::file_magic::pecoff_executable:
case sys::fs::file_magic::bitcode:
return ObjectFile::createSymbolicFile(scopedSource.take(), true, Type,
return ObjectFile::createSymbolicFile(scopedSource.release(), true, Type,
Context);
case sys::fs::file_magic::macho_universal_binary:
return MachOUniversalBinary::create(scopedSource.take());
return MachOUniversalBinary::create(scopedSource.release());
case sys::fs::file_magic::unknown:
case sys::fs::file_magic::windows_resource:
// Unrecognized object file format.
Expand All @@ -83,5 +83,5 @@ ErrorOr<Binary *> object::createBinary(StringRef Path) {
OwningPtr<MemoryBuffer> File;
if (error_code EC = MemoryBuffer::getFileOrSTDIN(Path, File))
return EC;
return createBinary(File.take());
return createBinary(File.release());
}
2 changes: 1 addition & 1 deletion lib/Object/COFFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,5 +1071,5 @@ ErrorOr<ObjectFile *> ObjectFile::createCOFFObjectFile(MemoryBuffer *Object,
OwningPtr<COFFObjectFile> Ret(new COFFObjectFile(Object, EC, BufferOwned));
if (EC)
return EC;
return Ret.take();
return Ret.release();
}
2 changes: 1 addition & 1 deletion lib/Object/ELFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ErrorOr<ObjectFile *> ObjectFile::createELFObjectFile(MemoryBuffer *Obj,

if (EC)
return EC;
return R.take();
return R.release();
}

} // end namespace llvm
2 changes: 1 addition & 1 deletion lib/Object/IRObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,5 @@ ErrorOr<SymbolicFile *> llvm::object::SymbolicFile::createIRObjectFile(
new IRObjectFile(Object, EC, Context, BufferOwned));
if (EC)
return EC;
return Ret.take();
return Ret.release();
}
2 changes: 1 addition & 1 deletion lib/Object/MachOObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,7 @@ ErrorOr<ObjectFile *> ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer,

if (EC)
return EC;
return Ret.take();
return Ret.release();
}

} // end namespace object
Expand Down
2 changes: 1 addition & 1 deletion lib/Object/MachOUniversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ MachOUniversalBinary::create(MemoryBuffer *Source) {
OwningPtr<MachOUniversalBinary> Ret(new MachOUniversalBinary(Source, EC));
if (EC)
return EC;
return Ret.take();
return Ret.release();
}

MachOUniversalBinary::MachOUniversalBinary(MemoryBuffer *Source,
Expand Down
2 changes: 1 addition & 1 deletion lib/Object/ObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ ErrorOr<ObjectFile *> ObjectFile::createObjectFile(StringRef ObjectPath) {
OwningPtr<MemoryBuffer> File;
if (error_code EC = MemoryBuffer::getFile(ObjectPath, File))
return EC;
return createObjectFile(File.take());
return createObjectFile(File.release());
}
2 changes: 1 addition & 1 deletion lib/Support/SourceMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ size_t SourceMgr::AddIncludeFile(const std::string &Filename,

if (!NewBuf) return ~0U;

return AddNewSourceBuffer(NewBuf.take(), IncludeLoc);
return AddNewSourceBuffer(NewBuf.release(), IncludeLoc);
}


Expand Down
2 changes: 1 addition & 1 deletion lib/TableGen/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int TableGenMain(char *argv0, TableGenMainFn *MainFn) {
<< ec.message() <<"\n";
return 1;
}
MemoryBuffer *F = File.take();
MemoryBuffer *F = File.release();

// Tell SrcMgr about this buffer, which is what TGParser will pick up.
SrcMgr.AddNewSourceBuffer(F, SMLoc());
Expand Down
2 changes: 1 addition & 1 deletion lib/Transforms/Utils/SpecialCaseList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ SpecialCaseList *SpecialCaseList::create(
OwningPtr<SpecialCaseList> SCL(new SpecialCaseList());
if (!SCL->parse(MB, Error))
return 0;
return SCL.take();
return SCL.release();
}

SpecialCaseList *SpecialCaseList::createOrDie(const StringRef Path) {
Expand Down
Loading

0 comments on commit 1a6eca2

Please sign in to comment.