Index: include/llvm/Bitcode/NaCl/NaClReaderWriter.h |
diff --git a/include/llvm/Bitcode/NaCl/NaClReaderWriter.h b/include/llvm/Bitcode/NaCl/NaClReaderWriter.h |
index 4b92e4767c21d501c6e4f966ff42cc341554ca3e..78ceddce6c278f5629bce9690990b9890379cd79 100644 |
--- a/include/llvm/Bitcode/NaCl/NaClReaderWriter.h |
+++ b/include/llvm/Bitcode/NaCl/NaClReaderWriter.h |
@@ -17,6 +17,7 @@ |
#define LLVM_BITCODE_NACL_NACLREADERWRITER_H |
#include "llvm/Support/CommandLine.h" |
+#include "llvm/Support/ErrorOr.h" |
#include <string> |
@@ -44,9 +45,11 @@ namespace llvm { |
/// getNaClLazyBitcodeModule - Read the header of the specified bitcode buffer |
/// and prepare for lazy deserialization of function bodies. If successful, |
- /// this takes ownership of 'buffer' and returns a non-null pointer. On |
- /// error, this returns null, *does not* take ownership of Buffer, and fills |
- /// in *ErrMsg with an error description if ErrMsg is non-null. |
+ /// takes ownership of 'buffer' and returns a non-null pointer. On |
+ /// error, this returns an error code and *does not* take ownership of Buffer. |
+ /// |
+ /// When Verbose is non-null, more descriptive error messages are also |
+ /// written to Verbose. |
/// |
/// The AcceptSupportedOnly argument is used to decide which PNaCl versions |
/// of the PNaCl bitcode to accept. There are three forms: |
@@ -56,34 +59,38 @@ namespace llvm { |
/// 3) Unreadable. |
/// When AcceptSupportedOnly is true, only form 1 is allowed. When |
/// AcceptSupportedOnly is false, forms 1 and 2 are allowed. |
- Module *getNaClLazyBitcodeModule(MemoryBuffer *Buffer, |
- LLVMContext &Context, |
- std::string *ErrMsg = 0, |
- bool AcceptSupportedOnly = true); |
+ ErrorOr<Module *> getNaClLazyBitcodeModule(MemoryBuffer *Buffer, |
+ LLVMContext &Context, |
+ raw_ostream *Verbose = nullptr, |
+ bool AcceptSupportedOnly = true); |
/// getNaClStreamedBitcodeModule - Read the header of the specified stream |
/// and prepare for lazy deserialization and streaming of function bodies. |
/// On error, this returns null, and fills in *ErrMsg with an error |
/// description if ErrMsg is non-null. |
/// |
- /// See getNaClLazyBitcodeModule for an explanation of argument |
- /// AcceptSupportedOnly. |
+ /// See getNaClLazyBitcodeModule for an explanation of arguments |
+ /// Verbose, AcceptSupportedOnly. |
+ /// TODO(kschimpf): Refactor this and getStreamedBitcodeModule to use |
+ /// ErrorOr<Module *> API so that all methods have the same interface. |
Module *getNaClStreamedBitcodeModule(const std::string &name, |
StreamingMemoryObject *streamer, |
LLVMContext &Context, |
- std::string *ErrMsg = 0, |
+ raw_ostream *Verbose = nullptr, |
+ std::string *ErrMsg = nullptr, |
bool AcceptSupportedOnly = true); |
/// NaClParseBitcodeFile - Read the specified bitcode file, |
- /// returning the module. If an error occurs, this returns null and |
- /// fills in *ErrMsg if it is non-null. This method *never* takes |
- /// ownership of Buffer. |
+ /// returning the module. If successful, takes ownership of |
+ /// 'buffer' and returns a non-null pointer. On error, this returns |
+ /// an error code and *does not* take ownership of Buffer. |
/// |
- /// See getNaClLazyBitcodeModule for an explanation of argument |
- /// AcceptSupportedOnly. |
- Module *NaClParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext &Context, |
- std::string *ErrMsg = 0, |
- bool AcceptSupportedOnly = true); |
+ /// See getNaClLazyBitcodeModule for an explanation of arguments |
+ /// Verbose, AcceptSupportedOnly. |
+ ErrorOr<Module *> NaClParseBitcodeFile(MemoryBuffer *Buffer, |
+ LLVMContext &Context, |
+ raw_ostream *Verbose = nullptr, |
+ bool AcceptSupportedOnly = true); |
/// NaClWriteBitcodeToFile - Write the specified module to the |
/// specified raw output stream, using PNaCl wire format. For |