Browse Source

Use llvm::DeleteContainerSeconds when possible

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201739 91177308-0d34-0410-b5e6-96231b3b80d8
Reid Kleckner 11 years ago
parent
commit
26b55ea31d

+ 1 - 5
lib/AST/ASTContext.cpp

@@ -783,11 +783,7 @@ ASTContext::~ASTContext() {
        A != AEnd; ++A)
        A != AEnd; ++A)
     A->second->~AttrVec();
     A->second->~AttrVec();
 
 
-  for (llvm::DenseMap<const DeclContext *, MangleNumberingContext *>::iterator
-           I = MangleNumberingContexts.begin(),
-           E = MangleNumberingContexts.end();
-       I != E; ++I)
-    delete I->second;
+  llvm::DeleteContainerSeconds(MangleNumberingContexts);
 }
 }
 
 
 void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) {
 void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) {

+ 3 - 7
lib/Analysis/AnalysisDeclContext.cpp

@@ -81,9 +81,7 @@ AnalysisDeclContextManager::AnalysisDeclContextManager(bool useUnoptimizedCFG,
 }
 }
 
 
 void AnalysisDeclContextManager::clear() {
 void AnalysisDeclContextManager::clear() {
-  for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I)
-    delete I->second;
-  Contexts.clear();
+  llvm::DeleteContainerSeconds(Contexts);
 }
 }
 
 
 static BodyFarm &getBodyFarm(ASTContext &C) {
 static BodyFarm &getBodyFarm(ASTContext &C) {
@@ -557,15 +555,13 @@ AnalysisDeclContext::~AnalysisDeclContext() {
   // Release the managed analyses.
   // Release the managed analyses.
   if (ManagedAnalyses) {
   if (ManagedAnalyses) {
     ManagedAnalysisMap *M = (ManagedAnalysisMap*) ManagedAnalyses;
     ManagedAnalysisMap *M = (ManagedAnalysisMap*) ManagedAnalyses;
-    for (ManagedAnalysisMap::iterator I = M->begin(), E = M->end(); I!=E; ++I)
-      delete I->second;  
+    llvm::DeleteContainerSeconds(*M);
     delete M;
     delete M;
   }
   }
 }
 }
 
 
 AnalysisDeclContextManager::~AnalysisDeclContextManager() {
 AnalysisDeclContextManager::~AnalysisDeclContextManager() {
-  for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I)
-    delete I->second;
+  llvm::DeleteContainerSeconds(Contexts);
 }
 }
 
 
 LocationContext::~LocationContext() {}
 LocationContext::~LocationContext() {}

+ 1 - 6
lib/Analysis/CallGraph.cpp

