Add LLVM-style RTTI to DIContext/DWARFContext classes
authorAlexey Samsonov <samsonov@google.com>
Tue, 6 Aug 2013 10:32:39 +0000 (10:32 +0000)
committerAlexey Samsonov <samsonov@google.com>
Tue, 6 Aug 2013 10:32:39 +0000 (10:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187790 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/DebugInfo/DIContext.h
lib/DebugInfo/DWARFContext.h

index bdd8dce08da308a18e8b7c2e7aa25af4bc2502e6..4bb7c774389a62ecf3da86a7aaa6546c9dbd2e02 100644 (file)
@@ -21,6 +21,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Object/RelocVisitor.h"
+#include "llvm/Support/Casting.h"
 #include "llvm/Support/DataTypes.h"
 
 namespace llvm {
@@ -122,6 +123,12 @@ typedef DenseMap<uint64_t, std::pair<uint8_t, int64_t> > RelocAddrMap;
 
 class DIContext {
 public:
+  enum DIContextKind {
+    CK_DWARF
+  };
+  DIContextKind getKind() const { return Kind; }
+
+  DIContext(DIContextKind K) : Kind(K) {}
   virtual ~DIContext();
 
   /// getDWARFContext - get a context for binary DWARF data.
@@ -135,6 +142,8 @@ public:
       uint64_t Size, DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
   virtual DIInliningInfo getInliningInfoForAddress(uint64_t Address,
       DILineInfoSpecifier Specifier = DILineInfoSpecifier()) = 0;
+private:
+  const DIContextKind Kind;
 };
 
 }
index 058476e34d376fb2c886a630ea0bbd243776cc52..5d8f714505ce549d470b12d918b631532a57cd19 100644 (file)
@@ -48,7 +48,12 @@ class DWARFContext : public DIContext {
   void parseDWOCompileUnits();
 
 public:
-  DWARFContext() {}
+  DWARFContext() : DIContext(CK_DWARF) {}
+
+  static bool classof(const DIContext *DICtx) {
+    return DICtx->getKind() == CK_DWARF;
+  }
+
   virtual void dump(raw_ostream &OS, DIDumpType DumpType = DIDT_All);
 
   /// Get the number of compile units in this context.