[llvm] r234812 - DebugInfo: Make DIDerivedType accessors more strict

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


Author: dexonsmith
Date: Mon Apr 13 18:13:18 2015
New Revision: 234812

URL: http://llvm.org/viewvc/llvm-project?rev=234812&view=rev
Log:
DebugInfo: Make DIDerivedType accessors more strict

These accessors in `DIDerivedType` should only be called when `DbgNode`
really is a `MDDerivedType`, not just a `MDDerivedTypeBase`.  Assume
that it is.

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

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





More information about the llvm-commits mailing list