]> granicus.if.org Git - clang/commitdiff
Actually free memory for the module maps
authorDouglas Gregor <dgregor@apple.com>
Thu, 17 Nov 2011 02:05:44 +0000 (02:05 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 17 Nov 2011 02:05:44 +0000 (02:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@144880 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/ModuleMap.h
lib/Lex/ModuleMap.cpp

index e9bf1b35c141f9fe6b324dbd62d6d8591a391258..b1eaebddb20a9cbd664abcbc6f87ae856046bed9 100644 (file)
@@ -73,7 +73,9 @@ public:
       : Name(Name), DefinitionLoc(DefinitionLoc), Parent(Parent), 
         UmbrellaHeader(0), IsExplicit(IsExplicit) {
     }
-           
+     
+    ~Module();
+    
     /// \brief Determine whether this module is a submodule.
     bool isSubModule() const { return Parent != 0; }
     
index 0c51659cab88194062cb757ab49429f737481911..393118110aff09e6c08e96b29a50ab8f007f7204 100644 (file)
@@ -31,6 +31,15 @@ using namespace clang;
 // Module
 //----------------------------------------------------------------------------//
 
+ModuleMap::Module::~Module() {
+  for (llvm::StringMap<Module *>::iterator I = SubModules.begin(), 
+                                        IEnd = SubModules.end();
+       I != IEnd; ++I) {
+    delete I->getValue();
+  }
+
+}
+
 std::string ModuleMap::Module::getFullModuleName() const {
   llvm::SmallVector<StringRef, 2> Names;
   
@@ -72,6 +81,12 @@ ModuleMap::ModuleMap(FileManager &FileMgr, const DiagnosticConsumer &DC) {
 }
 
 ModuleMap::~ModuleMap() {
+  for (llvm::StringMap<Module *>::iterator I = Modules.begin(), 
+                                        IEnd = Modules.end();
+       I != IEnd; ++I) {
+    delete I->getValue();
+  }
+  
   delete SourceMgr;
 }