From b135631d2e92dbe17738b5c6aadcfcaa2298a98a Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Tue, 7 Apr 2015 04:12:02 +0000 Subject: [PATCH] DebugInfo: Remove DICompositeType mutation API Change `DIBuilder` to mutate `MDCompositeTypeBase` directly, and remove the wrapping API in `DICompositeType`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234289 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DebugInfo.h | 19 ------------------- lib/IR/DIBuilder.cpp | 15 +++++++++++++-- lib/IR/DebugInfo.cpp | 15 --------------- 3 files changed, 13 insertions(+), 36 deletions(-) diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index c23cc4a7e4d..dd80875712c 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -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 - void setArrays(DITypedArray 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()); } diff --git a/lib/IR/DIBuilder.cpp b/lib/IR/DIBuilder.cpp index ba314b45462..fd863810068 100644 --- a/lib/IR/DIBuilder.cpp +++ b/lib/IR/DIBuilder.cpp @@ -835,7 +835,11 @@ Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, } void DIBuilder::replaceVTableHolder(DICompositeType &T, DICompositeType VTableHolder) { - T.setContainingType(VTableHolder); + { + TypedTrackingMDRef 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(DICompositeType &T, DICompositeType VTableHo void DIBuilder::replaceArrays(DICompositeType &T, DIArray Elements, DIArray TParams) { - T.setArrays(Elements, TParams); + { + TypedTrackingMDRef N(T); + if (Elements) + N->replaceElements(cast(Elements.get())); + if (TParams) + N->replaceTemplateParams(cast(TParams.get())); + T = N.get(); + } // If T isn't resolved, there's no problem. if (!T->isResolved()) diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 138df05ea4a..4c836924d88 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -125,23 +125,8 @@ static bool isDescriptorRef(const Metadata *MD) { } #endif -void DICompositeType::setArraysHelper(MDNode *Elements, MDNode *TParams) { - TypedTrackingMDRef N(get()); - if (Elements) - N->replaceElements(cast(Elements)); - if (TParams) - N->replaceTemplateParams(cast(TParams)); - DbgNode = N; -} - DIScopeRef DIScope::getRef() const { return MDScopeRef::get(get()); } -void DICompositeType::setContainingType(DICompositeType ContainingType) { - TypedTrackingMDRef N(get()); - N->replaceVTableHolder(MDTypeRef::get(ContainingType)); - DbgNode = N; -} - bool DIVariable::isInlinedFnArgument(const Function *CurFn) { assert(CurFn && "Invalid function"); DISubprogram SP = dyn_cast(getContext()); -- 2.11.0