]> granicus.if.org Git - clang/commitdiff
Create only one AnalysisManager for each translation unit. In HandleCode(),
authorZhongxing Xu <xuzhongxing@gmail.com>
Mon, 3 Aug 2009 03:13:46 +0000 (03:13 +0000)
committerZhongxing Xu <xuzhongxing@gmail.com>
Mon, 3 Aug 2009 03:13:46 +0000 (03:13 +0000)
reset the current analysis context of the AnalysisManager.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77943 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/PathSensitive/AnalysisManager.h
lib/Frontend/AnalysisConsumer.cpp

index e7371de65621c10b3fc33e23b692ef15a0119b9c..2cff088ee0dbb6e55b40e3f5f2692520dae26426 100644 (file)
@@ -75,6 +75,10 @@ public:
 
     CurrentContext = 0;
   }
+
+  void setContext(Decl *D) {
+    CurrentContext = ContextMgr.getContext(D);
+  }
     
   Decl *getCodeDecl() const { 
     assert (AScope == ScopeDecl);
index 44d79be11c1e62516ac424a39a73c0e35a9a9303..5af6c0112a621b562d8932dc17e18dd60a711f5a 100644 (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);  
 }
 
 //===----------------------------------------------------------------------===//