| Index: include/llvm/Bitcode/ReaderWriter.h
|
| diff --git a/include/llvm/Bitcode/ReaderWriter.h b/include/llvm/Bitcode/ReaderWriter.h
|
| index fa754c014621f52af5698561d1718ae014f24bca..803373c04603e8ee1dedca1132b1a5b74d9a5a43 100644
|
| --- a/include/llvm/Bitcode/ReaderWriter.h
|
| +++ b/include/llvm/Bitcode/ReaderWriter.h
|
| @@ -14,6 +14,7 @@
|
| #ifndef LLVM_BITCODE_H
|
| #define LLVM_BITCODE_H
|
|
|
| +#include "llvm/Bitcode/BitcodeStream.h"
|
| #include <string>
|
|
|
| namespace llvm {
|
| @@ -33,6 +34,13 @@ namespace llvm {
|
| LLVMContext& Context,
|
| std::string *ErrMsg = 0);
|
|
|
| + /// Like getLazyBitcodeModule, except it calls cb to get chunks of the
|
| + /// bitcode instead of needing the whole buffer ahead of time.
|
| + Module *getLazyBitcodeStreamModule(const std::string &name,
|
| + StreamChunkCallback cb,
|
| + LLVMContext& Context,
|
| + std::string *ErrMsg = 0);
|
| +
|
| /// getBitcodeTargetTriple - Read the header of the specified bitcode
|
| /// buffer and extract just the triple information. If successful,
|
| /// this returns a string and *does not* take ownership
|
| @@ -113,8 +121,10 @@ namespace llvm {
|
| /// This function is called when we find a file with a matching magic number.
|
| /// In this case, skip down to the subsection of the file that is actually a
|
| /// BC file.
|
| - static inline bool SkipBitcodeWrapperHeader(unsigned char *&BufPtr,
|
| - unsigned char *&BufEnd) {
|
| + /// If 'verify' is true, check that the file fits in the buffer.
|
| + static inline bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr,
|
| + const unsigned char *&BufEnd,
|
| + bool Verify) {
|
| enum {
|
| KnownHeaderSize = 4*4, // Size of header we read.
|
| OffsetField = 2*4, // Offset in bytes to Offset field.
|
| @@ -134,7 +144,7 @@ namespace llvm {
|
| (BufPtr[SizeField +3] << 24));
|
|
|
| // Verify that Offset+Size fits in the file.
|
| - if (Offset+Size > unsigned(BufEnd-BufPtr))
|
| + if (Verify && Offset+Size > unsigned(BufEnd-BufPtr))
|
| return true;
|
| BufPtr += Offset;
|
| BufEnd = BufPtr+Size;
|
|
|