mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
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
This commit is contained in:
parent
0fe727a669
commit
a2eead0028
@ -64,9 +64,10 @@ LLVMObjectFileRef LLVMCreateObjectFile(LLVMMemoryBufferRef MemBuf) {
|
|||||||
ErrorOr<std::unique_ptr<ObjectFile>> ObjOrErr(
|
ErrorOr<std::unique_ptr<ObjectFile>> ObjOrErr(
|
||||||
ObjectFile::createObjectFile(Buf->getMemBufferRef()));
|
ObjectFile::createObjectFile(Buf->getMemBufferRef()));
|
||||||
std::unique_ptr<ObjectFile> Obj;
|
std::unique_ptr<ObjectFile> Obj;
|
||||||
if (ObjOrErr)
|
if (!ObjOrErr)
|
||||||
Obj = std::move(ObjOrErr.get());
|
return nullptr;
|
||||||
auto *Ret = new OwningBinary<ObjectFile>(std::move(Obj), std::move(Buf));
|
|
||||||
|
auto *Ret = new OwningBinary<ObjectFile>(std::move(ObjOrErr.get()), std::move(Buf));
|
||||||
return wrap(Ret);
|
return wrap(Ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
test/Bindings/llvm-c/objectfile.ll
Normal file
2
test/Bindings/llvm-c/objectfile.ll
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
; RUN: not llvm-c-test --object-list-sections < /dev/null
|
||||||
|
; This used to cause a segfault
|
Loading…
x
Reference in New Issue
Block a user