summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Object/Object.cpp
diff options
context:
space:
mode:
authorBjorn Steinbrink <bsteinbr@gmail.com>2014-09-05 21:22:09 +0000
committerBjorn Steinbrink <bsteinbr@gmail.com>2014-09-05 21:22:09 +0000
commit5a121b2ef58e16d9565515126fc560bbe5d24eb5 (patch)
treeef9e540ef7d0a3c6ae8b7ddc0161f193b7ce3b06 /llvm/lib/Object/Object.cpp
parentf4b8debc1c6c030f241a0acc2d38d7e100cde65a (diff)
downloadbcm5719-llvm-5a121b2ef58e16d9565515126fc560bbe5d24eb5.tar.gz
bcm5719-llvm-5a121b2ef58e16d9565515126fc560bbe5d24eb5.zip
Restore the ability to check if LLVMCreateObjectFile was successful
Summary: Until r216870 LLVMCreateObjectFile returned nullptr in case of an error, so callers could check if the call was successful. Now, it always returns an OwningBinary wrapped as an LLVMObjectFileRef, so callers can't check if the call was successul. This results in a segfault running e.g. llvm-c-test --object-list-sections < /dev/null So the old behaviour should be restored. Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5143 llvm-svn: 217279
Diffstat (limited to 'llvm/lib/Object/Object.cpp')
-rw-r--r--llvm/lib/Object/Object.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Object/Object.cpp b/llvm/lib/Object/Object.cpp
index 4d3478bc14f..fea34113285 100644
--- a/llvm/lib/Object/Object.cpp
+++ b/llvm/lib/Object/Object.cpp
@@ -64,9 +64,10 @@ LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) {
ErrorOr<std::unique_ptr<ObjectFile>> ObjOrErr(
ObjectFile::createObjectFile(Buf->getMemBufferRef()));
std::unique_ptr<ObjectFile> Obj;
- if (ObjOrErr)
- Obj = std::move(ObjOrErr.get());
- auto *Ret = new OwningBinary<ObjectFile>(std::move(Obj), std::move(Buf));
+ if (!ObjOrErr)
+ return nullptr;
+
+ auto *Ret = new OwningBinary<ObjectFile>(std::move(ObjOrErr.get()), std::move(Buf));
return wrap(Ret);
}
OpenPOWER on IntegriCloud