X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FIR%2FDebugInfo.cpp;h=87984a097592b6d24e004eb5eeeb1dc0536ad1fe;hb=2c46deb1d07f4588ee70059cdd4c7145f81bc8e8;hp=51c9e58b2d7c2c598d5afb6cd3d4f992d7c8acc4;hpb=1039e106d095979b3707bb27cfa765cd2c0f3b54;p=oota-llvm.git diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 51c9e58b2d7..87984a09759 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -725,13 +725,13 @@ void DICompositeType::addMember(DIDescriptor D) { /// Generate a reference to this DIType. Uses the type identifier instead /// of the actual MDNode if possible, to help type uniquing. -Value *DIScope::generateRef() { +DIScopeRef DIScope::generateRef() { if (!isCompositeType()) - return *this; + return DIScopeRef(*this); DICompositeType DTy(DbgNode); if (!DTy.getIdentifier()) - return *this; - return DTy.getIdentifier(); + return DIScopeRef(*this); + return DIScopeRef(DTy.getIdentifier()); } /// \brief Set the containing type. @@ -1432,26 +1432,14 @@ void DIVariable::printExtendedName(raw_ostream &OS) const { } } -DIScopeRef::DIScopeRef(const Value *V) : Val(V) { +/// Specialize constructor to make sure it has the correct type. +template <> +DIRef::DIRef(const Value *V) : Val(V) { assert(isScopeRef(V) && "DIScopeRef should be a MDString or MDNode"); } - -/// Given a DITypeIdentifierMap, tries to find the corresponding -/// DIScope for a DIScopeRef. -DIScope DIScopeRef::resolve(const DITypeIdentifierMap &Map) const { - if (!Val) - return DIScope(); - - if (const MDNode *MD = dyn_cast(Val)) - return DIScope(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(DIType(Iter->second).isType() && - "MDNode in DITypeIdentifierMap should be a DIType."); - return DIScope(Iter->second); +template <> +DIRef::DIRef(const Value *V) : Val(V) { + assert(isTypeRef(V) && "DITypeRef should be a MDString or MDNode"); } /// Specialize getFieldAs to handle fields that are references to DIScopes. @@ -1459,3 +1447,12 @@ template <> DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const { return DIScopeRef(getField(DbgNode, Elt)); } +/// Specialize getFieldAs to handle fields that are references to DITypes. +template <> +DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const { + return DITypeRef(getField(DbgNode, Elt)); +} + +DIScopeRef DIType::getContext() const { + return getFieldAs(2); +}