Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: include/llvm/Bitcode/NaCl/NaClReaderWriter.h

Issue 770853002: Fix error reporting in the PNaCl bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix typo. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h ('k') | include/llvm/IRReader/IRReader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h ('k') | include/llvm/IRReader/IRReader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698