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
This commit is contained in:
Duncan P. N. Exon Smith 2015-04-07 18:41:54 +00:00
parent 876ee73d21
commit 8d06b52675
3 changed files with 17 additions and 96 deletions

View File

@ -255,7 +255,6 @@ template <typename T> class DIRef {
///
/// In the latter, MDString specifies the type identifier.
const Metadata *Val;
explicit DIRef(const Metadata *V);
public:
template <class U>
@ -266,8 +265,6 @@ public:
T resolve(const DITypeIdentifierMap &Map) const;
operator Metadata *() const { return const_cast<Metadata *>(Val); }
static DIRef get(const Metadata *MD) { return DIRef(MD); }
};
template <>
@ -276,22 +273,6 @@ template <>
DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const;
template <> DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const;
/// \brief Handle fields that are references to DIDescriptors.
template <>
DIDescriptorRef DIDescriptor::getFieldAs<DIDescriptorRef>(unsigned Elt) const;
/// \brief Specialize DIRef constructor for DIDescriptorRef.
template <> DIRef<DIDescriptor>::DIRef(const Metadata *V);
/// \brief Handle fields that are references to DIScopes.
template <> DIScopeRef DIDescriptor::getFieldAs<DIScopeRef>(unsigned Elt) const;
/// \brief Specialize DIRef constructor for DIScopeRef.
template <> DIRef<DIScope>::DIRef(const Metadata *V);
/// \brief Handle fields that are references to DITypes.
template <> DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const;
/// \brief Specialize DIRef constructor for DITypeRef.
template <> DIRef<DIType>::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<MDDerivedType>(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(); }
};

View File

@ -50,6 +50,7 @@ template <class T> class TypedDebugNodeRef {
const Metadata *MD = nullptr;
public:
TypedDebugNodeRef() = default;
TypedDebugNodeRef(std::nullptr_t) {}
/// \brief Construct from a raw pointer.

View File

@ -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<MDString>(MD))
return !S->getString().empty();
return isa<MDType>(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<MDString>(MD))
return !S->getString().empty();
return isa<MDScope>(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<MDString>(MD))
return !S->getString().empty();
return isa<MDNode>(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<MDSubprogram>(*this))
return DIScopeRef(SP.getContext());
return MDScopeRef(SP.getContext());
if (DILexicalBlock LB = dyn_cast<MDLexicalBlockBase>(*this))
return DIScopeRef(LB.getContext());
return MDScopeRef(LB.getContext());
if (DINameSpace NS = dyn_cast<MDNamespace>(*this))
return DIScopeRef(NS.getContext());
return MDScopeRef(NS.getContext());
assert((isa<MDFile>(*this) || isa<MDCompileUnit>(*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<DIDescriptor>::DIRef(const Metadata *V) : Val(V) {
assert(isDescriptorRef(V) &&
"DIDescriptorRef should be a MDString or MDNode");
}
template <> DIRef<DIScope>::DIRef(const Metadata *V) : Val(V) {
assert(isScopeRef(V) && "DIScopeRef should be a MDString or MDNode");
}
template <> DIRef<DIType>::DIRef(const Metadata *V) : Val(V) {
assert(isTypeRef(V) && "DITypeRef should be a MDString or MDNode");
}
template <>
DIDescriptorRef DIDescriptor::getFieldAs<DIDescriptorRef>(unsigned Elt) const {
return DIDescriptorRef(cast_or_null<Metadata>(getField(DbgNode, Elt)));
}
template <>
DIScopeRef DIDescriptor::getFieldAs<DIScopeRef>(unsigned Elt) const {
return DIScopeRef(cast_or_null<Metadata>(getField(DbgNode, Elt)));
}
template <> DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const {
return DITypeRef(cast_or_null<Metadata>(getField(DbgNode, Elt)));
}
template <>
DIDescriptor
DIRef<DIDescriptor>::resolve(const DITypeIdentifierMap &Map) const {