From ab6bcf35aefe823894d349773ebd53f465f122b7 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Mon, 17 Oct 2011 23:53:37 +0000 Subject: Object: Implement casting for concrete classes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142314 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/COFF.h | 6 ++++++ include/llvm/Object/MachO.h | 5 +++++ lib/Object/ELFObjectFile.cpp | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index fa8dee7c5d..1dd8f983ec 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -141,6 +141,12 @@ public: virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; virtual unsigned getArch() const; + + + static inline bool classof(const Binary *v) { + return v->getType() == isCOFF; + } + static inline bool classof(const COFFObjectFile *v) { return true; } }; } diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index 71830aa89b..147987e8f1 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -40,6 +40,11 @@ public: MachOObject *getObject() { return MachOObj; } + static inline bool classof(const Binary *v) { + return v->getType() == isMachO; + } + static inline bool classof(const MachOObjectFile *v) { return true; } + protected: virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const; diff --git a/lib/Object/ELFObjectFile.cpp b/lib/Object/ELFObjectFile.cpp index e13c31214a..7a992e2fec 100644 --- a/lib/Object/ELFObjectFile.cpp +++ b/lib/Object/ELFObjectFile.cpp @@ -377,6 +377,11 @@ public: uint64_t getStringTableIndex() const; ELF::Elf64_Word getSymbolTableIndex(const Elf_Sym *symb) const; const Elf_Shdr *getSection(const Elf_Sym *symb) const; + + static inline bool classof(const Binary *v) { + return v->getType() == isELF; + } + static inline bool classof(const ELFObjectFile *v) { return true; } }; } // end namespace -- cgit v1.2.3