llvm.org GIT mirror llvm / d6448b2
Simplify ownership with std::unique_ptr. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215566 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
3 changed file(s) with 10 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
2828 /// notifyObjectCompiled - Provides a pointer to compiled code for Module M.
2929 virtual void notifyObjectCompiled(const Module *M, const MemoryBuffer *Obj) = 0;
3030
31 /// getObjectCopy - Returns a pointer to a newly allocated MemoryBuffer that
32 /// contains the object which corresponds with Module M, or 0 if an object is
33 /// not available. The caller owns both the MemoryBuffer returned by this
34 /// and the memory it references.
35 virtual MemoryBuffer* getObject(const Module* M) = 0;
31 /// Returns a pointer to a newly allocated MemoryBuffer that contains the
32 /// object which corresponds with Module M, or 0 if an object is not
33 /// available.
34 virtual std::unique_ptr getObject(const Module* M) = 0;
3635 };
3736
3837 }
278278 outfile.close();
279279 }
280280
281 MemoryBuffer* getObject(const Module* M) override {
281 std::unique_ptr getObject(const Module* M) override {
282282 const std::string ModuleID = M->getModuleIdentifier();
283283 std::string CacheName;
284284 if (!getCacheFilename(ModuleID, CacheName))
293293 // because the file has probably just been mmapped. Instead we make
294294 // a copy. The filed-based buffer will be released when it goes
295295 // out of scope.
296 return MemoryBuffer::getMemBufferCopy(IRObjectBuffer.get()->getBuffer());
296 return std::unique_ptr(
297 MemoryBuffer::getMemBufferCopy(IRObjectBuffer.get()->getBuffer()));
297298 }
298299
299300 private:
4343 ObjMap[ModuleID] = copyBuffer(Obj);
4444 }
4545
46 virtual MemoryBuffer* getObject(const Module* M) {
46 virtual std::unique_ptr getObject(const Module* M) {
4747 const MemoryBuffer* BufferFound = getObjectInternal(M);
4848 ModulesLookedUp.insert(M->getModuleIdentifier());
4949 if (!BufferFound)
5050 return nullptr;
5151 // Our test cache wants to maintain ownership of its object buffers
5252 // so we make a copy here for the execution engine.
53 return MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer());
53 return std::unique_ptr(
54 MemoryBuffer::getMemBufferCopy(BufferFound->getBuffer()));
5455 }
5556
5657 // Test-harness-specific functions