/// This should not be stored in a container, because the underlying MDNode may
/// change in certain situations.
class DIDescriptor {
- // Befriends DIRef so DIRef can befriend the protected member
- // function: getFieldAs<DIRef>.
- template <typename T> friend class DIRef;
-
public:
/// \brief Duplicated debug info flags.
///
protected:
const MDNode *DbgNode;
- DIDescriptor getDescriptorField(unsigned Elt) const;
- template <typename DescTy> DescTy getFieldAs(unsigned Elt) const {
- return DescTy(getDescriptorField(Elt));
- }
-
public:
explicit DIDescriptor(const MDNode *N = nullptr) : DbgNode(N) {}
+ DIDescriptor(const DebugNode *N) : DbgNode(N) {}
MDNode *get() const { return const_cast<MDNode *>(DbgNode); }
operator MDNode *() const { return get(); }
DECLARE_SIMPLIFY_DESCRIPTOR(DIImportedEntity)
#undef DECLARE_SIMPLIFY_DESCRIPTOR
+typedef DebugNodeArray DIArray;
+typedef MDTypeRefArray DITypeArray;
+
/// \brief This is used to represent ranges, for array bounds.
class DISubrange : public DIDescriptor {
public:
int64_t getCount() const { return get()->getCount(); }
};
-/// \brief This descriptor holds an array of nodes with type T.
-template <typename T> class DITypedArray : public DIDescriptor {
-public:
- explicit DITypedArray(const MDNode *N = nullptr) : DIDescriptor(N) {}
- operator MDTuple *() const {
- return const_cast<MDTuple *>(cast_or_null<MDTuple>(DbgNode));
- }
- unsigned getNumElements() const {
- return DbgNode ? DbgNode->getNumOperands() : 0;
- }
- T getElement(unsigned Idx) const { return getFieldAs<T>(Idx); }
-};
-
-typedef DITypedArray<DIDescriptor> DIArray;
-
/// \brief A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
///
/// FIXME: it seems strange that this doesn't have either a reference to the
typedef DIRef<DIDescriptor> DIDescriptorRef;
typedef DIRef<DIScope> DIScopeRef;
typedef DIRef<DIType> DITypeRef;
-typedef DITypedArray<DITypeRef> DITypeArray;
/// \brief A base class for various scopes.
///
///
/// If the scope node has a name, return that, else return an empty string.
StringRef getName() const;
- StringRef getFilename() const;
- StringRef getDirectory() const;
+ StringRef getFilename() const { return get()->getFilename(); }
+ StringRef getDirectory() const { return get()->getDirectory(); }
/// \brief Generate a reference to this DIScope.
///
///
/// Abstracts over direct and identifier-based metadata references.
template <typename T> class DIRef {
- template <typename DescTy>
- friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const;
- friend DIScopeRef DIScope::getContext() const;
- friend DIScopeRef DIScope::getRef() const;
- friend class DIType;
-
/// \brief Val can be either a MDNode or a MDString.
///
/// In the latter, MDString specifies the type identifier.
const Metadata *Val;
- explicit DIRef(const Metadata *V);
public:
template <class U>
T resolve(const DITypeIdentifierMap &Map) const;
operator Metadata *() const { return const_cast<Metadata *>(Val); }
-
- static DIRef get(const Metadata *MD) { return DIRef(MD); }
};
template <>
DIScope DIRef<DIScope>::resolve(const DITypeIdentifierMap &Map) const;
template <> DIType DIRef<DIType>::resolve(const DITypeIdentifierMap &Map) const;
-/// \brief Handle fields that are references to DIDescriptors.
-template <>
-DIDescriptorRef DIDescriptor::getFieldAs<DIDescriptorRef>(unsigned Elt) const;
-/// \brief Specialize DIRef constructor for DIDescriptorRef.
-template <> DIRef<DIDescriptor>::DIRef(const Metadata *V);
-
-/// \brief Handle fields that are references to DIScopes.
-template <> DIScopeRef DIDescriptor::getFieldAs<DIScopeRef>(unsigned Elt) const;
-/// \brief Specialize DIRef constructor for DIScopeRef.
-template <> DIRef<DIScope>::DIRef(const Metadata *V);
-
-/// \brief Handle fields that are references to DITypes.
-template <> DITypeRef DIDescriptor::getFieldAs<DITypeRef>(unsigned Elt) const;
-/// \brief Specialize DIRef constructor for DITypeRef.
-template <> DIRef<DIType>::DIRef(const Metadata *V);
-
/// \brief This is a wrapper for a type.
///
/// FIXME: Types should be factored much better so that CV qualifiers and
return *get();
}
- DIScopeRef getContext() const { return DIScopeRef::get(get()->getScope()); }
+ DIScopeRef getContext() const { return get()->getScope(); }
StringRef getName() const { return get()->getName(); }
unsigned getLineNumber() const { return get()->getLine(); }
uint64_t getSizeInBits() const { return get()->getSizeInBits(); }
return *get();
}
- DITypeRef getTypeDerivedFrom() const {
- return DITypeRef::get(get()->getBaseType());
- }
+ DITypeRef getTypeDerivedFrom() const { return get()->getBaseType(); }
/// \brief Return property node, if this ivar is associated with one.
MDNode *getObjCProperty() const {
DITypeRef getClassType() const {
assert(getTag() == dwarf::DW_TAG_ptr_to_member_type);
if (auto *N = dyn_cast<MDDerivedType>(get()))
- return DITypeRef::get(N->getExtraData());
- return DITypeRef::get(nullptr);
+ return MDTypeRef(N->getExtraData());
+ return MDTypeRef();
}
Constant *getConstant() const {
class DICompositeType : public DIDerivedType {
friend class DIBuilder;
- /// \brief Set the array of member DITypes.
- void setArraysHelper(MDNode *Elements, MDNode *TParams);
-
public:
DICompositeType() = default;
DICompositeType(const MDCompositeTypeBase *N) : DIDerivedType(N) {}
return DIArray(get()->getElements());
}
-private:
- template <typename T>
- void setArrays(DITypedArray<T> Elements, DIArray TParams = DIArray()) {
- assert(
- (!TParams || DbgNode->getNumOperands() == 8) &&
- "If you're setting the template parameters this should include a slot "
- "for that!");
- setArraysHelper(Elements, TParams);
- }
-
-public:
unsigned getRunTimeLang() const { return get()->getRuntimeLang(); }
- DITypeRef getContainingType() const {
- return DITypeRef::get(get()->getVTableHolder());
- }
+ DITypeRef getContainingType() const { return get()->getVTableHolder(); }
-private:
- /// \brief Set the containing type.
- void setContainingType(DICompositeType ContainingType);
-
-public:
- DIArray getTemplateParams() const {
- return DIArray(get()->getTemplateParams());
- }
+ DIArray getTemplateParams() const { return get()->getTemplateParams(); }
MDString *getIdentifier() const { return get()->getRawIdentifier(); }
};
return *get();
}
- DITypedArray<DITypeRef> getTypeArray() const {
- return DITypedArray<DITypeRef>(get()->getTypeArray());
- }
+ MDTypeRefArray getTypeArray() const { return get()->getTypeArray(); }
};
/// \brief This is a wrapper for a file.
/// \brief Get the beginning of the scope of the function (not the name).
unsigned getScopeLineNumber() const { return get()->getScopeLine(); }
- DIScopeRef getContext() const { return DIScopeRef::get(get()->getScope()); }
+ DIScopeRef getContext() const { return get()->getScope(); }
DISubroutineType getType() const {
return DISubroutineType(get()->getType());
}
- DITypeRef getContainingType() const {
- return DITypeRef::get(get()->getContainingType());
- }
+ DITypeRef getContainingType() const { return get()->getContainingType(); }
/// \brief Check if this provides debugging information for the function F.
bool describes(const Function *F);
DISubprogram getFunctionDeclaration() const {
return DISubprogram(get()->getDeclaration());
}
- MDNode *getVariablesNodes() const { return getVariables(); }
DIArray getVariables() const { return DIArray(get()->getVariables()); }
unsigned isArtificial() const { return get()->isArtificial(); }
}
StringRef getName() const { return get()->getName(); }
-
- DITypeRef getType() const { return DITypeRef::get(get()->getType()); }
+ DITypeRef getType() const { return get()->getType(); }
};
/// \brief This is a wrapper for template value parameter.
}
StringRef getName() const { return get()->getName(); }
- DITypeRef getType() const { return DITypeRef::get(get()->getType()); }
+ DITypeRef getType() const { return get()->getType(); }
Metadata *getValue() const { return get()->getValue(); }
};
unsigned isDefinition() const { return get()->isDefinition(); }
DIScope getContext() const { return DIScope(get()->getScope()); }
- StringRef getFilename() const { return getFile().getFilename(); }
- StringRef getDirectory() const { return getFile().getDirectory(); }
- DITypeRef getType() const { return DITypeRef::get(get()->getType()); }
+ StringRef getFilename() const { return get()->getFilename(); }
+ StringRef getDirectory() const { return get()->getDirectory(); }
+ DITypeRef getType() const { return get()->getType(); }
GlobalVariable *getGlobal() const;
Constant *getConstant() const {
DIScope getContext() const { return DIScope(get()->getScope()); }
DIFile getFile() const { return DIFile(get()->getFile()); }
- DITypeRef getType() const { return DITypeRef::get(get()->getType()); }
+ DITypeRef getType() const { return get()->getType(); }
bool isArtificial() const { return get()->isArtificial(); }
bool isObjectPointer() const { return get()->isObjectPointer(); }
DILocation getOrigLocation() const {
return DILocation(get()->getInlinedAt());
}
- StringRef getFilename() const { return getScope().getFilename(); }
- StringRef getDirectory() const { return getScope().getDirectory(); }
- bool atSameLineAs(const DILocation &Other) const {
- return (getLineNumber() == Other.getLineNumber() &&
- getFilename() == Other.getFilename());
- }
+ StringRef getFilename() const { return get()->getFilename(); }
+ StringRef getDirectory() const { return get()->getDirectory(); }
+
/// \brief Get the DWAF discriminator.
///
/// DWARF discriminators are used to distinguish identical file locations for
}
DIScope getContext() const { return DIScope(get()->getScope()); }
- DIDescriptorRef getEntity() const {
- return DIDescriptorRef::get(get()->getEntity());
- }
+ DIDescriptorRef getEntity() const { return get()->getEntity(); }
unsigned getLineNumber() const { return get()->getLine(); }
StringRef getName() const { return get()->getName(); }
};