14 #ifndef LLVM_BITCODE_BITCODEREADER_H 15 #define LLVM_BITCODE_BITCODEREADER_H 28 #include <system_error> 45 return std::move(*Val);
67 uint64_t IdentificationBit;
73 uint64_t IdentificationBit, uint64_t ModuleBit)
74 : Buffer(Buffer), ModuleIdentifier(ModuleIdentifier),
75 IdentificationBit(IdentificationBit), ModuleBit(ModuleBit) {}
83 bool ShouldLazyLoadMetadata,
88 return StringRef((
const char *)Buffer.begin(), Buffer.size());
100 bool ShouldLazyLoadMetadata,
120 std::vector<BitcodeModule>
Mods;
141 bool ShouldLazyLoadMetadata =
false,
142 bool IsImporting =
false);
150 bool ShouldLazyLoadMetadata =
false,
bool IsImporting =
false);
188 bool IgnoreEmptyThinLTOIndexFile =
false);
193 const unsigned char *BufEnd) {
196 return BufPtr != BufEnd &&
206 const unsigned char *BufEnd) {
209 return BufPtr != BufEnd &&
219 const unsigned char *BufEnd) {
241 const unsigned char *&BufEnd,
242 bool VerifyBufferSize) {
249 uint64_t BitcodeOffsetEnd = (uint64_t)Offset + (uint64_t)
Size;
252 if (VerifyBufferSize && BitcodeOffsetEnd > uint64_t(BufEnd-BufPtr))
255 BufEnd = BufPtr+
Size;
273 #endif // LLVM_BITCODE_BITCODEREADER_H Represents either an error or a value T.
This class represents lattice values for constants.
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...
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.
StringRef getModuleIdentifier() const
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
Basic information extracted from a bitcode module to be used for LTO.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
static const unsigned BWH_SizeField
const std::error_category & BitcodeErrorCategory()
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 GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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
Error readModuleSummaryIndex(MemoryBufferRef Buffer, ModuleSummaryIndex &CombinedIndex, uint64_t ModuleId)
Parse the specified bitcode buffer and merge the index into CombinedIndex.
Expected< BitcodeFileContents > getBitcodeFileContents(MemoryBufferRef Buffer)
Returns the contents of a bitcode file.
std::unique_ptr< Module > parseModule(const uint8_t *Data, size_t Size, LLVMContext &Context)
Fuzzer friendly interface for the llvm bitcode parser.
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.
StringRef getStrtab() const
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 ...
Expected< std::unique_ptr< ModuleSummaryIndex > > getModuleSummaryIndexForFile(StringRef Path, bool IgnoreEmptyThinLTOIndexFile=false)
Parse the module summary index out of an IR file and return the module summary index object if found...
Expected< std::unique_ptr< Module > > parseBitcodeFile(MemoryBufferRef Buffer, LLVMContext &Context)
Read the specified bitcode file, returning the module.
Expected< BitcodeLTOInfo > getBitcodeLTOInfo(MemoryBufferRef Buffer)
Returns LTO information for the specified bitcode file.
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.
Lightweight error class with error context and mandatory checking.
StringRef - Represent a constant reference to a string, i.e.
std::vector< BitcodeModule > Mods