[llvm] r234289 - DebugInfo: Remove DICompositeType mutation API

Duncan P. N. Exon Smith dexonsmith at apple.com
Mon Apr 6 21:12:02 PDT 2015


Author: dexonsmith
Date: Mon Apr  6 23:12:02 2015
New Revision: 234289

URL: http://llvm.org/viewvc/llvm-project?rev=234289&view=rev
Log:
DebugInfo: Remove DICompositeType mutation API

Change `DIBuilder` to mutate `MDCompositeTypeBase` directly, and remove
the wrapping API in `DICompositeType`.

Modified:
    llvm/trunk/include/llvm/IR/DebugInfo.h
    llvm/trunk/lib/IR/DIBuilder.cpp
    llvm/trunk/lib/IR/DebugInfo.cpp

Modified: llvm/trunk/include/llvm/IR/DebugInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfo.h?rev=234289&r1=234288&r2=234289&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfo.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfo.h Mon Apr  6 23:12:02 2015
@@ -427,9 +427,6 @@ public:
 class DICompositeType : public DIDerivedType {
   friend class DIBuilder;
 
-  /// \brief Set the array of member DITypes.
-  void setArraysHelper(MDNode *Elements, MDNode *TParams);
-
 public:
   DICompositeType() = default;
   DICompositeType(const MDCompositeTypeBase *N) : DIDerivedType(N) {}
@@ -449,27 +446,11 @@ public:
     return DIArray(get()->getElements());
   }
 
-private:
-  template <typename T>
-  void setArrays(DITypedArray<T> Elements, DIArray TParams = DIArray()) {
-    assert(
-        (!TParams || DbgNode->getNumOperands() == 8) &&
-        "If you're setting the template parameters this should include a slot "
-        "for that!");
-    setArraysHelper(Elements, TParams);
-  }
-
-public:
   unsigned getRunTimeLang() const { return get()->getRuntimeLang(); }
   DITypeRef getContainingType() const {
     return DITypeRef::get(get()->getVTableHolder());
   }
 
-private:
-  /// \brief Set the containing type.
-  void setContainingType(DICompositeType ContainingType);
-
-public:
   DIArray getTemplateParams() const {
     return DIArray(get()->getTemplateParams());
   }

Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=234289&r1=234288&r2=234289&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Mon Apr  6 23:12:02 2015
@@ -835,7 +835,11 @@ Instruction *DIBuilder::insertDbgValueIn
 }
 
 void DIBuilder::replaceVTableHolder(DICompositeType &T, DICompositeType VTableHolder) {
-  T.setContainingType(VTableHolder);
+  {
+    TypedTrackingMDRef<MDCompositeTypeBase> N(T);
+    N->replaceVTableHolder(MDTypeRef::get(VTableHolder));
+    T = N.get();
+  }
 
   // If this didn't create a self-reference, just return.
   if (T != VTableHolder)
@@ -851,7 +855,14 @@ void DIBuilder::replaceVTableHolder(DICo
 
 void DIBuilder::replaceArrays(DICompositeType &T, DIArray Elements,
                               DIArray TParams) {
-  T.setArrays(Elements, TParams);
+  {
+    TypedTrackingMDRef<MDCompositeTypeBase> N(T);
+    if (Elements)
+      N->replaceElements(cast<MDTuple>(Elements.get()));
+    if (TParams)
+      N->replaceTemplateParams(cast<MDTuple>(TParams.get()));
+    T = N.get();
+  }
 
   // If T isn't resolved, there's no problem.
   if (!T->isResolved())

Modified: llvm/trunk/lib/IR/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=234289&r1=234288&r2=234289&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfo.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfo.cpp Mon Apr  6 23:12:02 2015
@@ -125,23 +125,8 @@ static bool isDescriptorRef(const Metada
 }
 #endif
 
-void DICompositeType::setArraysHelper(MDNode *Elements, MDNode *TParams) {
-  TypedTrackingMDRef<MDCompositeTypeBase> N(get());
-  if (Elements)
-    N->replaceElements(cast<MDTuple>(Elements));
-  if (TParams)
-    N->replaceTemplateParams(cast<MDTuple>(TParams));
-  DbgNode = N;
-}
-
 DIScopeRef DIScope::getRef() const { return MDScopeRef::get(get()); }
 
-void DICompositeType::setContainingType(DICompositeType ContainingType) {
-  TypedTrackingMDRef<MDCompositeTypeBase> N(get());
-  N->replaceVTableHolder(MDTypeRef::get(ContainingType));
-  DbgNode = N;
-}
-
 bool DIVariable::isInlinedFnArgument(const Function *CurFn) {
   assert(CurFn && "Invalid function");
   DISubprogram SP = dyn_cast<MDSubprogram>(getContext());





More information about the llvm-commits mailing list