• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //== AnalysisManager.h - Path sensitive analysis data manager ------*- C++ -*-//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the AnalysisManager class that manages the data and policy
11 // for path sensitive analysis.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CLANG_GR_ANALYSISMANAGER_H
16 #define LLVM_CLANG_GR_ANALYSISMANAGER_H
17 
18 #include "clang/Analysis/AnalysisContext.h"
19 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
20 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
21 #include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h"
22 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
23 
24 namespace clang {
25 
26 namespace ento {
27   class CheckerManager;
28 
29 class AnalysisManager : public BugReporterData {
30   virtual void anchor();
31   AnalysisDeclContextManager AnaCtxMgr;
32 
33   ASTContext &Ctx;
34   DiagnosticsEngine &Diags;
35   const LangOptions &LangOpts;
36   PathDiagnosticConsumers PathConsumers;
37 
38   // Configurable components creators.
39   StoreManagerCreator CreateStoreMgr;
40   ConstraintManagerCreator CreateConstraintMgr;
41 
42   CheckerManager *CheckerMgr;
43 
44 public:
45   const AnalyzerOptions &options;
46 
47   AnalysisManager(ASTContext &ctx,DiagnosticsEngine &diags,
48                   const LangOptions &lang,
49                   const PathDiagnosticConsumers &Consumers,
50                   StoreManagerCreator storemgr,
51                   ConstraintManagerCreator constraintmgr,
52                   CheckerManager *checkerMgr,
53                   const AnalyzerOptions &Options);
54 
55   ~AnalysisManager();
56 
ClearContexts()57   void ClearContexts() {
58     AnaCtxMgr.clear();
59   }
60 
getAnalysisDeclContextManager()61   AnalysisDeclContextManager& getAnalysisDeclContextManager() {
62     return AnaCtxMgr;
63   }
64 
getStoreManagerCreator()65   StoreManagerCreator getStoreManagerCreator() {
66     return CreateStoreMgr;
67   }
68 
getConstraintManagerCreator()69   ConstraintManagerCreator getConstraintManagerCreator() {
70     return CreateConstraintMgr;
71   }
72 
getCheckerManager()73   CheckerManager *getCheckerManager() const { return CheckerMgr; }
74 
getASTContext()75   virtual ASTContext &getASTContext() {
76     return Ctx;
77   }
78 
getSourceManager()79   virtual SourceManager &getSourceManager() {
80     return getASTContext().getSourceManager();
81   }
82 
getDiagnostic()83   virtual DiagnosticsEngine &getDiagnostic() {
84     return Diags;
85   }
86 
getLangOpts()87   const LangOptions &getLangOpts() const {
88     return LangOpts;
89   }
90 
getPathDiagnosticConsumers()91   ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers()  {
92     return PathConsumers;
93   }
94 
95   void FlushDiagnostics();
96 
shouldVisualize()97   bool shouldVisualize() const {
98     return options.visualizeExplodedGraphWithGraphViz ||
99            options.visualizeExplodedGraphWithUbiGraph;
100   }
101 
shouldInlineCall()102   bool shouldInlineCall() const {
103     return options.IPAMode != None;
104   }
105 
getCFG(Decl const * D)106   CFG *getCFG(Decl const *D) {
107     return AnaCtxMgr.getContext(D)->getCFG();
108   }
109 
110   template <typename T>
getAnalysis(Decl const * D)111   T *getAnalysis(Decl const *D) {
112     return AnaCtxMgr.getContext(D)->getAnalysis<T>();
113   }
114 
getParentMap(Decl const * D)115   ParentMap &getParentMap(Decl const *D) {
116     return AnaCtxMgr.getContext(D)->getParentMap();
117   }
118 
getAnalysisDeclContext(const Decl * D)119   AnalysisDeclContext *getAnalysisDeclContext(const Decl *D) {
120     return AnaCtxMgr.getContext(D);
121   }
122 };
123 
124 } // enAnaCtxMgrspace
125 
126 } // end clang namespace
127 
128 #endif
129