forked from OSchip/llvm-project
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:
parent
854d34a9fb
commit
bcbe44fa90
|
@ -76,6 +76,10 @@ public:
|
||||||
CurrentContext = 0;
|
CurrentContext = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setContext(Decl *D) {
|
||||||
|
CurrentContext = ContextMgr.getContext(D);
|
||||||
|
}
|
||||||
|
|
||||||
Decl *getCodeDecl() const {
|
Decl *getCodeDecl() const {
|
||||||
assert (AScope == ScopeDecl);
|
assert (AScope == ScopeDecl);
|
||||||
return CurrentContext->getDecl();
|
return CurrentContext->getDecl();
|
||||||
|
|
|
@ -88,6 +88,8 @@ namespace {
|
||||||
StoreManagerCreator CreateStoreMgr;
|
StoreManagerCreator CreateStoreMgr;
|
||||||
ConstraintManagerCreator CreateConstraintMgr;
|
ConstraintManagerCreator CreateConstraintMgr;
|
||||||
|
|
||||||
|
llvm::OwningPtr<AnalysisManager> Mgr;
|
||||||
|
|
||||||
AnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
|
AnalysisConsumer(Diagnostic &diags, Preprocessor* pp,
|
||||||
PreprocessorFactory* ppf,
|
PreprocessorFactory* ppf,
|
||||||
const LangOptions& lopts,
|
const LangOptions& lopts,
|
||||||
|
@ -152,6 +154,12 @@ namespace {
|
||||||
|
|
||||||
virtual void Initialize(ASTContext &Context) {
|
virtual void Initialize(ASTContext &Context) {
|
||||||
Ctx = &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) {
|
virtual void HandleTopLevelDecl(DeclGroupRef D) {
|
||||||
|
@ -215,14 +223,9 @@ void AnalysisConsumer::HandleTopLevelSingleDecl(Decl *D) {
|
||||||
void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
|
void AnalysisConsumer::HandleTranslationUnit(ASTContext &C) {
|
||||||
|
|
||||||
if(!TranslationUnitActions.empty()) {
|
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(),
|
for (Actions::iterator I = TranslationUnitActions.begin(),
|
||||||
E = TranslationUnitActions.end(); I != E; ++I)
|
E = TranslationUnitActions.end(); I != E; ++I)
|
||||||
(*I)(mgr);
|
(*I)(*Mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ObjCImplementationActions.empty()) {
|
if (!ObjCImplementationActions.empty()) {
|
||||||
|
@ -253,17 +256,11 @@ void AnalysisConsumer::HandleCode(Decl* D, Stmt* Body, Actions& actions) {
|
||||||
!Ctx->getSourceManager().isFromMainFile(D->getLocation()))
|
!Ctx->getSourceManager().isFromMainFile(D->getLocation()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Create an AnalysisManager that will manage the state for analyzing
|
Mgr->setContext(D);
|
||||||
// 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);
|
|
||||||
|
|
||||||
// Dispatch on the actions.
|
// Dispatch on the actions.
|
||||||
for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I)
|
for (Actions::iterator I = actions.begin(), E = actions.end(); I != E; ++I)
|
||||||
(*I)(mgr);
|
(*I)(*Mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
Loading…
Reference in New Issue