diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 6af79cd5383e9a8cb967de61aa22f100c0376640..a1f2e1f4ab63d3a943540cccf7335457524eea4f 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -783,11 +783,7 @@ ASTContext::~ASTContext() { A != AEnd; ++A) 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) { diff --git a/lib/Analysis/AnalysisDeclContext.cpp b/lib/Analysis/AnalysisDeclContext.cpp index 5a9b10775af1894c62abfc49a460bbeebcbc8eb9..baac6c18fa74232bc4c82dded920723478e30135 100644 --- a/lib/Analysis/AnalysisDeclContext.cpp +++ b/lib/Analysis/AnalysisDeclContext.cpp @@ -81,9 +81,7 @@ AnalysisDeclContextManager::AnalysisDeclContextManager(bool useUnoptimizedCFG, } 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) { @@ -557,15 +555,13 @@ AnalysisDeclContext::~AnalysisDeclContext() { // Release the managed analyses. if (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; } } AnalysisDeclContextManager::~AnalysisDeclContextManager() { - for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I) - delete I->second; + llvm::DeleteContainerSeconds(Contexts); } LocationContext::~LocationContext() {} diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp index 33870158b384bb3f511bdf76b8c23621c66a7365..24705e534b59df3b08ee1ce27dfc3514cf4f6ef9 100644 --- a/lib/Analysis/CallGraph.cpp +++ b/lib/Analysis/CallGraph.cpp @@ -106,12 +106,7 @@ 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) { diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index ab113c189421ebd708e7142024568f3a61b0cbc0..bc31189d1f76df1ade18ccc69191826e6e9c8bf8 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -404,10 +404,7 @@ SourceManager::~SourceManager() { delete FakeBufferForRecovery; 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() { diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index e84a40d74ae67b3bfd73e99960609a40ebca20e4..eb7115f6e448cb723e2cd905493dcc9cb637f7e0 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -38,10 +38,7 @@ CodeGenTypes::CodeGenTypes(CodeGenModule &cgm) } 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 I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; ) diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index dd650ae83384fd755c397d93e727664f1cc5e2b3..e2ff568ff34d47bd92e4663bf7ab84b37e5b43e4 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -77,10 +77,7 @@ Driver::Driver(StringRef ClangExecutable, Driver::~Driver() { 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) { diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index d617b368065c0e8801645ef5dadbb72e6cbbd8bc..8d46a8f4a5db701644a98a3df66c004b6437fc8f 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -191,10 +191,7 @@ struct ASTUnit::ASTWriterData { }; 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() { diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp index 1a7f6a5f4835c8eff6634cba7085b6ee46884b9e..2e7fb293cb7605ef0116a90ebbc5f2887b281369 100644 --- a/lib/Lex/Pragma.cpp +++ b/lib/Lex/Pragma.cpp @@ -48,9 +48,7 @@ void EmptyPragmaHandler::HandlePragma(Preprocessor &PP, //===----------------------------------------------------------------------===// 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 diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 416388c294c0791c66169b6a966ee03b3950543f..600da90d2c79203fffbf11aabfd24a86866c9930 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -208,10 +208,7 @@ void Sema::Initialize() { } Sema::~Sema() { - for (LateParsedTemplateMapT::iterator I = LateParsedTemplateMap.begin(), - E = LateParsedTemplateMap.end(); - I != E; ++I) - delete I->second; + llvm::DeleteContainerSeconds(LateParsedTemplateMap); if (PackContext) FreePackedContext(); if (VisContext) FreeVisContext(); // Kill all the active scopes. diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 18d83cfe6aeee36a5034dbf80c075e303f296a97..11b57407c29d519cc47a585e05be18abc88e56a9 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -3799,9 +3799,7 @@ ASTWriter::ASTWriter(llvm::BitstreamWriter &Stream) } 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, diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp index eedf05685cc724ccab86b0b731ce161cac5405a1..f2c2ab1ae206a3d6ed0bc5149d4ea6d233555cc2 100644 --- a/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -2802,9 +2802,7 @@ void BugReporter::FlushReports() { // EmitBasicReport. // FIXME: There are leaks from checkers that assume that the BugTypes they // 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. BugTypes = F.getEmptySet(); diff --git a/lib/StaticAnalyzer/Core/SymbolManager.cpp b/lib/StaticAnalyzer/Core/SymbolManager.cpp index 1b56f82dc60fcea83ad6f6a8ef4d00927de9ec4e..a04cb4161e7da10c9b56725a7c673fae979d8a7a 100644 --- a/lib/StaticAnalyzer/Core/SymbolManager.cpp +++ b/lib/StaticAnalyzer/Core/SymbolManager.cpp @@ -326,11 +326,7 @@ QualType SymbolRegionValue::getType() const { } 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) {