Object: Add IRObjectFile::getTargetTriple().

This lets us remove a use of IRObjectFile::getModule() in llvm-nm.

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

llvm-svn: 287846
This commit is contained in:
Peter Collingbourne 2016-11-24 01:13:09 +00:00
parent e32baa0c3e
commit debb6f6cc1
3 changed files with 6 additions and 8 deletions

View File

@ -60,6 +60,8 @@ public:
} }
std::unique_ptr<Module> takeModule(); std::unique_ptr<Module> takeModule();
StringRef getTargetTriple() const;
static inline bool classof(const Binary *v) { static inline bool classof(const Binary *v) {
return v->isIR(); return v->isIR();
} }

View File

@ -213,6 +213,8 @@ basic_symbol_iterator IRObjectFile::symbol_end() const {
return basic_symbol_iterator(BasicSymbolRef(Ret, this)); return basic_symbol_iterator(BasicSymbolRef(Ret, this));
} }
StringRef IRObjectFile::getTargetTriple() const { return M->getTargetTriple(); }
ErrorOr<MemoryBufferRef> IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { ErrorOr<MemoryBufferRef> IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) {
for (const SectionRef &Sec : Obj.sections()) { for (const SectionRef &Sec : Obj.sections()) {
if (Sec.isBitcode()) { if (Sec.isBitcode()) {

View File

@ -265,14 +265,8 @@ static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) {
} }
static char isSymbolList64Bit(SymbolicFile &Obj) { static char isSymbolList64Bit(SymbolicFile &Obj) {
if (isa<IRObjectFile>(Obj)) { if (auto *IRObj = dyn_cast<IRObjectFile>(&Obj))
IRObjectFile *IRobj = dyn_cast<IRObjectFile>(&Obj); return Triple(IRObj->getTargetTriple()).isArch64Bit();
Module &M = IRobj->getModule();
if (M.getTargetTriple().empty())
return false;
Triple T(M.getTargetTriple());
return T.isArch64Bit();
}
if (isa<COFFObjectFile>(Obj)) if (isa<COFFObjectFile>(Obj))
return false; return false;
if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj)) if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj))