mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-28 09:31:03 +00:00
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:
parent
93d8e23940
commit
a10307bf95
@ -301,22 +301,11 @@ public:
|
|||||||
static DIRef get(const Metadata *MD) { return DIRef(MD); }
|
static DIRef get(const Metadata *MD) { return DIRef(MD); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <>
|
||||||
T DIRef<T>::resolve(const DITypeIdentifierMap &Map) const {
|
DIDescriptor DIRef<DIDescriptor>::resolve(const DITypeIdentifierMap &Map) const;
|
||||||
if (!Val)
|
template <>
|
||||||
return T();
|
DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const;
|
||||||
|
template <> DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const;
|
||||||
if (const MDNode *MD = dyn_cast<MDNode>(Val))
|
|
||||||
return T(MD);
|
|
||||||
|
|
||||||
const MDString *MS = cast<MDString>(Val);
|
|
||||||
// Find the corresponding MDNode.
|
|
||||||
DITypeIdentifierMap::const_iterator Iter = Map.find(MS);
|
|
||||||
assert(Iter != Map.end() && "Identifier not in the type map?");
|
|
||||||
assert(DIDescriptor(Iter->second).isType() &&
|
|
||||||
"MDNode in DITypeIdentifierMap should be a DIType.");
|
|
||||||
return T(Iter->second);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// \brief Handle fields that are references to DIDescriptors.
|
/// \brief Handle fields that are references to DIDescriptors.
|
||||||
template <>
|
template <>
|
||||||
|
@ -75,6 +75,9 @@ public:
|
|||||||
static TypedDebugNodeRef get(const T *N);
|
static TypedDebugNodeRef get(const T *N);
|
||||||
|
|
||||||
template <class MapTy> T *resolve(const MapTy &Map) const {
|
template <class MapTy> T *resolve(const MapTy &Map) const {
|
||||||
|
if (!MD)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
if (auto *Typed = dyn_cast<T>(MD))
|
if (auto *Typed = dyn_cast<T>(MD))
|
||||||
return const_cast<T *>(Typed);
|
return const_cast<T *>(Typed);
|
||||||
|
|
||||||
|
@ -685,6 +685,20 @@ template <> DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const {
|
|||||||
return DITypeRef(cast_or_null<Metadata>(getField(DbgNode, Elt)));
|
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 llvm::stripDebugInfo(Function &F) {
|
||||||
bool Changed = false;
|
bool Changed = false;
|
||||||
for (BasicBlock &BB : F) {
|
for (BasicBlock &BB : F) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user