diff --git a/llvm/include/llvm/DebugInfo.h b/llvm/include/llvm/DebugInfo.h index 8486b1023419..ad0149476a17 100644 --- a/llvm/include/llvm/DebugInfo.h +++ b/llvm/include/llvm/DebugInfo.h @@ -226,24 +226,27 @@ template class DIRef { explicit DIRef(const Value *V); public: - T resolve(const DITypeIdentifierMap &Map) const { - if (!Val) - return T(); - - if (const MDNode *MD = dyn_cast(Val)) - return T(MD); - - const MDString *MS = cast(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); - } + T resolve(const DITypeIdentifierMap &Map) const; operator Value *() const { return const_cast(Val); } }; +template +T DIRef::resolve(const DITypeIdentifierMap &Map) const { + if (!Val) + return T(); + + if (const MDNode *MD = dyn_cast(Val)) + return T(MD); + + const MDString *MS = cast(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. template <> DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; /// Specialize DIRef constructor for DIScopeRef.