AnalysisManager periodically cleanup its AnalysisContextManager and LocationContextManager objects,
as they don't need to forever retain all the CFGs ever created when analyzing a file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84684
91177308-0d34-0410-b5e6-
96231b3b80d8
~AnalysisContextManager();
AnalysisContext *getContext(const Decl *D);
+
+ // Discard all previously created AnalysisContexts.
+ void clear();
};
class LocationContext : public llvm::FoldingSetNode {
llvm::FoldingSet<LocationContext> Contexts;
public:
+ ~LocationContextManager();
+
StackFrameContext *getStackFrame(AnalysisContext *ctx,
const LocationContext *parent,
const Stmt *s);
ScopeContext *getScope(AnalysisContext *ctx, const LocationContext *parent,
const Stmt *s);
+
+ /// Discard all previously created LocationContext objects.
+ void clear();
};
} // end clang namespace
AScope(ScopeDecl), DisplayedFunction(!displayProgress),
VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
EagerlyAssume(eager), TrimGraph(trim) {}
+
+ void ClearContexts() {
+ LocCtxMgr.clear();
+ AnaCtxMgr.clear();
+ }
StoreManagerCreator getStoreManagerCreator() {
return CreateStoreMgr;
delete I->second;
}
+void AnalysisContextManager::clear() {
+ for (ContextMap::iterator I = Contexts.begin(), E = Contexts.end(); I!=E; ++I)
+ delete I->second;
+ Contexts.clear();
+}
+
Stmt *AnalysisContext::getBody() {
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
return FD->getBody();
ID.AddPointer(s);
}
+LocationContextManager::~LocationContextManager() {
+ clear();
+}
+
+void LocationContextManager::clear() {
+ for (llvm::FoldingSet<LocationContext>::iterator I = Contexts.begin(),
+ E = Contexts.end(); I != E; ) {
+ LocationContext *LC = &*I;
+ ++I;
+ delete LC;
+ }
+
+ Contexts.clear();
+}
+
StackFrameContext*
LocationContextManager::getStackFrame(AnalysisContext *ctx,
const LocationContext *parent,
!Ctx->getSourceManager().isFromMainFile(D->getLocation()))
return;
+ // Clear the AnalysisManager of old AnalysisContexts.
+ Mgr->ClearContexts();
+
// Dispatch on the actions.
for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I)
(*I)(*Mgr, D);