1 //===- IRObjectFile.h - LLVM IR object file implementation ------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the IRObjectFile template class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_OBJECT_IROBJECTFILE_H
15 #define LLVM_OBJECT_IROBJECTFILE_H
17 #include "llvm/ADT/PointerUnion.h"
18 #include "llvm/Object/ModuleSymbolTable.h"
19 #include "llvm/Object/SymbolicFile.h"
30 class IRObjectFile : public SymbolicFile {
31 std::vector<std::unique_ptr<Module>> Mods;
32 ModuleSymbolTable SymTab;
33 IRObjectFile(MemoryBufferRef Object,
34 std::vector<std::unique_ptr<Module>> Mods);
37 ~IRObjectFile() override;
38 void moveSymbolNext(DataRefImpl &Symb) const override;
39 std::error_code printSymbolName(raw_ostream &OS,
40 DataRefImpl Symb) const override;
41 uint32_t getSymbolFlags(DataRefImpl Symb) const override;
42 basic_symbol_iterator symbol_begin() const override;
43 basic_symbol_iterator symbol_end() const override;
45 StringRef getTargetTriple() const;
47 static inline bool classof(const Binary *v) {
51 /// \brief Finds and returns bitcode embedded in the given object file, or an
52 /// error code if not found.
53 static ErrorOr<MemoryBufferRef> findBitcodeInObject(const ObjectFile &Obj);
55 /// \brief Finds and returns bitcode in the given memory buffer (which may
56 /// be either a bitcode file or a native object file with embedded bitcode),
57 /// or an error code if not found.
58 static ErrorOr<MemoryBufferRef>
59 findBitcodeInMemBuffer(MemoryBufferRef Object);
61 static Expected<std::unique_ptr<IRObjectFile>> create(MemoryBufferRef Object,
62 LLVMContext &Context);