14 #ifndef LLVM_BITCODE_READERWRITER_H
15 #define LLVM_BITCODE_READERWRITER_H
25 class BitstreamWriter;
36 ErrorOr<std::unique_ptr<Module>>
40 bool ShouldLazyLoadMetadata =
false);
45 StringRef
Name, std::unique_ptr<DataStreamer> Streamer,
57 ErrorOr<std::unique_ptr<Module>>
70 bool ShouldPreserveUseListOrder =
false);
76 const unsigned char *BufEnd) {
79 return BufPtr != BufEnd &&
90 const unsigned char *BufEnd) {
93 return BufPtr != BufEnd &&
104 const unsigned char *BufEnd) {
126 const unsigned char *&BufEnd,
127 bool VerifyBufferSize) {
129 KnownHeaderSize = 4*4,
135 if (BufEnd-BufPtr < KnownHeaderSize)
return true;
141 if (VerifyBufferSize && Offset+Size >
unsigned(BufEnd-BufPtr))
144 BufEnd = BufPtr+Size;
172 template <>
struct is_error_code_enum<llvm::
BitcodeError> : std::true_type {};
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
bool isBitcodeWrapper(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcodeWrapper - Return true if the given bytes are the magic bytes for an LLVM IR bitcode wrapper...
ErrorOr< std::unique_ptr< Module > > getStreamedBitcodeModule(StringRef Name, std::unique_ptr< DataStreamer > Streamer, LLVMContext &Context, DiagnosticHandlerFunction DiagnosticHandler=nullptr)
Read the header of the specified stream and prepare for lazy deserialization and streaming of functio...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::error_code make_error_code(BitcodeError E)
Interface for custom diagnostic printing.
const std::error_category & BitcodeErrorCategory()
BitcodeDiagnosticInfo(std::error_code EC, DiagnosticSeverity Severity, const Twine &Msg)
This is the base abstract class for diagnostic reporting in the backend.
uint32_t read32le(const void *p)
void WriteBitcodeToFile(const Module *M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false)
Write the specified module to the specified raw output stream.
ErrorOr< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context, DiagnosticHandlerFunction DiagnosticHandler=nullptr)
Read the specified bitcode file, returning the module.
static ManagedStatic< _object_error_category > error_category
bool isBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcode - Return true if the given bytes are the magic bytes for LLVM IR bitcode, either with or without a wrapper.
void print(DiagnosticPrinter &DP) const override
Print using the given DP a user-friendly message.
std::function< void(const DiagnosticInfo &)> DiagnosticHandlerFunction
std::string getBitcodeTargetTriple(MemoryBufferRef Buffer, LLVMContext &Context, DiagnosticHandlerFunction DiagnosticHandler=nullptr)
Read the header of the specified bitcode buffer and extract just the triple information.
bool isRawBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
isRawBitcode - Return true if the given bytes are the magic bytes for raw LLVM IR bitcode (without a ...
bool SkipBitcodeWrapperHeader(const unsigned char *&BufPtr, const unsigned char *&BufEnd, bool VerifyBufferSize)
SkipBitcodeWrapperHeader - Some systems wrap bc files with a special header for padding or other reas...
static bool classof(const DiagnosticInfo *DI)
std::error_code getError() const
Provides ErrorOr<T> smart pointer.
ErrorOr< std::unique_ptr< Module > > getLazyBitcodeModule(std::unique_ptr< MemoryBuffer > &&Buffer, LLVMContext &Context, DiagnosticHandlerFunction DiagnosticHandler=nullptr, bool ShouldLazyLoadMetadata=false)
Read the header of the specified bitcode buffer and prepare for lazy deserialization of function bodi...