diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-24 01:13:09 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-24 01:13:09 +0000 |
commit | 045ffc4b32244b655d59469ae5c05b6332217d92 (patch) | |
tree | 73fabf6c90fccfc3ffdacf48284f9d05f96852c8 | |
parent | 4384b55c02374481b6851b845aa06a1a228aaee1 (diff) |
Object: Add IRObjectFile::getTargetTriple().
This lets us remove a use of IRObjectFile::getModule() in llvm-nm.
Differential Revision: https://reviews.llvm.org/D27074
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287846 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Object/IRObjectFile.h | 2 | ||||
-rw-r--r-- | lib/Object/IRObjectFile.cpp | 2 | ||||
-rw-r--r-- | tools/llvm-nm/llvm-nm.cpp | 10 |
3 files changed, 6 insertions, 8 deletions
diff --git a/include/llvm/Object/IRObjectFile.h b/include/llvm/Object/IRObjectFile.h index 5126ea10da7..9acc286a6a0 100644 --- a/include/llvm/Object/IRObjectFile.h +++ b/include/llvm/Object/IRObjectFile.h @@ -60,6 +60,8 @@ public: } std::unique_ptr<Module> takeModule(); + StringRef getTargetTriple() const; + static inline bool classof(const Binary *v) { return v->isIR(); } diff --git a/lib/Object/IRObjectFile.cpp b/lib/Object/IRObjectFile.cpp index 4fd5e64fb7c..51b2446535b 100644 --- a/lib/Object/IRObjectFile.cpp +++ b/lib/Object/IRObjectFile.cpp @@ -213,6 +213,8 @@ basic_symbol_iterator IRObjectFile::symbol_end() const { return basic_symbol_iterator(BasicSymbolRef(Ret, this)); } +StringRef IRObjectFile::getTargetTriple() const { return M->getTargetTriple(); } + ErrorOr<MemoryBufferRef> IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { for (const SectionRef &Sec : Obj.sections()) { if (Sec.isBitcode()) { diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index 8c6fa4ecec7..436cf9cac68 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -265,14 +265,8 @@ static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) { } static char isSymbolList64Bit(SymbolicFile &Obj) { - if (isa<IRObjectFile>(Obj)) { - IRObjectFile *IRobj = dyn_cast<IRObjectFile>(&Obj); - Module &M = IRobj->getModule(); - if (M.getTargetTriple().empty()) - return false; - Triple T(M.getTargetTriple()); - return T.isArch64Bit(); - } + if (auto *IRObj = dyn_cast<IRObjectFile>(&Obj)) + return Triple(IRObj->getTargetTriple()).isArch64Bit(); if (isa<COFFObjectFile>(Obj)) return false; if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj)) |