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
24namespace clang {
25
26namespace ento {
27  class CheckerManager;
28
29class 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
44public:
45  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                  AnalyzerOptions &Options);
54
55  ~AnalysisManager();
56
57  void ClearContexts() {
58    AnaCtxMgr.clear();
59  }
60
61  AnalysisDeclContextManager& getAnalysisDeclContextManager() {
62    return AnaCtxMgr;
63  }
64
65  StoreManagerCreator getStoreManagerCreator() {
66    return CreateStoreMgr;
67  }
68
69  AnalyzerOptions& getAnalyzerOptions() override {
70    return options;
71  }
72
73  ConstraintManagerCreator getConstraintManagerCreator() {
74    return CreateConstraintMgr;
75  }
76
77  CheckerManager *getCheckerManager() const { return CheckerMgr; }
78
79  ASTContext &getASTContext() override {
80    return Ctx;
81  }
82
83  SourceManager &getSourceManager() override {
84    return getASTContext().getSourceManager();
85  }
86
87  DiagnosticsEngine &getDiagnostic() override {
88    return Diags;
89  }
90
91  const LangOptions &getLangOpts() const {
92    return LangOpts;
93  }
94
95  ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() override {
96    return PathConsumers;
97  }
98
99  void FlushDiagnostics();
100
101  bool shouldVisualize() const {
102    return options.visualizeExplodedGraphWithGraphViz ||
103           options.visualizeExplodedGraphWithUbiGraph;
104  }
105
106  bool shouldInlineCall() const {
107    return options.getIPAMode() != IPAK_None;
108  }
109
110  CFG *getCFG(Decl const *D) {
111    return AnaCtxMgr.getContext(D)->getCFG();
112  }
113
114  template <typename T>
115  T *getAnalysis(Decl const *D) {
116    return AnaCtxMgr.getContext(D)->getAnalysis<T>();
117  }
118
119  ParentMap &getParentMap(Decl const *D) {
120    return AnaCtxMgr.getContext(D)->getParentMap();
121  }
122
123  AnalysisDeclContext *getAnalysisDeclContext(const Decl *D) {
124    return AnaCtxMgr.getContext(D);
125  }
126};
127
128} // enAnaCtxMgrspace
129
130} // end clang namespace
131
132#endif
133