From: Reid Kleckner Date: Wed, 19 Feb 2014 23:44:52 +0000 (+0000) Subject: Use llvm::DeleteContainerSeconds when possible X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26b55ea31d6aba5ca78fc3f5eb5ce1656630646d;p=clang Use llvm::DeleteContainerSeconds when possible git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@201739 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 6af79cd538..a1f2e1f4ab 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::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 5a9b10775a..baac6c18fa 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 33870158b3..24705e534b 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 ab113c1894..bc31189d1f 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -404,10 +404,7 @@ SourceManager::~SourceManager() { delete FakeBufferForRecovery; delete FakeContentCacheForRecovery; - for (llvm::DenseMap::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 e84a40d74a..eb7115f6e4 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -38,10 +38,7 @@ CodeGenTypes::CodeGenTypes(CodeGenModule &cgm) } CodeGenTypes::~CodeGenTypes() { - for (llvm::DenseMap::iterator - I = CGRecordLayouts.begin(), E = CGRecordLayouts.end(); - I != E; ++I) - delete I->second; + llvm::DeleteContainerSeconds(CGRecordLayouts); for (llvm::FoldingSet::iterator I = FunctionInfos.begin(), E = FunctionInfos.end(); I != E; ) diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index dd650ae833..e2ff568ff3 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::iterator I = ToolChains.begin(), - E = ToolChains.end(); - I != E; ++I) - delete I->second; + llvm::DeleteContainerSeconds(ToolChains); } void Driver::ParseDriverMode(ArrayRef Args) { diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index d617b36806..8d46a8f4a5 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 1a7f6a5f48..2e7fb293cb 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::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 416388c294..600da90d2c 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 18d83cfe6a..11b57407c2 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 eedf05685c..f2c2ab1ae2 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::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 1b56f82dc6..a04cb4161e 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) {