22 #include <system_error>
38 std::unique_ptr<Module> M =
53 if (std::error_code EC = FileOrErr.
getError()) {
55 "Could not open input file: " + EC.message());
59 return parseAssembly(FileOrErr.
get()->getMemBufferRef(), Err, Context, Slots);
std::error_code getError() const
Represents either an error or a value T.
A Module instance is used to store all the information related to an LLVM module. ...
static std::unique_ptr< MemoryBuffer > getMemBuffer(StringRef InputData, StringRef BufferName="", bool RequiresNullTerminator=true)
Open the specified memory range as a MemoryBuffer.
unsigned AddNewSourceBuffer(std::unique_ptr< MemoryBuffer > F, SMLoc IncludeLoc)
Add a new source buffer to this source manager.
std::unique_ptr< Module > parseAssembly(MemoryBufferRef F, SMDiagnostic &Err, LLVMContext &Context, SlotMapping *Slots=nullptr)
parseAssemblyFile and parseAssemblyString are wrappers around this function.
This is an important class for using LLVM in a threaded context.
This owns the files read by a parser, handles include stacks, and handles diagnostic wrangling...
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, int64_t FileSize=-1)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
StringRef getBuffer() const
Module.h This file contains the declarations for the Module class.
bool parseAssemblyInto(MemoryBufferRef F, Module &M, SMDiagnostic &Err, SlotMapping *Slots=nullptr)
This function is the low-level interface to the LLVM Assembly Parser.
This struct contains the mapping from the slot numbers to unnamed metadata nodes and global values...
std::unique_ptr< Module > parseAssemblyFile(StringRef Filename, SMDiagnostic &Error, LLVMContext &Context, SlotMapping *Slots=nullptr)
This function is the main interface to the LLVM Assembly Parser.
StringRef getBufferIdentifier() const
std::unique_ptr< Module > parseAssemblyString(StringRef AsmString, SMDiagnostic &Error, LLVMContext &Context, SlotMapping *Slots=nullptr)
The function is a secondary interface to the LLVM Assembly Parser.
StringRef - Represent a constant reference to a string, i.e.
Represents a location in source code.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...