Create only one AnalysisManager for each translation unit. In HandleCode(),

reset the current analysis context of the AnalysisManager.

llvm-svn: 77943
This commit is contained in:
Zhongxing Xu 2009-08-03 03:13:46 +00:00
parent 854d34a9fb
commit bcbe44fa90
2 changed files with 15 additions and 14 deletions

View File

@ -76,6 +76,10 @@ public:
CurrentContext = 0;
}
void setContext(Decl *D) {
CurrentContext = ContextMgr.getContext(D);
}
Decl *getCodeDecl() const {
assert (AScope == ScopeDecl);
return CurrentContext->getDecl();

View File

@ -88,6 +88,8 @@ namespace {
StoreManagerCreator CreateStoreMgr;
ConstraintManagerCreator CreateConstraintMgr;
llvm::OwningPtr<AnalysisManager> Mgr;
AnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
PreprocessorFactory* ppf,
const LangOptions& lopts,
@ -152,6 +154,12 @@ namespace {
virtual void Initialize(ASTContext &Context) {
Ctx = &Context;
Mgr.reset(new AnalysisManager(*Ctx, Diags, LOpts, PD.get(),
CreateStoreMgr, CreateConstraintMgr,
Opts.AnalyzerDisplayProgress,
Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
Opts.PurgeDead, Opts.EagerlyAssume,
Opts.TrimGraph));
}
virtual void HandleTopLevelDecl(DeclGroupRef D) {
@ -215,14 +223,9 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
if(!TranslationUnitActions.empty()) {
AnalysisManager mgr(*Ctx, Diags, LOpts, PD.get(),
CreateStoreMgr, CreateConstraintMgr,
Opts.AnalyzerDisplayProgress, Opts.VisualizeEGDot,
Opts.VisualizeEGUbi, Opts.PurgeDead, Opts.EagerlyAssume,
Opts.TrimGraph);
for (Actions::iterator I = TranslationUnitActions.begin(),
E = TranslationUnitActions.end(); I != E; ++I)
(*I)(mgr);
(*I)(*Mgr);
}
if (!ObjCImplementationActions.empty()) {
@ -253,17 +256,11 @@ void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) {
!Ctx->getSourceManager().isFromMainFile(D->getLocation()))
return;
// Create an AnalysisManager that will manage the state for analyzing
// this method/function.
AnalysisManager mgr(D, *Ctx, Diags, LOpts, PD.get(),
CreateStoreMgr, CreateConstraintMgr,
Opts.AnalyzerDisplayProgress, Opts.VisualizeEGDot,
Opts.VisualizeEGUbi, Opts.PurgeDead, Opts.EagerlyAssume,
Opts.TrimGraph);
Mgr->setContext(D);
// Dispatch on the actions.
for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I)
(*I)(mgr);
(*I)(*Mgr);
}
//===----------------------------------------------------------------------===//