diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-11 19:50:24 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-11 19:50:24 +0000 |
commit | 9b252f03d92e5474d84036822e4472f07763e1d6 (patch) | |
tree | d5bf13939f3ca7288190bd71bdb446cef003e892 /tools/llvm-lto | |
parent | 3352395b1c2ba18c1e7afd5e68ab20a4f4486df4 (diff) |
Bitcode: Clean up error handling for certain bitcode query functions.
The functions getBitcodeTargetTriple(), isBitcodeContainingObjCCategory(),
getBitcodeProducerString() and hasGlobalValueSummary() now return errors
via their return value rather than via the diagnostic handler.
To make this work, re-implement these functions using non-member functions
so that they can be used without the LLVMContext required by BitcodeReader.
Differential Revision: https://reviews.llvm.org/D26532
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286623 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-lto')
-rw-r--r-- | tools/llvm-lto/llvm-lto.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index 50c5f2348dd..d883f3cc229 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -773,12 +773,12 @@ int main(int argc, char **argv) { if (CheckHasObjC) { for (auto &Filename : InputFilenames) { - ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr = - MemoryBuffer::getFile(Filename); - error(BufferOrErr, "error loading file '" + Filename + "'"); + ExitOnError ExitOnErr(std::string(*argv) + ": error loading file '" + + Filename + "': "); + std::unique_ptr<MemoryBuffer> BufferOrErr = + ExitOnErr(errorOrToExpected(MemoryBuffer::getFile(Filename))); auto Buffer = std::move(BufferOrErr.get()); - LLVMContext Ctx; - if (llvm::isBitcodeContainingObjCCategory(*Buffer, Ctx)) + if (ExitOnErr(llvm::isBitcodeContainingObjCCategory(*Buffer))) outs() << "Bitcode " << Filename << " contains ObjC\n"; else outs() << "Bitcode " << Filename << " does not contain ObjC\n"; |