DebugInfo: Reimplement DIRef<>::resolve() using TypedDebugNodeRef<>

Gut `DIRef<>::resolve()`, reimplementing it using
`TypedDebugNodeRef<>::resolve()`.  Use three separate functions rather
than some sort of type traits, since the latter (i.e., mapping `DIScope`
=> `MDScope`) seems heavy-handed.  I don't expect `DIRef<>` to last much
longer in tree anyway.

As a drive-by fix, make `TypedDebugNodeRef<>::resolve()` do the right
thing with `nullptr`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234248 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-04-06 22:27:37 +00:00
parent 93d8e23940
commit a10307bf95
3 changed files with 22 additions and 16 deletions

View File

@@ -685,6 +685,20 @@ 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 {
return DIDescriptor(DebugNodeRef(Val).resolve(Map));
}
template <>
DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const {
return MDScopeRef(Val).resolve(Map);
}
template <>
DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const {
return MDTypeRef(Val).resolve(Map);
}
bool llvm::stripDebugInfo(Function &F) {
bool Changed = false;
for (BasicBlock &BB : F) {