[C++11] Replace OwningPtr::take() with OwningPtr::release().

llvm-svn: 202957
This commit is contained in:
Ahmed Charles 2014-03-05 10:19:29 +00:00
parent 17220c1886
commit 96c9d95f51
43 changed files with 117 additions and 117 deletions

View File

@ -68,7 +68,7 @@ public:
/// 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.

View File

@ -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,
@ -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,

View File

@ -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);
@ -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);

View File

@ -89,7 +89,7 @@ public:
/// 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());
@ -280,7 +280,7 @@ PBQPRAProblem *PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis,
}
}
return p.take();
return p.release();
}
void PBQPBuilder::addSpillCosts(PBQP::Vector &costVec,
@ -391,7 +391,7 @@ PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf,
}
}
return p.take();
return p.release();
}
void PBQPBuilderWithCoalescing::addPhysRegCoalesce(PBQP::Vector &costVec,

View File

@ -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();
}
}
@ -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();
}
}
@ -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();
}
}
@ -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();
}
}
@ -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 =

View File

@ -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;
}
}

View File

@ -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) {
@ -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
@ -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());
@ -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.

View File

@ -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.

View File

@ -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;
}
@ -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;
}

View File

@ -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,
@ -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);
}
//===----------------------------------------------------------------------===//

View File

@ -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);

View File

@ -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
@ -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,
@ -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,
@ -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,
@ -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

View File

@ -52,5 +52,5 @@ void MCDisassembler::tryAddingPcLoadReferenceComment(int64_t Value,
}
void MCDisassembler::setSymbolizer(OwningPtr<MCSymbolizer> &Symzer) {
Symbolizer.reset(Symzer.take());
Symbolizer.reset(Symzer.release());
}

View File

@ -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);

View File

@ -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() {

View File

@ -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:
@ -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.
@ -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());
}

View File

@ -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();
}

View File

@ -79,7 +79,7 @@ ErrorOr<ObjectFile *> ObjectFile::createELFObjectFile(MemoryBuffer *Obj,
if (EC)
return EC;
return R.take();
return R.release();
}
} // end namespace llvm

View File

@ -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();
}

View File

@ -1565,7 +1565,7 @@ ErrorOr<ObjectFile *> ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer,
if (EC)
return EC;
return Ret.take();
return Ret.release();
}
} // end namespace object

View File

@ -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,

View File

@ -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());
}

View File

@ -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);
}

View File

@ -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());

View File

