mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-06 20:32:19 +00:00
Pull this out for a bit of readability.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191999 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
916d49e772
commit
164793918c
@ -226,24 +226,27 @@ template <typename T> class DIRef {
|
|||||||
explicit DIRef(const Value *V);
|
explicit DIRef(const Value *V);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
T resolve(const DITypeIdentifierMap &Map) const {
|
T resolve(const DITypeIdentifierMap &Map) const;
|
||||||
if (!Val)
|
|
||||||
return T();
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
operator Value *() const { return const_cast<Value *>(Val); }
|
operator Value *() const { return const_cast<Value *>(Val); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T DIRef<T>::resolve(const DITypeIdentifierMap &Map) const {
|
||||||
|
if (!Val)
|
||||||
|
return T();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/// Specialize getFieldAs to handle fields that are references to DIScopes.
|
/// Specialize getFieldAs to handle fields that are references to DIScopes.
|
||||||
template <> DIScopeRef DIDescriptor::getFieldAs<DIScopeRef>(unsigned Elt) const;
|
template <> DIScopeRef DIDescriptor::getFieldAs<DIScopeRef>(unsigned Elt) const;
|
||||||
/// Specialize DIRef constructor for DIScopeRef.
|
/// Specialize DIRef constructor for DIScopeRef.
|
||||||
|
Loading…
Reference in New Issue
Block a user