29#include <system_error>
32using namespace object;
111 if (std::error_code EC = FileOrErr.
getError())
113 std::unique_ptr<MemoryBuffer> &Buffer = FileOrErr.
get();
116 createBinary(Buffer->getMemBufferRef(), Context, InitContent);
119 std::unique_ptr<Binary> &
Bin = BinOrErr.
get();
Provides ErrorOr<T> smart pointer.
Represents either an error or a value T.
std::error_code getError() const
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
This is an important class for using LLVM in a threaded context.
StringRef getBufferIdentifier() const
StringRef getBuffer() const
static ErrorOr< std::unique_ptr< MemoryBuffer > > getFileOrSTDIN(const Twine &Filename, bool IsText=false, bool RequiresNullTerminator=true, std::optional< Align > Alignment=std::nullopt)
Open the specified file as a MemoryBuffer, or open stdin if the Filename is "-".
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
TypeID
Definitions of all of the base types for the Type system.
static Expected< std::unique_ptr< Archive > > create(MemoryBufferRef Source)
StringRef getData() const
MemoryBufferRef getMemoryBufferRef() const
StringRef getFileName() const
static Expected< std::unique_ptr< MachOUniversalBinary > > create(MemoryBufferRef Source)
static Expected< std::unique_ptr< MinidumpFile > > create(MemoryBufferRef Source)
Construct a new MinidumpFile object from the given memory buffer.
static Expected< std::unique_ptr< OffloadBinary > > create(MemoryBufferRef)
Attempt to parse the offloading binary stored in Data.
static Expected< std::unique_ptr< SymbolicFile > > createSymbolicFile(MemoryBufferRef Object, llvm::file_magic Type, LLVMContext *Context, bool InitContent=true)
static Expected< std::unique_ptr< TapiUniversal > > create(MemoryBufferRef Source)
static Expected< std::unique_ptr< WindowsResource > > createWindowsResource(MemoryBufferRef Source)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Expected< std::unique_ptr< Binary > > createBinary(MemoryBufferRef Source, LLVMContext *Context=nullptr, bool InitContent=true)
Create a Binary from Source, autodetecting the file type.
This is an optimization pass for GlobalISel generic memory operations.
file_magic identify_magic(StringRef magic)
Identify the type of a binary file based on how magical it is.
Error errorCodeToError(std::error_code EC)
Helper for converting an std::error_code to a Error.
file_magic - An "enum class" enumeration of file types based on magic (the first N bytes of the file)...
@ coff_import_library
COFF import library.
@ pdb
Windows PDB debug info file.
@ spirv_object
A binary SPIR-V file.
@ elf_relocatable
ELF Relocatable object file.
@ archive
ar style archive file
@ elf_shared_object
ELF dynamically linked shared lib.
@ goff_object
GOFF object file.
@ minidump
Windows minidump file.
@ macho_dynamically_linked_shared_lib
Mach-O dynlinked shared lib.
@ xcoff_object_64
64-bit XCOFF object file
@ elf_executable
ELF Executable image.
@ macho_dynamically_linked_shared_lib_stub
Mach-O Shared lib stub.
@ macho_preload_executable
Mach-O Preloaded Executable.
@ offload_bundle
Clang offload bundle file.
@ offload_bundle_compressed
Compressed clang offload bundle file.
@ macho_file_set
Mach-O file set binary.
@ dxcontainer_object
DirectX container file.
@ macho_kext_bundle
Mach-O kext bundle file.
@ pecoff_executable
PECOFF executable file.
@ offload_binary
LLVM offload object file.
@ macho_universal_binary
Mach-O universal binary.
@ macho_core
Mach-O Core File.
@ wasm_object
WebAssembly Object file.
@ xcoff_object_32
32-bit XCOFF object file
@ windows_resource
Windows compiled resource file (.res)
@ clang_ast
Clang PCH or PCM.
@ elf_core
ELF core image.
@ macho_object
Mach-O Object file.
@ coff_object
COFF object file.
@ macho_bundle
Mach-O Bundle file.
@ coff_cl_gl_object
Microsoft cl.exe's intermediate code file.
@ cuda_fatbinary
CUDA Fatbinary object file.
@ macho_executable
Mach-O Executable.
@ macho_dsym_companion
Mach-O dSYM companion file.
@ unknown
Unrecognized file.
@ macho_fixed_virtual_memory_shared_lib
Mach-O Shared Lib, FVM.
@ macho_dynamic_linker
The Mach-O dynamic linker.
@ tapi_file
Text-based Dynamic Library Stub file.