[llvm-commits] [llvm] r61740 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp

Devang Patel dpatel at apple.com
Mon Jan 5 11:55:07 PST 2009


Author: dpatel
Date: Mon Jan  5 13:55:07 2009
New Revision: 61740

URL: http://llvm.org/viewvc/llvm-project?rev=61740&view=rev
Log:
Add classof() methods so that dwarf writer can decide what DIDescriptor is in its hand.

Modified:
    llvm/trunk/include/llvm/Analysis/DebugInfo.h
    llvm/trunk/lib/Analysis/DebugInfo.cpp

Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=61740&r1=61739&r2=61740&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Jan  5 13:55:07 2009
@@ -77,6 +77,7 @@
     unsigned getTag() const {
       return getUnsignedField(0) & ~VersionMask;
     }
+    static inline bool classof(const DIDescriptor *D) { return true; }
   };
   
   /// DIAnchor - A wrapper for various anchor descriptors.
@@ -94,6 +95,11 @@
     
     int64_t getLo() const { return (int64_t)getUInt64Field(1); }
     int64_t getHi() const { return (int64_t)getUInt64Field(2); }
+    static bool isSubrange(unsigned);
+    static inline bool classof(const DISubrange *) { return true; }
+    static inline bool classof(const DIDescriptor *D) {
+      return isSubrange(D->getTag());
+    }
   };
   
   /// DIArray - This descriptor holds an array of descriptors.
@@ -102,8 +108,8 @@
     explicit DIArray(GlobalVariable *GV = 0) : DIDescriptor(GV) {}
     
     unsigned getNumElements() const;
-    DISubrange getElement(unsigned Idx) const {
-      return getFieldAs<DISubrange>(Idx); 
+    DIDescriptor getElement(unsigned Idx) const {
+      return getDescriptorField(Idx);
     }
   };
   
@@ -180,6 +186,11 @@
     /// isDerivedType - Return true if the specified tag is legal for
     /// DIDerivedType.
     static bool isDerivedType(unsigned TAG);
+
+    static inline bool classof(const DIDerivedType *) { return true; }
+    static inline bool classof(const DIDescriptor *D) {
+      return isDerivedType(D->getTag());
+    }
   };
 
   
@@ -197,6 +208,10 @@
     /// isCompositeType - Return true if the specified tag is legal for
     /// DICompositeType.
     static bool isCompositeType(unsigned TAG);
+    static inline bool classof(const DIDerivedType *) { return true; }
+    static inline bool classof(const DIDescriptor *D) {
+      return isCompositeType(D->getTag());
+    }
   };
   
   /// DIGlobal - This is a common class for global variables and subprograms.

Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=61740&r1=61739&r2=61740&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Jan  5 13:55:07 2009
@@ -181,6 +181,11 @@
   return C->getNumOperands();
 }
 
+/// isSubrange - Return true if the specified tag is legal for DISubrange.
+bool DISubrange::isSubrange(unsigned Tag) {
+  return Tag == dwarf::DW_TAG_subrange_type;
+}
+
 //===----------------------------------------------------------------------===//
 // DIFactory: Basic Helpers
 //===----------------------------------------------------------------------===//





More information about the llvm-commits mailing list