[llvm] r215566 - Simplify ownership with std::unique_ptr. NFC.
Rafael Espindola
rafael.espindola at gmail.com
Wed Aug 13 11:49:01 PDT 2014
Author: rafael
Date: Wed Aug 13 13:49:01 2014
New Revision: 215566
URL: http://llvm.org/viewvc/llvm-project?rev=215566&view=rev
Log:
Simplify ownership with std::unique_ptr. NFC.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/ObjectCache.h
llvm/trunk/tools/lli/lli.cpp
llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/ObjectCache.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ObjectCache.h?rev=215566&r1=215565&r2=215566&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/ObjectCache.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/ObjectCache.h Wed Aug 13 13:49:01 2014
@@ -29,11 +29,10 @@ public:
/// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
virtual void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) = 0;
- /// getObjectCopy - Returns a pointer to a newly allocated MemoryBuffer that
- /// contains the object which corresponds with Module M, or 0 if an object is
- /// not available. The caller owns both the MemoryBuffer returned by this
- /// and the memory it references.
- virtual MemoryBuffer* getObject(const Module* M) = 0;
+ /// Returns a pointer to a newly allocated MemoryBuffer that contains the
+ /// object which corresponds with Module M, or 0 if an object is not
+ /// available.
+ virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) = 0;
};
}
Modified: llvm/trunk/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=215566&r1=215565&r2=215566&view=diff
==============================================================================
--- llvm/trunk/tools/lli/lli.cpp (original)
+++ llvm/trunk/tools/lli/lli.cpp Wed Aug 13 13:49:01 2014
@@ -279,7 +279,7 @@ public:
outfile.close();
}
- MemoryBuffer* getObject(const Module* M) override {
+ std::unique_ptr<MemoryBuffer> getObject(const Module* M) override {
const std::string ModuleID = M->getModuleIdentifier();
std::string CacheName;
if (!getCacheFilename(ModuleID, CacheName))
@@ -294,7 +294,8 @@ public:
// because the file has probably just been mmapped. Instead we make
// a copy. The filed-based buffer will be released when it goes
// out of scope.
- return MemoryBuffer::getMemBufferCopy(IRObjectBuffer.get()->getBuffer());
+ return std::unique_ptr<MemoryBuffer>(
+ MemoryBuffer::getMemBufferCopy(IRObjectBuffer.get()->getBuffer()));
}
private:
Modified: llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp?rev=215566&r1=215565&r2=215566&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp Wed Aug 13 13:49:01 2014
@@ -44,14 +44,15 @@ public:
ObjMap[ModuleID] = copyBuffer(Obj);
}
- virtual MemoryBuffer* getObject(const Module* M) {
+ virtual std::unique_ptr<MemoryBuffer> getObject(const Module* M) {
const MemoryBuffer* BufferFound = getObjectInternal(M);
ModulesLookedUp.insert(M->getModuleIdentifier());
if (!BufferFound)
return nullptr;
// Our test cache wants to maintain ownership of its object buffers
// so we make a copy here for the execution engine.
- return MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer());
+ return std::unique_ptr<MemoryBuffer>(
+ MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer()));
}
// Test-harness-specific functions
More information about the llvm-commits
mailing list