summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-07 18:41:54 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-04-07 18:41:54 +0000
commit8d06b526759ed6c9f91a71936678e9f39b321da6 (patch)
treec90154907c509b9ac643b24d9cf31b27501c2b28
parent876ee73d212380bc7660b7f16ec522b805a2dd3c (diff)
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
-rw-r--r--include/llvm/IR/DebugInfo.h52
-rw-r--r--include/llvm/IR/DebugInfoMetadata.h1
-rw-r--r--lib/IR/DebugInfo.cpp60
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 <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(); }
};
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 T> 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<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 {