Use TrackingVH instead of WeakVH for NamedMDNode's operands, since nodes
[oota-llvm.git] / include / llvm / Metadata.h
index e5363228a3966bff80e0e9cb14b3c98b13e145bf..7cfcb7007950ae18867be5e59becd66529337434 100644 (file)
@@ -43,8 +43,10 @@ protected:
 
 public:
   static MDString *get(LLVMContext &Context, StringRef Str);
-  static MDString *get(LLVMContext &Context, const char *Str);
-  
+  static MDString *get(LLVMContext &Context, const char *Str) {
+    return get(Context, Str ? StringRef(Str) : StringRef());
+  }
+
   StringRef getString() const { return Str; }
 
   unsigned getLength() const { return (unsigned)Str.size(); }
@@ -89,7 +91,7 @@ class MDNode : public Value, public FoldingSetNode {
     FunctionLocalBit = 1 << 0,
     
     /// NotUniquedBit - This is set on MDNodes that are not uniqued because they
-    /// have a null perand.
+    /// have a null operand.
     NotUniquedBit    = 1 << 1,
     
     /// DestroyFlag - This bit is set by destroy() so the destructor can assert
@@ -108,9 +110,6 @@ class MDNode : public Value, public FoldingSetNode {
   /// node with T.
   void replaceOperand(MDNodeOperand *Op, Value *NewVal);
   ~MDNode();
-  /// replaceAllOperandsWithNull - This is used while destroying llvm context to 
-  /// gracefully delete all nodes. This method replaces all operands with null.
-  void replaceAllOperandsWithNull();
 
 protected:
   explicit MDNode(LLVMContext &C, Value *const *Vals, unsigned NumVals,
@@ -166,9 +165,7 @@ private:
   bool isNotUniqued() const { 
     return (getSubclassDataFromValue() & NotUniquedBit) != 0;
   }
-  void setIsNotUniqued() {
-    setValueSubclassData(getSubclassDataFromValue() | NotUniquedBit);
-  }
+  void setIsNotUniqued();
   
   // Shadow Value::setValueSubclassData with a private forwarding method so that
   // any future subclasses cannot accidentally use it.
@@ -188,7 +185,7 @@ class NamedMDNode : public Value, public ilist_node<NamedMDNode> {
 
   std::string Name;
   Module *Parent;
-  void *Operands; // SmallVector<WeakVH<MDNode>, 4>
+  void *Operands; // SmallVector<TrackingVH<MDNode>, 4>
 
   void setParent(Module *M) { Parent = M; }
 protected: