14 #ifndef LLVM_BITCODE_BITCODEREADER_H
15 #define LLVM_BITCODE_BITCODEREADER_H
40 return std::move(*Val);
50 uint64_t IdentificationBit;
56 uint64_t IdentificationBit, uint64_t ModuleBit)
57 : Buffer(Buffer), ModuleIdentifier(ModuleIdentifier),
58 IdentificationBit(IdentificationBit), ModuleBit(ModuleBit) {}
66 bool ShouldLazyLoadMetadata,
71 return StringRef((
const char *)Buffer.begin(), Buffer.size());
81 bool ShouldLazyLoadMetadata,
95 Expected<std::vector<BitcodeModule>>
102 Expected<std::unique_ptr<Module>>
104 bool ShouldLazyLoadMetadata =
false,
105 bool IsImporting =
false);
112 std::unique_ptr<MemoryBuffer> &&Buffer, LLVMContext &
Context,
113 bool ShouldLazyLoadMetadata =
false,
bool IsImporting =
false);
137 Expected<std::unique_ptr<ModuleSummaryIndex>>
144 const unsigned char *BufEnd) {
147 return BufPtr != BufEnd &&
158 const unsigned char *BufEnd) {
161 return BufPtr != BufEnd &&
172 const unsigned char *BufEnd) {
194 const unsigned char *&BufEnd,
195 bool VerifyBufferSize) {
202 uint64_t BitcodeOffsetEnd = (uint64_t)Offset + (uint64_t)Size;
205 if (VerifyBufferSize && BitcodeOffsetEnd > uint64_t(BufEnd-BufPtr))
208 BufEnd = BufPtr+Size;
221 template <>
struct is_error_code_enum<llvm::
BitcodeError> : std::true_type {};
Represents either an error or a value T.
Expected< std::unique_ptr< Module > > getLazyBitcodeModule(MemoryBufferRef Buffer, LLVMContext &Context, bool ShouldLazyLoadMetadata=false, bool IsImporting=false)
Read the header of the specified bitcode buffer and prepare for lazy deserialization of function bodi...
Expected< bool > hasSummary()
Check if the given bitcode buffer contains a summary block.
Expected< std::unique_ptr< ModuleSummaryIndex > > getSummary()
Parse the specified bitcode buffer, returning the module summary index.
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...
Error takeError()
Take ownership of the stored error.
Expected< std::vector< BitcodeModule > > getBitcodeModuleList(MemoryBufferRef Buffer)
Returns a list of modules in the specified bitcode buffer.
Represents a module in a bitcode file.
std::error_code make_error_code(BitcodeError E)
Tagged union holding either a T or a Error.
static const unsigned BWH_OffsetField
static const unsigned BWH_SizeField
const std::error_category & BitcodeErrorCategory()
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
Expected< std::string > getBitcodeProducerString(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the producer string information...
This is an important class for using LLVM in a threaded context.
static ManagedStatic< _object_error_category > error_category
Expected< std::string > getBitcodeTargetTriple(MemoryBufferRef Buffer)
Read the header of the specified bitcode buffer and extract just the triple information.
StringRef getBuffer() const
Expected< bool > isBitcodeContainingObjCCategory(MemoryBufferRef Buffer)
Return true if Buffer contains a bitcode file with ObjC code (category or class) in it...
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.
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 ...
StringRef getModuleIdentifier() const
Expected< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context)
Read the specified bitcode file, returning the module.
ErrorOr< T > expectedToErrorOrAndEmitErrors(LLVMContext &Ctx, Expected< T > Val)
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...
uint32_t read32le(const void *P)
Provides ErrorOr<T> smart pointer.
Expected< std::unique_ptr< Module > > getOwningLazyBitcodeModule(std::unique_ptr< MemoryBuffer > &&Buffer, LLVMContext &Context, bool ShouldLazyLoadMetadata=false, bool IsImporting=false)
Like getLazyBitcodeModule, except that the module takes ownership of the memory buffer if successful...
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
std::error_code errorToErrorCodeAndEmitErrors(LLVMContext &Ctx, Error Err)
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndex(MemoryBufferRef Buffer)
Parse the specified bitcode buffer, returning the module summary index.
Expected< std::unique_ptr< Module > > getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata, bool IsImporting)
Read the bitcode module and prepare for lazy deserialization of function bodies.
Expected< std::unique_ptr< Module > > parseModule(LLVMContext &Context)
Read the entire bitcode module and return it.
StringRef - Represent a constant reference to a string, i.e.
Expected< bool > hasGlobalValueSummary(MemoryBufferRef Buffer)
Check if the given bitcode buffer contains a summary block.
friend Expected< std::vector< BitcodeModule > > getBitcodeModuleList(MemoryBufferRef Buffer)
Returns a list of modules in the specified bitcode buffer.