-//===----------------------------------------------------------------------===//
-/// MetadataContext -
-/// MetadataContext handles uniquing and assignment of IDs for custom metadata
-/// types. Custom metadata handler names do not contain spaces. And the name
-/// must start with an alphabet. The regular expression used to check name
-/// is [a-zA-Z$._][a-zA-Z$._0-9]*
-class MetadataContext {
- // DO NOT IMPLEMENT
- MetadataContext(MetadataContext&);
- void operator=(MetadataContext&);
-
- MetadataContextImpl *const pImpl;
-public:
- MetadataContext();
- ~MetadataContext();
-
- /// registerMDKind - Register a new metadata kind and return its ID.
- /// A metadata kind can be registered only once.
- unsigned registerMDKind(StringRef Name);
-
- /// getMDKind - Return metadata kind. If the requested metadata kind
- /// is not registered then return 0.
- unsigned getMDKind(StringRef Name) const;
-
- /// isValidName - Return true if Name is a valid custom metadata handler name.
- static bool isValidName(StringRef Name);
-
- /// getMD - Get the metadata of given kind attached to an Instruction.
- /// If the metadata is not found then return 0.
- MDNode *getMD(unsigned Kind, const Instruction *Inst);
-
- /// getMDs - Get the metadata attached to an Instruction.
- void getMDs(const Instruction *Inst,
- SmallVectorImpl<std::pair<unsigned, TrackingVH<MDNode> > > &MDs) const;
-
- /// addMD - Attach the metadata of given kind to an Instruction.
- void addMD(unsigned Kind, MDNode *Node, Instruction *Inst);
-
- /// removeMD - Remove metadata of given kind attached with an instuction.
- void removeMD(unsigned Kind, Instruction *Inst);
-
- /// removeAllMetadata - Remove all metadata attached with an instruction.
- void removeAllMetadata(Instruction *Inst);
-
- /// copyMD - If metadata is attached with Instruction In1 then attach
- /// the same metadata to In2.
- void copyMD(Instruction *In1, Instruction *In2);
-
- /// getHandlerNames - Populate client supplied smallvector using custom
- /// metadata name and ID.
- void getHandlerNames(SmallVectorImpl<std::pair<unsigned, StringRef> >&) const;
-
- /// ValueIsDeleted - This handler is used to update metadata store
- /// when a value is deleted.
- void ValueIsDeleted(const Value *) {}
- void ValueIsDeleted(Instruction *Inst);
- void ValueIsRAUWd(Value *V1, Value *V2);
-
- /// ValueIsCloned - This handler is used to update metadata store
- /// when In1 is cloned to create In2.
- void ValueIsCloned(const Instruction *In1, Instruction *In2);
-};
-