From 8d06b526759ed6c9f91a71936678e9f39b321da6 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Tue, 7 Apr 2015 18:41:54 +0000 Subject: [PATCH] DebugInfo: Remove constructors for DIRef<> Remove all constructors for `DIRef<>` *except* the ones forwarding from `TypedDebugNodeRef`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234340 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DebugInfo.h | 52 ++++++------------------- include/llvm/IR/DebugInfoMetadata.h | 1 + lib/IR/DebugInfo.cpp | 60 ++--------------------------- 3 files changed, 17 insertions(+), 96 deletions(-) diff --git a/include/llvm/IR/DebugInfo.h b/include/llvm/IR/DebugInfo.h index dc1514d16af..88e81f372fe 100644 --- a/include/llvm/IR/DebugInfo.h +++ b/include/llvm/IR/DebugInfo.h @@ -255,7 +255,6 @@ template class DIRef { /// /// In the latter, MDString specifies the type identifier. const Metadata *Val; - explicit DIRef(const Metadata *V); public: template @@ -266,8 +265,6 @@ public: T resolve(const DITypeIdentifierMap &Map) const; operator Metadata *() const { return const_cast(Val); } - - static DIRef get(const Metadata *MD) { return DIRef(MD); } }; template <> @@ -276,22 +273,6 @@ template <> DIScope DIRef::resolve(const DITypeIdentifierMap &Map) const; template <> DIType DIRef::resolve(const DITypeIdentifierMap &Map) const; -/// \brief Handle fields that are references to DIDescriptors. -template <> -DIDescriptorRef DIDescriptor::getFieldAs(unsigned Elt) const; -/// \brief Specialize DIRef constructor for DIDescriptorRef. -template <> DIRef::DIRef(const Metadata *V); - -/// \brief Handle fields that are references to DIScopes. -template <> DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; -/// \brief Specialize DIRef constructor for DIScopeRef. -template <> DIRef::DIRef(const Metadata *V); - -/// \brief Handle fields that are references to DITypes. -template <> DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; -/// \brief Specialize DIRef constructor for DITypeRef. -template <> DIRef::DIRef(const Metadata *V); - /// \brief This is a wrapper for a type. /// /// FIXME: Types should be factored much better so that CV qualifiers and @@ -309,7 +290,7 @@ public: return *get(); } - DIScopeRef getContext() const { return DIScopeRef::get(get()->getScope()); } + DIScopeRef getContext() const { return get()->getScope(); } StringRef getName() const { return get()->getName(); } unsigned getLineNumber() const { return get()->getLine(); } uint64_t getSizeInBits() const { return get()->getSizeInBits(); } @@ -375,9 +356,7 @@ public: return *get(); } - DITypeRef getTypeDerivedFrom() const { - return DITypeRef::get(get()->getBaseType()); - } + DITypeRef getTypeDerivedFrom() const { return get()->getBaseType(); } /// \brief Return property node, if this ivar is associated with one. MDNode *getObjCProperty() const { @@ -389,8 +368,8 @@ public: DITypeRef getClassType() const { assert(getTag() == dwarf::DW_TAG_ptr_to_member_type); if (auto *N = dyn_cast(get())) - return DITypeRef::get(N->getExtraData()); - return DITypeRef::get(nullptr); + return MDTypeRef(N->getExtraData()); + return MDTypeRef(); } Constant *getConstant() const { @@ -435,9 +414,7 @@ public: } unsigned getRunTimeLang() const { return get()->getRuntimeLang(); } - DITypeRef getContainingType() const { - return DITypeRef::get(get()->getVTableHolder()); - } + DITypeRef getContainingType() const { return get()->getVTableHolder(); } DIArray getTemplateParams() const { return get()->getTemplateParams(); } MDString *getIdentifier() const { return get()->getRawIdentifier(); } @@ -559,14 +536,12 @@ public: /// \brief Get the beginning of the scope of the function (not the name). unsigned getScopeLineNumber() const { return get()->getScopeLine(); } - DIScopeRef getContext() const { return DIScopeRef::get(get()->getScope()); } + DIScopeRef getContext() const { return get()->getScope(); } DISubroutineType getType() const { return DISubroutineType(get()->getType()); } - DITypeRef getContainingType() const { - return DITypeRef::get(get()->getContainingType()); - } + DITypeRef getContainingType() const { return get()->getContainingType(); } /// \brief Check if this provides debugging information for the function F. bool describes(const Function *F); @@ -682,8 +657,7 @@ public: } StringRef getName() const { return get()->getName(); } - - DITypeRef getType() const { return DITypeRef::get(get()->getType()); } + DITypeRef getType() const { return get()->getType(); } }; /// \brief This is a wrapper for template value parameter. @@ -704,7 +678,7 @@ public: } StringRef getName() const { return get()->getName(); } - DITypeRef getType() const { return DITypeRef::get(get()->getType()); } + DITypeRef getType() const { return get()->getType(); } Metadata *getValue() const { return get()->getValue(); } }; @@ -736,7 +710,7 @@ public: DIScope getContext() const { return DIScope(get()->getScope()); } StringRef getFilename() const { return getFile().getFilename(); } StringRef getDirectory() const { return getFile().getDirectory(); } - DITypeRef getType() const { return DITypeRef::get(get()->getType()); } + DITypeRef getType() const { return get()->getType(); } GlobalVariable *getGlobal() const; Constant *getConstant() const { @@ -774,7 +748,7 @@ public: DIScope getContext() const { return DIScope(get()->getScope()); } DIFile getFile() const { return DIFile(get()->getFile()); } - DITypeRef getType() const { return DITypeRef::get(get()->getType()); } + DITypeRef getType() const { return get()->getType(); } bool isArtificial() const { return get()->isArtificial(); } bool isObjectPointer() const { return get()->isObjectPointer(); } @@ -944,9 +918,7 @@ public: } DIScope getContext() const { return DIScope(get()->getScope()); } - DIDescriptorRef getEntity() const { - return DIDescriptorRef::get(get()->getEntity()); - } + DIDescriptorRef getEntity() const { return get()->getEntity(); } unsigned getLineNumber() const { return get()->getLine(); } StringRef getName() const { return get()->getName(); } }; diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index 18619f37420..4bed55ef1bd 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -50,6 +50,7 @@ template class TypedDebugNodeRef { const Metadata *MD = nullptr; public: + TypedDebugNodeRef() = default; TypedDebugNodeRef(std::nullptr_t) {} /// \brief Construct from a raw pointer. diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 0062f1bbf58..56db33a63d2 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -96,35 +96,6 @@ void DIDescriptor::replaceAllUsesWith(MDNode *D) { Node->replaceAllUsesWith(D); } -#ifndef NDEBUG -/// \brief Check if a value can be a reference to a type. -static bool isTypeRef(const Metadata *MD) { - if (!MD) - return true; - if (auto *S = dyn_cast(MD)) - return !S->getString().empty(); - return isa(MD); -} - -/// \brief Check if a value can be a ScopeRef. -static bool isScopeRef(const Metadata *MD) { - if (!MD) - return true; - if (auto *S = dyn_cast(MD)) - return !S->getString().empty(); - return isa(MD); -} - -/// \brief Check if a value can be a DescriptorRef. -static bool isDescriptorRef(const Metadata *MD) { - if (!MD) - return true; - if (auto *S = dyn_cast(MD)) - return !S->getString().empty(); - return isa(MD); -} -#endif - DIScopeRef DIScope::getRef() const { return MDScopeRef::get(get()); } bool DIVariable::isInlinedFnArgument(const Function *CurFn) { @@ -165,17 +136,17 @@ DIScopeRef DIScope::getContext() const { return T.getContext(); if (DISubprogram SP = dyn_cast(*this)) - return DIScopeRef(SP.getContext()); + return MDScopeRef(SP.getContext()); if (DILexicalBlock LB = dyn_cast(*this)) - return DIScopeRef(LB.getContext()); + return MDScopeRef(LB.getContext()); if (DINameSpace NS = dyn_cast(*this)) - return DIScopeRef(NS.getContext()); + return MDScopeRef(NS.getContext()); assert((isa(*this) || isa(*this)) && "Unhandled type of scope."); - return DIScopeRef(nullptr); + return MDScopeRef(); } StringRef DIScope::getName() const { @@ -564,29 +535,6 @@ void DIVariable::printExtendedName(raw_ostream &OS) const { } } -template <> DIRef::DIRef(const Metadata *V) : Val(V) { - assert(isDescriptorRef(V) && - "DIDescriptorRef should be a MDString or MDNode"); -} -template <> DIRef::DIRef(const Metadata *V) : Val(V) { - assert(isScopeRef(V) && "DIScopeRef should be a MDString or MDNode"); -} -template <> DIRef::DIRef(const Metadata *V) : Val(V) { - assert(isTypeRef(V) && "DITypeRef should be a MDString or MDNode"); -} - -template <> -DIDescriptorRef DIDescriptor::getFieldAs(unsigned Elt) const { - return DIDescriptorRef(cast_or_null(getField(DbgNode, Elt))); -} -template <> -DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const { - return DIScopeRef(cast_or_null(getField(DbgNode, Elt))); -} -template <> DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const { - return DITypeRef(cast_or_null(getField(DbgNode, Elt))); -} - template <> DIDescriptor DIRef::resolve(const DITypeIdentifierMap &Map) const { -- 2.34.1