@@ -106,12 +106,7 @@ CallGraph::CallGraph() {
 }
 }
 
 
 CallGraph::~CallGraph() {
 CallGraph::~CallGraph() {
-  if (!FunctionMap.empty()) {
-    for (FunctionMapTy::iterator I = FunctionMap.begin(), E = FunctionMap.end();
-        I != E; ++I)
-      delete I->second;
-    FunctionMap.clear();
-  }
+  llvm::DeleteContainerSeconds(FunctionMap);
 }
 }
 
 
 bool CallGraph::includeInGraph(const Decl *D) {
 bool CallGraph::includeInGraph(const Decl *D) {

+ 1 - 4
lib/Basic/SourceManager.cpp

@@ -404,10 +404,7 @@ SourceManager::~SourceManager() {
   delete FakeBufferForRecovery;
   delete FakeBufferForRecovery;
   delete FakeContentCacheForRecovery;
   delete FakeContentCacheForRecovery;
 
 
-  for (llvm::DenseMap<FileID, MacroArgsMap *>::iterator
-         I = MacroArgsCacheMap.begin(),E = MacroArgsCacheMap.end(); I!=E; ++I) {
-    delete I->second;
-  }
+  llvm::DeleteContainerSeconds(MacroArgsCacheMap);
 }
 }
 
 
 void SourceManager::clearIDTables() {
 void SourceManager::clearIDTables() {

+ 1 - 4
lib/CodeGen/CodeGenTypes.cpp

@@ -38,10 +38,7 @@ CodeGenTypes::CodeGenTypes(CodeGenModule &cgm)
 }
 }
 
 
 CodeGenTypes::~CodeGenTypes() {
 CodeGenTypes::~CodeGenTypes() {
-  for (llvm::DenseMap<const Type *, CGRecordLayout *>::iterator
-         I = CGRecordLayouts.begin(), E = CGRecordLayouts.end();
-      I != E; ++I)
-    delete I->second;
+  llvm::DeleteContainerSeconds(CGRecordLayouts);
 
 
   for (llvm::FoldingSet<CGFunctionInfo>::iterator
   for (llvm::FoldingSet<CGFunctionInfo>::iterator
        I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )
        I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; )

+ 1 - 4
lib/Driver/Driver.cpp

@@ -77,10 +77,7 @@ Driver::Driver(StringRef ClangExecutable,
 Driver::~Driver() {
 Driver::~Driver() {
   delete Opts;
   delete Opts;
 
 
-  for (llvm::StringMap<ToolChain *>::iterator I = ToolChains.begin(),
-                                              E = ToolChains.end();
-       I != E; ++I)
-    delete I->second;
+  llvm::DeleteContainerSeconds(ToolChains);
 }
 }
 
 
 void Driver::ParseDriverMode(ArrayRef<const char *> Args) {
 void Driver::ParseDriverMode(ArrayRef<const char *> Args) {

+ 1 - 4
lib/Frontend/ASTUnit.cpp

@@ -191,10 +191,7 @@ struct ASTUnit::ASTWriterData {
 };
 };
 
 
 void ASTUnit::clearFileLevelDecls() {
 void ASTUnit::clearFileLevelDecls() {
-  for (FileDeclsTy::iterator
-         I = FileDecls.begin(), E = FileDecls.end(); I != E; ++I)
-    delete I->second;
-  FileDecls.clear();
+  llvm::DeleteContainerSeconds(FileDecls);
 }
 }
 
 
 void ASTUnit::CleanTemporaryFiles() {
 void ASTUnit::CleanTemporaryFiles() {

+ 1 - 3
lib/Lex/Pragma.cpp

@@ -48,9 +48,7 @@ void EmptyPragmaHandler::HandlePragma(Preprocessor &PP,
 //===----------------------------------------------------------------------===//
 //===----------------------------------------------------------------------===//
 
 
 PragmaNamespace::~PragmaNamespace() {
 PragmaNamespace::~PragmaNamespace() {
-  for (llvm::StringMap<PragmaHandler*>::iterator
-         I = Handlers.begin(), E = Handlers.end(); I != E; ++I)
-    delete I->second;
+  llvm::DeleteContainerSeconds(Handlers);
 }
 }
 
 
 /// FindHandler - Check to see if there is already a handler for the
 /// FindHandler - Check to see if there is already a handler for the

+ 1 - 4
lib/Sema/Sema.cpp

@@ -208,10 +208,7 @@ void Sema::Initialize() {
 }
 }
 
 
 Sema::~Sema() {
 Sema::~Sema() {
-  for (LateParsedTemplateMapT::iterator I = LateParsedTemplateMap.begin(),
-                                        E = LateParsedTemplateMap.end();
-       I != E; ++I)
-    delete I->second;
+  llvm::DeleteContainerSeconds(LateParsedTemplateMap);
   if (PackContext) FreePackedContext();
   if (PackContext) FreePackedContext();
   if (VisContext) FreeVisContext();
   if (VisContext) FreeVisContext();
   // Kill all the active scopes.
   // Kill all the active scopes.

+ 1 - 3
lib/Serialization/ASTWriter.cpp

@@ -3799,9 +3799,7 @@ ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream)
 }
 }
 
 
 ASTWriter::~ASTWriter() {
 ASTWriter::~ASTWriter() {
-  for (FileDeclIDsTy::iterator
-         I = FileDeclIDs.begin(), E = FileDeclIDs.end(); I != E; ++I)
-    delete I->second;
+  llvm::DeleteContainerSeconds(FileDeclIDs);
 }
 }
 
 
 void ASTWriter::WriteAST(Sema &SemaRef,
 void ASTWriter::WriteAST(Sema &SemaRef,

+ 1 - 3
lib/StaticAnalyzer/Core/BugReporter.cpp

@@ -2802,9 +2802,7 @@ void BugReporter::FlushReports() {
   // EmitBasicReport.
   // EmitBasicReport.
   // FIXME: There are leaks from checkers that assume that the BugTypes they
   // FIXME: There are leaks from checkers that assume that the BugTypes they
   // create will be destroyed by the BugReporter.
   // create will be destroyed by the BugReporter.
-  for (llvm::StringMap<BugType*>::iterator
-         I = StrBugTypes.begin(), E = StrBugTypes.end(); I != E; ++I)
-    delete I->second;
+  llvm::DeleteContainerSeconds(StrBugTypes);
 
 
   // Remove all references to the BugType objects.
   // Remove all references to the BugType objects.
   BugTypes = F.getEmptySet();
   BugTypes = F.getEmptySet();

+ 1 - 5
lib/StaticAnalyzer/Core/SymbolManager.cpp

@@ -326,11 +326,7 @@ QualType SymbolRegionValue::getType() const {
 }
 }
 
 
 SymbolManager::~SymbolManager() {
 SymbolManager::~SymbolManager() {
-  for (SymbolDependTy::const_iterator I = SymbolDependencies.begin(),
-       E = SymbolDependencies.end(); I != E; ++I) {
-    delete I->second;
-  }
-
+  llvm::DeleteContainerSeconds(SymbolDependencies);
 }
 }
 
 
 bool SymbolManager::canSymbolicate(QualType T) {
 bool SymbolManager::canSymbolicate(QualType T) {