Move createIRObjectFile to the IRObjectFile class and return the concrete type.
[oota-llvm.git] / include / llvm / Object / IRObjectFile.h
1 //===- IRObjectFile.h - LLVM IR object file implementation ------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares the IRObjectFile template class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_OBJECT_IR_OBJECT_FILE_H
15 #define LLVM_OBJECT_IR_OBJECT_FILE_H
16
17 #include "llvm/Object/SymbolicFile.h"
18
19 namespace llvm {
20 class Mangler;
21 class Module;
22 class GlobalValue;
23
24 namespace object {
25 class IRObjectFile : public SymbolicFile {
26   std::unique_ptr<Module> M;
27   std::unique_ptr<Mangler> Mang;
28   std::vector<std::pair<std::string, uint32_t>> AsmSymbols;
29
30 public:
31   IRObjectFile(std::unique_ptr<MemoryBuffer> Object, std::error_code &EC,
32                LLVMContext &Context);
33   ~IRObjectFile();
34   void moveSymbolNext(DataRefImpl &Symb) const override;
35   std::error_code printSymbolName(raw_ostream &OS,
36                                   DataRefImpl Symb) const override;
37   uint32_t getSymbolFlags(DataRefImpl Symb) const override;
38   const GlobalValue *getSymbolGV(DataRefImpl Symb) const;
39   basic_symbol_iterator symbol_begin_impl() const override;
40   basic_symbol_iterator symbol_end_impl() const override;
41
42   static inline bool classof(const Binary *v) {
43     return v->isIR();
44   }
45
46   static ErrorOr<IRObjectFile *>
47   createIRObjectFile(std::unique_ptr<MemoryBuffer> Object,
48                      LLVMContext &Context);
49 };
50 }
51 }
52
53 #endif