]> granicus.if.org Git - clang/commitdiff
Modules: Clean up ModuleFile::Imports in ModuleManager::removeModules
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 28 Jan 2017 23:12:13 +0000 (23:12 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Sat, 28 Jan 2017 23:12:13 +0000 (23:12 +0000)
I don't have a testcase for this (and I'm not sure if it's an observable
bug), but it seems obviously wrong that ModuleManager::removeModules is
failing to clean up deleted modules from ModuleFile::Imports.  See the
code in ModuleManager::addModule that inserts into ModuleFile::Imports;
we need the inverse operation.

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

lib/Serialization/ModuleManager.cpp

index 358dd0ec7f42b61fa62ad049f27a54e7329a50c0..609eedf88151f1ff34e44f035cae086e5da3fa52 100644 (file)
@@ -204,10 +204,10 @@ void ModuleManager::removeModules(
     return victimSet.count(MF);
   };
   // Remove any references to the now-destroyed modules.
-  //
-  // FIXME: this should probably clean up Imports as well.
-  for (auto I = begin(); I != First; ++I)
+  for (auto I = begin(); I != First; ++I) {
+    I->Imports.remove_if(IsVictim);
     I->ImportedBy.remove_if(IsVictim);
+  }
   Roots.erase(std::remove_if(Roots.begin(), Roots.end(), IsVictim),
               Roots.end());