From bedd1b2427b7bdc7de5280e26b36fb4256891e60 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 2 Jul 2008 05:26:32 +0000 Subject: [PATCH] Add a new (simple) StringMap::clear method, patch by Pratik Solanki! llvm-svn: 53008 --- llvm/include/llvm/ADT/StringMap.h | 6 ++++++ llvm/lib/CodeGen/CollectorMetadata.cpp | 5 +---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/ADT/StringMap.h b/llvm/include/llvm/ADT/StringMap.h index f180b3636060..7189931abb9f 100644 --- a/llvm/include/llvm/ADT/StringMap.h +++ b/llvm/include/llvm/ADT/StringMap.h @@ -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. diff --git a/llvm/lib/CodeGen/CollectorMetadata.cpp b/llvm/lib/CodeGen/CollectorMetadata.cpp index 7a5a699a117f..5b8c7c799961 100644 --- a/llvm/lib/CodeGen/CollectorMetadata.cpp +++ b/llvm/lib/CodeGen/CollectorMetadata.cpp @@ -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;