]> granicus.if.org Git - clang/commitdiff
AnalysisManager can now be used to for analyses over TranslationUnits.
authorTed Kremenek <kremenek@apple.com>
Wed, 5 Nov 2008 19:05:06 +0000 (19:05 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 5 Nov 2008 19:05:06 +0000 (19:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58766 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/AnalysisConsumer.cpp

index 5f338c8af53dd8cd2704c998d62e5c6505dc37b4..f01a755988e890d7375dc1a6d689908fa6d1ae79 100644 (file)
@@ -112,8 +112,11 @@ namespace {
     
   
   class VISIBILITY_HIDDEN AnalysisManager : public BugReporterData {
-    Decl* D;
-    Stmt* Body;    
+    Decl* D; Stmt* Body; 
+    TranslationUnit* TU;
+    
+    enum AnalysisScope { ScopeTU, ScopeDecl } AScope;
+      
     AnalysisConsumer& C;
     bool DisplayedFunction;
     
@@ -123,11 +126,25 @@ namespace {
 
   public:
     AnalysisManager(AnalysisConsumer& c, Decl* d, Stmt* b) 
-    : D(d), Body(b), C(c), DisplayedFunction(false) {}
+    : D(d), Body(b), TU(0), AScope(ScopeDecl), C(c), DisplayedFunction(false) {}
+    
+    AnalysisManager(AnalysisConsumer& c, TranslationUnit* tu) 
+    : D(0), Body(0), TU(tu), AScope(ScopeTU), C(c), DisplayedFunction(false) {}    
     
+    Decl* getCodeDecl() const { 
+      assert (AScope == ScopeDecl);
+      return D;
+    }
+    
+    Stmt* getBody() const {
+      assert (AScope == ScopeDecl);
+      return Body;
+    }
     
-    Decl* getCodeDecl() const { return D; }
-    Stmt* getBody() const { return Body; }
+    TranslationUnit* getTranslationUnit() const {
+      assert (AScope == ScopeTU);
+      return TU;
+    }    
     
     GRStateManager::StoreManagerCreator getStoreManagerCreator() {
       switch (C.SM) {