[llvm] r234816 - DebugInfo: Move DIDerivedType accessors to MDDerivedType, NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Apr 13 16:36:36 PDT 2015


Author: dexonsmith
Date: Mon Apr 13 18:36:36 2015
New Revision: 234816

URL: http://llvm.org/viewvc/llvm-project?rev=234816&view=rev
Log:
DebugInfo: Move DIDerivedType accessors to MDDerivedType, NFC

Add accessors in `MDDerivedType` to downcast `getExtraData()`, matching
those in `DIDerivedType`.

Modified:
    llvm/trunk/include/llvm/IR/DebugInfo.h
    llvm/trunk/include/llvm/IR/DebugInfoMetadata.h

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234816&r1=234815&r2=234816&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr 13 18:36:36 2015
@@ -315,22 +315,15 @@ public:
 
   /// \brief Return property node, if this ivar is associated with one.
   MDObjCProperty *getObjCProperty() const {
-    return dyn_cast_or_null<MDObjCProperty>(
-        cast<MDDerivedType>(get())->getExtraData());
+    return cast<MDDerivedType>(get())->getObjCProperty();
   }
 
   DITypeRef getClassType() const {
-    assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
-    return MDTypeRef(cast<MDDerivedType>(get())->getExtraData());
+    return cast<MDDerivedType>(get())->getClassType();
   }
 
   Constant *getConstant() const {
-    assert(getTag() == dwarf::DW_TAG_member && isStaticMember());
-    if (auto *C = cast_or_null<ConstantAsMetadata>(
-            cast<MDDerivedType>(get())->getExtraData()))
-      return C->getValue();
-
-    return nullptr;
+    return cast<MDDerivedType>(get())->getConstant();
   }
 };
 

Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=234816&r1=234815&r2=234816&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Mon Apr 13 18:36:36 2015
@@ -746,6 +746,23 @@ public:
   Metadata *getExtraData() const { return getRawExtraData(); }
   Metadata *getRawExtraData() const { return getOperand(4); }
 
+  /// \brief Get casted version of extra data.
+  /// @{
+  MDTypeRef getClassType() const {
+    assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
+    return MDTypeRef(getExtraData());
+  }
+  MDObjCProperty *getObjCProperty() const {
+    return dyn_cast_or_null<MDObjCProperty>(getExtraData());
+  }
+  Constant *getConstant() const {
+    assert(getTag() == dwarf::DW_TAG_member && isStaticMember());
+    if (auto *C = cast_or_null<ConstantAsMetadata>(getExtraData()))
+      return C->getValue();
+    return nullptr;
+  }
+  /// @}
+
   static bool classof(const Metadata *MD) {
     return MD->getMetadataID() == MDDerivedTypeKind;
   }





More information about the llvm-commits mailing list