DEBUG_METADATA_VERSION = 2 // Current debug info version number.
};
+/// \brief Root of the metadata hierarchy.
+///
+/// This is a root class for typeless data in the IR.
+///
+/// TODO: Detach from the Value hierarchy.
+class Metadata : public Value {
+protected:
+ Metadata(Type *Type, unsigned ID) : Value(Type, ID) {}
+
+public:
+ static bool classof(const Value *V) {
+ return V->getValueID() == MDNodeVal;
+ }
+};
+
//===----------------------------------------------------------------------===//
/// \brief A single uniqued string.
///
/// These are used to efficiently contain a byte sequence for metadata.
/// MDString is always unnamed.
+///
+/// TODO: Inherit from Metadata.
class MDString : public Value {
virtual void anchor();
MDString(const MDString &) LLVM_DELETED_FUNCTION;
class MDNodeOperand;
//===----------------------------------------------------------------------===//
-/// \brief A tuple of other values.
-class MDNode : public Value, public FoldingSetNode {
+/// \brief Generic tuple of metadata.
+class MDNode : public Metadata, public FoldingSetNode {
MDNode(const MDNode &) LLVM_DELETED_FUNCTION;
void operator=(const MDNode &) LLVM_DELETED_FUNCTION;
friend class MDNodeOperand;
///
/// Despite its name, a NamedMDNode isn't itself an MDNode. NamedMDNodes belong
/// to modules, have names, and contain lists of MDNodes.
+///
+/// TODO: Inherit from Metadata.
class NamedMDNode : public ilist_node<NamedMDNode> {
friend class SymbolTableListTraits<NamedMDNode, Module>;
friend struct ilist_traits<NamedMDNode>;
replaceOperand(Op, Val);
}
-MDNode::MDNode(LLVMContext &C, ArrayRef<Value*> Vals, bool isFunctionLocal)
-: Value(Type::getMetadataTy(C), Value::MDNodeVal) {
+MDNode::MDNode(LLVMContext &C, ArrayRef<Value *> Vals, bool isFunctionLocal)
+ : Metadata(Type::getMetadataTy(C), Value::MDNodeVal) {
NumOperands = Vals.size();
if (isFunctionLocal)