Object: Implement casting for concrete classes.
authorMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 17 Oct 2011 23:53:37 +0000 (23:53 +0000)
committerMichael J. Spencer <bigcheesegs@gmail.com>
Mon, 17 Oct 2011 23:53:37 +0000 (23:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142314 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/COFF.h
include/llvm/Object/MachO.h
lib/Object/ELFObjectFile.cpp

index fa8dee7c5d05e5665bee679759b1fc544abc41d6..1dd8f983ec50b0ea76eb0f15d1c39f1bcc7b8f19 100644 (file)
@@ -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; }
 };
 
 }
index 71830aa89b17dc0453985699fa43ac5a0fe5ddf5..147987e8f1cfcb4124e7eebf2eb4c6eeeca346b8 100644 (file)
@@ -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;
index e13c31214a7bedd41c30be018ee8402fd9f74b84..7a992e2fecf9769161c920305cfcdc8f444500d1 100644 (file)
@@ -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