Use llvm::DeleteContainerSeconds when possible

llvm-svn: 201739
This commit is contained in:
Reid Kleckner 2014-02-19 23:44:52 +00:00
parent 7ce956ded4
commit 588c937228
12 changed files with 14 additions and 52 deletions

View File

@ -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 llvm::DeleteContainerSeconds(MangleNumberingContexts);
I = MangleNumberingContexts.begin(),
E = MangleNumberingContexts.end();
I != E; ++I)
delete I->second;
} }
void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) { void ASTContext::AddDeallocation(void (*Callback)(void*), void *Data) {

View File

@ -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) llvm::DeleteContainerSeconds(Contexts);
delete I->second;
Contexts.clear();
} }
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) llvm::DeleteContainerSeconds(*M);
delete I->second;
delete M; delete M;
} }
} }
AnalysisDeclContextManager::~AnalysisDeclContextManager() { AnalysisDeclContextManager::~AnalysisDeclContextManager() {
for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I) llvm::DeleteContainerSeconds(Contexts);
delete I->second;
} }
LocationContext::~LocationContext() {} LocationContext::~LocationContext() {}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 llvm::DeleteContainerSeconds(StrBugTypes);
I = StrBugTypes.begin(), E = StrBugTypes.end(); I != E; ++I)
delete I->second;
// Remove all references to the BugType objects. // Remove all references to the BugType objects.
BugTypes = F.getEmptySet(); BugTypes = F.getEmptySet();

View File

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