@ -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) {

View File

@ -145,7 +145,7 @@ ReduceMiscompilingPasses::doTest(std::vector<std::string> &Prefix,
<< "' passes compile correctly after the '"
<< getPassesString(Prefix) << "' passes: ";
OwningPtr<Module> OriginalInput(BD.swapProgramIn(PrefixOutput.take()));
OwningPtr<Module> OriginalInput(BD.swapProgramIn(PrefixOutput.release()));
if (BD.runPasses(BD.getProgram(), Suffix, BitcodeResult, false/*delete*/,
true/*quiet*/)) {
errs() << " Error running this sequence of passes"
@ -168,7 +168,7 @@ ReduceMiscompilingPasses::doTest(std::vector<std::string> &Prefix,
// Otherwise, we must not be running the bad pass anymore.
outs() << " yup.\n"; // No miscompilation!
// Restore orig program & free test.
delete BD.swapProgramIn(OriginalInput.take());
delete BD.swapProgramIn(OriginalInput.release());
return NoFailure;
}

View File

@ -544,7 +544,7 @@ int main(int argc, char **argv, char * const *envp) {
Err.print(argv[0], errs());
return 1;
}
object::Archive *Ar = new object::Archive(ArBuf.take(), ec);
object::Archive *Ar = new object::Archive(ArBuf.release(), ec);
if (ec || !Ar) {
Err.print(argv[0], errs());
return 1;

View File

@ -785,7 +785,7 @@ static void performWriteOperation(ArchiveOperation Operation,
object::Archive::child_iterator OldMember = Member.getOld();
failIfError(OldMember->getMemoryBuffer(MemberBuffer));
}
MemberBuffers[I] = MemberBuffer.take();
MemberBuffers[I] = MemberBuffer.release();
}
if (Symtab) {
@ -947,7 +947,7 @@ static int performOperation(ArchiveOperation Operation) {
}
if (!EC) {
object::Archive Archive(Buf.take(), EC);
object::Archive Archive(Buf.release(), EC);
if (EC) {
errs() << ToolName << ": error loading '" << ArchiveName

View File

@ -94,7 +94,7 @@ static void DumpInput(const StringRef &Filename) {
return;
}
ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(Buff.take()));
ErrorOr<ObjectFile*> ObjOrErr(ObjectFile::createObjectFile(Buff.release()));
if (error_code EC = ObjOrErr.getError()) {
errs() << Filename << ": " << EC.message() << '\n';
return;

View File

@ -368,7 +368,7 @@ int main(int argc, char **argv) {
errs() << ProgName << ": " << ec.message() << '\n';
return 1;
}
MemoryBuffer *Buffer = BufferPtr.take();
MemoryBuffer *Buffer = BufferPtr.release();
SourceMgr SrcMgr;

View File

@ -141,7 +141,7 @@ static void parseMCMarkup(StringRef Filename) {
errs() << ToolName << ": " << ec.message() << '\n';
return;
}
MemoryBuffer *Buffer = BufferPtr.take();
MemoryBuffer *Buffer = BufferPtr.release();
SourceMgr SrcMgr;

View File

@ -523,7 +523,7 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
return;
LLVMContext &Context = getGlobalContext();
ErrorOr<Binary *> BinaryOrErr = createBinary(Buffer.take(), &Context);
ErrorOr<Binary *> BinaryOrErr = createBinary(Buffer.release(), &Context);
if (error(BinaryOrErr.getError(), Filename))
return;
OwningPtr<Binary> Bin(BinaryOrErr.get());

View File

@ -209,7 +209,7 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
}
OwningPtr<MachOObjectFile> MachOOF(static_cast<MachOObjectFile *>(
ObjectFile::createMachOObjectFile(Buff.take()).get()));
ObjectFile::createMachOObjectFile(Buff.release()).get()));
DisassembleInputMachO2(Filename, MachOOF.get());
}
@ -297,7 +297,7 @@ static void DisassembleInputMachO2(StringRef Filename,
errs() << "llvm-objdump: " << Filename << ": " << ec.message() << '\n';
return;
}
DbgObj = ObjectFile::createMachOObjectFile(Buf.take()).get();
DbgObj = ObjectFile::createMachOObjectFile(Buf.release()).get();
}
// Setup the DIContext

View File

@ -140,7 +140,7 @@ static int printLineInfoForInput() {
return Error("unable to read input: '" + ec.message() + "'");
// Load the object file
LoadedObject.reset(Dyld.loadObject(new ObjectBuffer(InputBuffer.take())));
LoadedObject.reset(Dyld.loadObject(new ObjectBuffer(InputBuffer.release())));
if (!LoadedObject) {
return Error(Dyld.getErrorString());
}
@ -198,7 +198,7 @@ static int executeInput() {
return Error("unable to read input: '" + ec.message() + "'");
// Load the object file
LoadedObject.reset(Dyld.loadObject(new ObjectBuffer(InputBuffer.take())));
LoadedObject.reset(Dyld.loadObject(new ObjectBuffer(InputBuffer.release())));
if (!LoadedObject) {
return Error(Dyld.getErrorString());
}

View File

@ -315,7 +315,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
if (!error(BinaryOrErr.getError())) {
OwningPtr<Binary> ParsedBinary(BinaryOrErr.get());
// Check if it's a universal binary.
Bin = ParsedBinary.take();
Bin = ParsedBinary.release();
ParsedBinariesAndObjects.push_back(Bin);
if (Bin->isMachO() || Bin->isMachOUniversalBinary()) {
// On Darwin we may find DWARF in separate object file in
@ -363,7 +363,7 @@ LLVMSymbolizer::getObjectFileFromBinary(Binary *Bin, const std::string &ArchName
return I->second;
OwningPtr<ObjectFile> ParsedObj;
if (!UB->getObjectForArch(Triple(ArchName).getArch(), ParsedObj)) {
Res = ParsedObj.take();
Res = ParsedObj.release();
ParsedBinariesAndObjects.push_back(Res);
}
ObjectFileForArch[std::make_pair(UB, ArchName)] = Res;

View File

@ -45,7 +45,7 @@ int main(int argc, char *argv[]) {
errs() << "Error: '" << ec.message() << "' opening file '" << InputFilename
<< "'\n";
} else {
ec = coff2yaml(outs(), buf.take());
ec = coff2yaml(outs(), buf.release());
if (ec)
errs() << "Error: " << ec.message() << " dumping COFF file\n";
}

View File

@ -94,8 +94,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_case) {
Function *FA, *FB;
createTwoModuleCase(A, FA, B, FB);
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
checkAdd(ptr);
@ -114,8 +114,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_reverse_case) {
Function *FA, *FB;
createTwoModuleCase(A, FA, B, FB);
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
TheJIT->finalizeObject();
@ -135,8 +135,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_extern_reverse_case) {
Function *FA, *FB;
createTwoModuleExternCase(A, FA, B, FB);
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
TheJIT->finalizeObject();
@ -156,8 +156,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_extern_case) {
Function *FA, *FB;
createTwoModuleExternCase(A, FA, B, FB);
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
checkAdd(ptr);
@ -177,8 +177,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_consecutive_call_case) {
createTwoModuleExternCase(A, FA1, B, FB);
FA2 = insertSimpleCallFunction<int32_t(int32_t, int32_t)>(A.get(), FA1);
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
TheJIT->finalizeObject();
@ -213,8 +213,8 @@ TEST_F(MCJITMultipleModuleTest, two_module_global_variables_case) {
FB = startFunction<int32_t(void)>(B.get(), "FB");
endFunctionWithRet(FB, Builder.CreateLoad(GVB));
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t FBPtr = TheJIT->getFunctionAddress(FB->getName().str());
TheJIT->finalizeObject();
@ -241,9 +241,9 @@ TEST_F(MCJITMultipleModuleTest, three_module_case) {
Function *FA, *FB, *FC;
createThreeModuleCase(A, FA, B, FB, C, FC);
createJIT(A.take());
TheJIT->addModule(B.take());
TheJIT->addModule(C.take());
createJIT(A.release());
TheJIT->addModule(B.release());
TheJIT->addModule(C.release());
uint64_t ptr = TheJIT->getFunctionAddress(FC->getName().str());
checkAdd(ptr);
@ -266,9 +266,9 @@ TEST_F(MCJITMultipleModuleTest, three_module_case_reverse_order) {
Function *FA, *FB, *FC;
createThreeModuleCase(A, FA, B, FB, C, FC);
createJIT(A.take());
TheJIT->addModule(B.take());
TheJIT->addModule(C.take());
createJIT(A.release());
TheJIT->addModule(B.release());
TheJIT->addModule(C.release());
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
checkAdd(ptr);
@ -291,9 +291,9 @@ TEST_F(MCJITMultipleModuleTest, three_module_chain_case) {
Function *FA, *FB, *FC;
createThreeModuleChainedCallsCase(A, FA, B, FB, C, FC);
createJIT(A.take());
TheJIT->addModule(B.take());
TheJIT->addModule(C.take());
createJIT(A.release());
TheJIT->addModule(B.release());
TheJIT->addModule(C.release());
uint64_t ptr = TheJIT->getFunctionAddress(FC->getName().str());
checkAdd(ptr);
@ -316,9 +316,9 @@ TEST_F(MCJITMultipleModuleTest, three_modules_chain_case_reverse_order) {
Function *FA, *FB, *FC;
createThreeModuleChainedCallsCase(A, FA, B, FB, C, FC);
createJIT(A.take());
TheJIT->addModule(B.take());
TheJIT->addModule(C.take());
createJIT(A.release());
TheJIT->addModule(B.release());
TheJIT->addModule(C.release());
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
checkAdd(ptr);
@ -341,8 +341,8 @@ TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case) {
Function *FA, *FB1, *FB2;
createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
checkAccumulate(ptr);
@ -362,8 +362,8 @@ TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case_reverse_order) {
Function *FA, *FB1, *FB2;
createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t ptr = TheJIT->getFunctionAddress(FB1->getName().str());
checkAccumulate(ptr);
@ -383,8 +383,8 @@ TEST_F(MCJITMultipleModuleTest, cross_module_dependency_case3) {
Function *FA, *FB1, *FB2;
createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
createJIT(A.take());
TheJIT->addModule(B.take());
createJIT(A.release());
TheJIT->addModule(B.release());
uint64_t ptr = TheJIT->getFunctionAddress(FB1->getName().str());
checkAccumulate(ptr);

View File

@ -122,7 +122,7 @@ protected:
TEST_F(MCJITObjectCacheTest, SetNullObjectCache) {
SKIP_UNSUPPORTED_PLATFORM;
createJIT(M.take());
createJIT(M.release());
TheJIT->setObjectCache(NULL);
@ -138,7 +138,7 @@ TEST_F(MCJITObjectCacheTest, VerifyBasicObjectCaching) {
// Save a copy of the module pointer before handing it off to MCJIT.
const Module * SavedModulePointer = M.get();
createJIT(M.take());
createJIT(M.release());
TheJIT->setObjectCache(Cache.get());
@ -165,7 +165,7 @@ TEST_F(MCJITObjectCacheTest, VerifyLoadFromCache) {
OwningPtr<TestObjectCache> Cache(new TestObjectCache);
// Compile this module with an MCJIT engine
createJIT(M.take());
createJIT(M.release());
TheJIT->setObjectCache(Cache.get());
TheJIT->finalizeObject();
@ -182,7 +182,7 @@ TEST_F(MCJITObjectCacheTest, VerifyLoadFromCache) {
const Module * SecondModulePointer = M.get();
// Create a new MCJIT instance to load this module then execute it.
createJIT(M.take());
createJIT(M.release());
TheJIT->setObjectCache(Cache.get());
compileAndRun();
@ -199,7 +199,7 @@ TEST_F(MCJITObjectCacheTest, VerifyNonLoadFromCache) {
OwningPtr<TestObjectCache> Cache(new TestObjectCache);
// Compile this module with an MCJIT engine
createJIT(M.take());
createJIT(M.release());
TheJIT->setObjectCache(Cache.get());
TheJIT->finalizeObject();
@ -217,7 +217,7 @@ TEST_F(MCJITObjectCacheTest, VerifyNonLoadFromCache) {
const Module * SecondModulePointer = M.get();
// Create a new MCJIT instance to load this module then execute it.
createJIT(M.take());
createJIT(M.release());
TheJIT->setObjectCache(Cache.get());
// Verify that our object cache does not contain the module yet.

View File

@ -49,7 +49,7 @@ TEST_F(MCJITTest, global_variable) {
int initialValue = 5;
GlobalValue *Global = insertGlobalInt32(M.get(), "test_global", initialValue);
createJIT(M.take());
createJIT(M.release());
void *globalPtr = TheJIT->getPointerToGlobal(Global);
EXPECT_TRUE(0 != globalPtr)
<< "Unable to get pointer to global value from JIT";
@ -62,7 +62,7 @@ TEST_F(MCJITTest, add_function) {
SKIP_UNSUPPORTED_PLATFORM;
Function *F = insertAddFunction(M.get());
createJIT(M.take());
createJIT(M.release());
uint64_t addPtr = TheJIT->getFunctionAddress(F->getName().str());
EXPECT_TRUE(0 != addPtr)
<< "Unable to get pointer to function from JIT";
@ -83,7 +83,7 @@ TEST_F(MCJITTest, run_main) {
int rc = 6;
Function *Main = insertMainFunction(M.get(), 6);
createJIT(M.take());
createJIT(M.release());
uint64_t ptr = TheJIT->getFunctionAddress(Main->getName().str());
EXPECT_TRUE(0 != ptr)
<< "Unable to get pointer to main() from JIT";
@ -104,7 +104,7 @@ TEST_F(MCJITTest, return_global) {
Value *ReadGlobal = Builder.CreateLoad(GV);
endFunctionWithRet(ReturnGlobal, ReadGlobal);
createJIT(M.take());
createJIT(M.release());
uint64_t rgvPtr = TheJIT->getFunctionAddress(ReturnGlobal->getName().str());
EXPECT_TRUE(0 != rgvPtr);
@ -175,7 +175,7 @@ TEST_F(MCJITTest, multiple_functions) {
Inner = Outer;
}
createJIT(M.take());
createJIT(M.release());
uint64_t ptr = TheJIT->getFunctionAddress(Outer->getName().str());
EXPECT_TRUE(0 != ptr)
<< "Unable to get pointer to outer function from JIT";

View File

@ -832,7 +832,7 @@ static bool ReadCheckFile(SourceMgr &SM,
// If we want to canonicalize whitespace, strip excess whitespace from the
// buffer containing the CHECK lines. Remove DOS style line endings.
MemoryBuffer *F =
CanonicalizeInputFile(File.take(), NoCanonicalizeWhiteSpace);
CanonicalizeInputFile(File.release(), NoCanonicalizeWhiteSpace);
SM.AddNewSourceBuffer(F, SMLoc());
@ -1234,7 +1234,7 @@ int main(int argc, char **argv) {
// Remove duplicate spaces in the input file if requested.
// Remove DOS style line endings.
MemoryBuffer *F =
CanonicalizeInputFile(File.take(), NoCanonicalizeWhiteSpace);
CanonicalizeInputFile(File.release(), NoCanonicalizeWhiteSpace);
SM.AddNewSourceBuffer(F, SMLoc());

View File

@ -1366,7 +1366,7 @@ void AsmMatcherInfo::buildInfo() {
StringRef(II->TheDef->getName()).endswith("_Int"))
continue;
Matchables.push_back(II.take());
Matchables.push_back(II.release());
}
// Parse all of the InstAlias definitions and stick them in the list of
@ -1390,7 +1390,7 @@ void AsmMatcherInfo::buildInfo() {
// Validate the alias definitions.
II->validate(CommentDelimiter, false);
Matchables.push_back(II.take());
Matchables.push_back(II.release());
}
}
@ -1461,7 +1461,7 @@ void AsmMatcherInfo::buildInfo() {
AliasII->formTwoOperandAlias(Constraint);
// Add the alias to the matchables list.
NewMatchables.push_back(AliasII.take());
NewMatchables.push_back(AliasII.release());
}
} else
II->buildAliasResultOperands();

View File

@ -98,7 +98,7 @@ public:
Matcher *getNext() { return Next.get(); }
const Matcher *getNext() const { return Next.get(); }
void setNext(Matcher *C) { Next.reset(C); }
Matcher *takeNext() { return Next.take(); }
Matcher *takeNext() { return Next.release(); }
OwningPtr<Matcher> &getNextPtr() { return Next; }

View File

@ -33,7 +33,7 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr,
for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
OwningPtr<Matcher> Child(Scope->takeChild(i));
ContractNodes(Child, CGP);
Scope->resetChild(i, Child.take());
Scope->resetChild(i, Child.release());
}
return;
}
@ -62,7 +62,7 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr,
if (New) {
// Insert the new node.
New->setNext(MatcherPtr.take());
New->setNext(MatcherPtr.release());
MatcherPtr.reset(New);
// Remove the old one.
MC->setNext(MC->getNext()->takeNext());
@ -85,7 +85,7 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr,
if (isa<EmitNodeMatcher>(N) && isa<MarkGlueResultsMatcher>(N->getNext()) &&
isa<CompleteMatchMatcher>(N->getNext()->getNext())) {
// Unlink the two nodes from the list.
Matcher *EmitNode = MatcherPtr.take();
Matcher *EmitNode = MatcherPtr.release();
Matcher *MFR = EmitNode->takeNext();
Matcher *Tail = MFR->takeNext();
@ -164,7 +164,7 @@ static void ContractNodes(OwningPtr<Matcher> &MatcherPtr,
isa<RecordMatcher>(N)) &&
isa<CheckOpcodeMatcher>(N->getNext())) {
// Unlink the two nodes from the list.
Matcher *CheckType = MatcherPtr.take();
Matcher *CheckType = MatcherPtr.release();
Matcher *CheckOpcode = CheckType->takeNext();
Matcher *Tail = CheckOpcode->takeNext();
@ -198,7 +198,7 @@ static void SinkPatternPredicates(OwningPtr<Matcher> &MatcherPtr) {
for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
OwningPtr<Matcher> Child(Scope->takeChild(i));
SinkPatternPredicates(Child);
Scope->resetChild(i, Child.take());
Scope->resetChild(i, Child.release());
}
return;
}
@ -217,7 +217,7 @@ static void SinkPatternPredicates(OwningPtr<Matcher> &MatcherPtr) {
// Okay, we know we can sink it past at least one node. Unlink it from the
// chain and scan for the new insertion point.
MatcherPtr.take(); // Don't delete CPPM.
MatcherPtr.release(); // Don't delete CPPM.
MatcherPtr.reset(CPPM->takeNext());
N = MatcherPtr.get();
@ -272,7 +272,7 @@ static void FactorNodes(OwningPtr<Matcher> &MatcherPtr) {
OwningPtr<Matcher> Child(Scope->takeChild(i));
FactorNodes(Child);
if (Matcher *N = Child.take())
if (Matcher *N = Child.release())
OptionsToMatch.push_back(N);
}
@ -516,5 +516,5 @@ Matcher *llvm::OptimizeMatcher(Matcher *TheMatcher,
ContractNodes(MatcherPtr, CGP);
SinkPatternPredicates(MatcherPtr);
FactorNodes(MatcherPtr);
return MatcherPtr.take();
return MatcherPtr.release();
}