Make NamedMDNode not be a subclass of Value, and simplify the interface
[oota-llvm.git] / include / llvm / Module.h
index 9b7cd4c88d768c3039b2b040d7b9b9eb50bb15ae..45247ec31c5e8a059ff829c337343f9a3dd2ae34 100644 (file)
@@ -28,7 +28,6 @@ namespace llvm {
 class FunctionType;
 class GVMaterializer;
 class LLVMContext;
-class MDSymbolTable;
 
 template<> struct ilist_traits<Function>
   : public SymbolTableListTraits<Function, Module> {
@@ -61,7 +60,7 @@ template<> struct ilist_traits<GlobalAlias>
 };
 
 template<> struct ilist_traits<NamedMDNode>
-  : public SymbolTableListTraits<NamedMDNode, Module> {
+  : public ilist_default_traits<NamedMDNode> {
   // createSentinel is used to get hold of a node that marks the end of
   // the list...
   NamedMDNode *createSentinel() const {
@@ -72,8 +71,8 @@ template<> struct ilist_traits<NamedMDNode>
   NamedMDNode *provideInitialHead() const { return createSentinel(); }
   NamedMDNode *ensureHead(NamedMDNode*) const { return createSentinel(); }
   static void noteHead(NamedMDNode*, NamedMDNode*) {}
-  void addNodeToList(NamedMDNode *N);
-  void removeNodeFromList(NamedMDNode *N);
+  void addNodeToList(NamedMDNode *N) {}
+  void removeNodeFromList(NamedMDNode *N) {}
 private:
   mutable ilist_node<NamedMDNode> Sentinel;
 };
@@ -100,7 +99,7 @@ public:
   /// The type for the list of aliases.
   typedef iplist<GlobalAlias> AliasListType;
   /// The type for the list of named metadata.
-  typedef iplist<NamedMDNode> NamedMDListType;
+  typedef ilist<NamedMDNode> NamedMDListType;
 
   /// The type for the list of dependent libraries.
   typedef std::vector<std::string> LibraryListType;
@@ -151,7 +150,7 @@ private:
   std::string ModuleID;           ///< Human readable identifier for the module
   std::string TargetTriple;       ///< Platform target triple Module compiled on
   std::string DataLayout;         ///< Target data description
-  MDSymbolTable *NamedMDSymTab;   ///< NamedMDNode names.
+  void *NamedMDSymTab;            ///< NamedMDNode names.
 
   friend class Constant;
 
@@ -331,6 +330,10 @@ public:
   /// NamedMDNode with the specified name is not found.
   NamedMDNode *getOrInsertNamedMetadata(StringRef Name);
 
+  /// eraseNamedMetadata - Remove the given NamedMDNode from this module
+  /// and delete it.
+  void eraseNamedMetadata(NamedMDNode *NMD);
+
 /// @}
 /// @name Type Accessors
 /// @{
@@ -417,13 +420,6 @@ public:
   static iplist<GlobalAlias> Module::*getSublistAccess(GlobalAlias*) {
     return &Module::AliasList;
   }
-  /// Get the Module's list of named metadata (constant).
-  const NamedMDListType  &getNamedMDList() const      { return NamedMDList; }
-  /// Get the Module's list of named metadata.
-  NamedMDListType  &getNamedMDList()                  { return NamedMDList; }
-  static iplist<NamedMDNode> Module::*getSublistAccess(NamedMDNode *) {
-    return &Module::NamedMDList;
-  }
   /// Get the symbol table of global variable and function identifiers
   const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
   /// Get the Module's symbol table of global variable and function identifiers.
@@ -432,10 +428,6 @@ public:
   const TypeSymbolTable  &getTypeSymbolTable() const  { return *TypeSymTab; }
   /// Get the Module's symbol table of types
   TypeSymbolTable        &getTypeSymbolTable()        { return *TypeSymTab; }
-  /// Get the symbol table of named metadata
-  const MDSymbolTable  &getMDSymbolTable() const      { return *NamedMDSymTab; }
-  /// Get the Module's symbol table of named metadata
-  MDSymbolTable        &getMDSymbolTable()            { return *NamedMDSymTab; }
 
 /// @}
 /// @name Global Variable Iteration