summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-09-03 21:34:34 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-09-03 21:34:34 +0000
commitfba8b20d98afebd0b11b675b2a10c891b12c2b5b (patch)
tree8b7a5c0059b0e4b08f8899cf3e8d5363b53ddbd6 /llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
parented3d48f16128304821e884b4e4ff0ec6f95323bf (diff)
downloadbcm5719-llvm-fba8b20d98afebd0b11b675b2a10c891b12c2b5b.tar.gz
bcm5719-llvm-fba8b20d98afebd0b11b675b2a10c891b12c2b5b.zip
unique_ptrify RuntimeDyldImpl::loadObject
I'm not sure this is a particularly helpful API (to pass ownership and then return it unconditionally) rather than just pass the underlying object by non-const reference, but this was the original API so I'll just make it more safe/stable and anyone else is free to adjust that at their whim, of course. llvm-svn: 217081
Diffstat (limited to 'llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
index 1f326d8c478..895ba05bccd 100644
--- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
+++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
@@ -137,10 +137,10 @@ static std::error_code getOffset(const SymbolRef &Sym, uint64_t &Result) {
return object_error::success;
}
-ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) {
+std::unique_ptr<ObjectImage>
+RuntimeDyldImpl::loadObject(std::unique_ptr<ObjectImage> Obj) {
MutexGuard locked(lock);
- std::unique_ptr<ObjectImage> Obj(InputObject);
if (!Obj)
return nullptr;
@@ -250,7 +250,7 @@ ObjectImage *RuntimeDyldImpl::loadObject(ObjectImage *InputObject) {
// Give the subclasses a chance to tie-up any loose ends.
finalizeLoad(*Obj, LocalSections);
- return Obj.release();
+ return Obj;
}
// A helper method for computeTotalAllocSize.
@@ -816,8 +816,7 @@ RuntimeDyld::loadObject(std::unique_ptr<ObjectFile> InputObject) {
if (!Dyld->isCompatibleFile(&Obj))
report_fatal_error("Incompatible object format!");
- Dyld->loadObject(InputImage.get());
- return InputImage;
+ return Dyld->loadObject(std::move(InputImage));
}
std::unique_ptr<ObjectImage>
@@ -865,8 +864,7 @@ RuntimeDyld::loadObject(std::unique_ptr<ObjectBuffer> InputBuffer) {
if (!Dyld->isCompatibleFormat(InputBufferPtr))
report_fatal_error("Incompatible object format!");
- Dyld->loadObject(InputImage.get());
- return InputImage;
+ return Dyld->loadObject(std::move(InputImage));
}
void *RuntimeDyld::getSymbolAddress(StringRef Name) {
OpenPOWER on IntegriCloud