aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-08-13 18:59:01 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-08-13 18:59:01 +0000
commitbb415eac2e79cc9c6d761cdb427693d8936b4a62 (patch)
treeff5e5468fb9c33b6e71a2e9a1917265015dce1d9 /llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
parent5f2bb7d9b8303c164b5b61f59d2b402926ba8056 (diff)
downloadllvm-bb415eac2e79cc9c6d761cdb427693d8936b4a62.zip
llvm-bb415eac2e79cc9c6d761cdb427693d8936b4a62.tar.gz
llvm-bb415eac2e79cc9c6d761cdb427693d8936b4a62.tar.bz2
Simplify memory ownership with std::unique_ptr.
llvm-svn: 215567
Diffstat (limited to 'llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp')
-rw-r--r--llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp b/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
index 5732908c..4c3b5cf 100644
--- a/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
+++ b/llvm/unittests/ExecutionEngine/MCJIT/MCJITObjectCacheTest.cpp
@@ -25,16 +25,6 @@ class TestObjectCache : public ObjectCache {
public:
TestObjectCache() : DuplicateInserted(false) { }
- virtual ~TestObjectCache() {
- // Free any buffers we've allocated.
- SmallVectorImpl<MemoryBuffer *>::iterator it, end;
- end = AllocatedBuffers.end();
- for (it = AllocatedBuffers.begin(); it != end; ++it) {
- delete *it;
- }
- AllocatedBuffers.clear();
- }
-
virtual void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) {
// If we've seen this module before, note that.
const std::string ModuleID = M->getModuleIdentifier();
@@ -75,14 +65,16 @@ public:
private:
MemoryBuffer *copyBuffer(const MemoryBuffer *Buf) {
// Create a local copy of the buffer.
- MemoryBuffer *NewBuffer = MemoryBuffer::getMemBufferCopy(Buf->getBuffer());
- AllocatedBuffers.push_back(NewBuffer);
- return NewBuffer;
+ std::unique_ptr<MemoryBuffer> NewBuffer(
+ MemoryBuffer::getMemBufferCopy(Buf->getBuffer()));
+ MemoryBuffer *Ret = NewBuffer.get();
+ AllocatedBuffers.push_back(std::move(NewBuffer));
+ return Ret;
}
StringMap<const MemoryBuffer *> ObjMap;
StringSet<> ModulesLookedUp;
- SmallVector<MemoryBuffer *, 2> AllocatedBuffers;
+ SmallVector<std::unique_ptr<MemoryBuffer>, 2> AllocatedBuffers;
bool DuplicateInserted;
};