Object: Remove module accessors from IRObjectFile, and hide its constructor.

Differential Revision: https://reviews.llvm.org/D27079

llvm-svn: 289577
This commit is contained in:
Peter Collingbourne 2016-12-13 20:10:22 +00:00
parent 77f4c30d6f
commit c5fecb4f1a
2 changed files with 3 additions and 20 deletions

View File

@ -30,29 +30,17 @@ class ObjectFile;
class IRObjectFile : public SymbolicFile {
std::unique_ptr<Module> M;
ModuleSymbolTable SymTab;
IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> M);
public:
IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> M);
~IRObjectFile() override;
void moveSymbolNext(DataRefImpl &Symb) const override;
std::error_code printSymbolName(raw_ostream &OS,
DataRefImpl Symb) const override;
uint32_t getSymbolFlags(DataRefImpl Symb) const override;
GlobalValue *getSymbolGV(DataRefImpl Symb);
const GlobalValue *getSymbolGV(DataRefImpl Symb) const {
return const_cast<IRObjectFile *>(this)->getSymbolGV(Symb);
}
basic_symbol_iterator symbol_begin() const override;
basic_symbol_iterator symbol_end() const override;
const Module &getModule() const {
return const_cast<IRObjectFile*>(this)->getModule();
}
Module &getModule() {
return *M;
}
std::unique_ptr<Module> takeModule();
StringRef getTargetTriple() const;
static inline bool classof(const Binary *v) {

View File

@ -60,12 +60,6 @@ uint32_t IRObjectFile::getSymbolFlags(DataRefImpl Symb) const {
return SymTab.getSymbolFlags(getSym(Symb));
}
GlobalValue *IRObjectFile::getSymbolGV(DataRefImpl Symb) {
return getSym(Symb).dyn_cast<GlobalValue *>();
}
std::unique_ptr<Module> IRObjectFile::takeModule() { return std::move(M); }
basic_symbol_iterator IRObjectFile::symbol_begin() const {
DataRefImpl Ret;
Ret.p = reinterpret_cast<uintptr_t>(SymTab.symbols().data());
@ -127,5 +121,6 @@ llvm::object::IRObjectFile::create(MemoryBufferRef Object,
return MOrErr.takeError();
std::unique_ptr<Module> &M = MOrErr.get();
return llvm::make_unique<IRObjectFile>(BCOrErr.get(), std::move(M));
return std::unique_ptr<IRObjectFile>(
new IRObjectFile(*BCOrErr, std::move(M)));
}