Add a new (simple) StringMap::clear method, patch by Pratik
authorChris Lattner <sabre@nondot.org>
Wed, 2 Jul 2008 05:26:32 +0000 (05:26 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 2 Jul 2008 05:26:32 +0000 (05:26 +0000)
Solanki!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53008 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/StringMap.h
lib/CodeGen/CollectorMetadata.cpp

index f180b363606067734c5bd6cf31611646521f234d..7189931abb9fb6c8a2a44bcaa91599e714817b7b 100644 (file)
@@ -333,6 +333,12 @@ public:
     return true;
   }
 
+  // clear - Empties out the StringMap
+  void clear() {
+    while (!empty())
+      erase(begin());
+  }
+
   /// GetOrCreateValue - Look up the specified key in the table.  If a value
   /// exists, return it.  Otherwise, default construct a value, insert it, and
   /// return.
index 7a5a699a117fbf840dd3cde246b49a788dbb3768..5b8c7c7999616363a70888e9d782cf2aa07dad13 100644 (file)
@@ -112,10 +112,7 @@ CollectorMetadata &CollectorModuleMetadata::get(const Function &F) {
 
 void CollectorModuleMetadata::clear() {
   Map.clear();
-  
-  // TODO: StringMap should provide a clear method.
-  while (!NameMap.empty())
-    NameMap.erase(NameMap.begin());
+  NameMap.clear();
   
   for (iterator I = begin(), E = end(); I != E; ++I)
     delete *I;