11541Srgrimes//== AnalysisManager.h - Path sensitive analysis data manager ------*- C++ -*-// 21541Srgrimes// 31541Srgrimes// The LLVM Compiler Infrastructure 41541Srgrimes// 551138Salfred// This file is distributed under the University of Illinois Open Source 659288Sjlemon// License. See LICENSE.TXT for details. 71541Srgrimes// 81541Srgrimes//===----------------------------------------------------------------------===// 91541Srgrimes// 101541Srgrimes// This file defines the AnalysisManager class that manages the data and policy 111541Srgrimes// for path sensitive analysis. 121541Srgrimes// 131541Srgrimes//===----------------------------------------------------------------------===// 141541Srgrimes 151541Srgrimes#ifndef LLVM_CLANG_GR_ANALYSISMANAGER_H 161541Srgrimes#define LLVM_CLANG_GR_ANALYSISMANAGER_H 171541Srgrimes 181541Srgrimes#include "clang/Analysis/AnalysisContext.h" 191541Srgrimes#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h" 201541Srgrimes#include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h" 211541Srgrimes#include "clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h" 221541Srgrimes#include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h" 231541Srgrimes 241541Srgrimesnamespace clang { 251541Srgrimes 261541Srgrimesnamespace ento { 271541Srgrimes class CheckerManager; 281541Srgrimes 291541Srgrimesclass AnalysisManager : public BugReporterData { 301541Srgrimes virtual void anchor(); 311541Srgrimes AnalysisDeclContextManager AnaCtxMgr; 321541Srgrimes 331541Srgrimes ASTContext &Ctx; 341541Srgrimes DiagnosticsEngine &Diags; 351541Srgrimes const LangOptions &LangOpts; 361541Srgrimes PathDiagnosticConsumers PathConsumers; 371541Srgrimes 381541Srgrimes // Configurable components creators. 391541Srgrimes StoreManagerCreator CreateStoreMgr; 401541Srgrimes ConstraintManagerCreator CreateConstraintMgr; 411541Srgrimes 421541Srgrimes CheckerManager *CheckerMgr; 431541Srgrimes 441541Srgrimespublic: 451541Srgrimes AnalyzerOptions &options; 461541Srgrimes 471541Srgrimes AnalysisManager(ASTContext &ctx,DiagnosticsEngine &diags, 481541Srgrimes const LangOptions &lang, 491541Srgrimes const PathDiagnosticConsumers &Consumers, 501541Srgrimes StoreManagerCreator storemgr, 511541Srgrimes ConstraintManagerCreator constraintmgr, 521541Srgrimes CheckerManager *checkerMgr, 531541Srgrimes AnalyzerOptions &Options); 541541Srgrimes 551541Srgrimes ~AnalysisManager(); 5652150Smarcel 571541Srgrimes void ClearContexts() { 5852150Smarcel AnaCtxMgr.clear(); 591541Srgrimes } 601541Srgrimes 611541Srgrimes AnalysisDeclContextManager& getAnalysisDeclContextManager() { 6252150Smarcel return AnaCtxMgr; 631541Srgrimes } 641541Srgrimes 651541Srgrimes StoreManagerCreator getStoreManagerCreator() { 661541Srgrimes return CreateStoreMgr; 671541Srgrimes } 681541Srgrimes 691541Srgrimes AnalyzerOptions& getAnalyzerOptions() { 701541Srgrimes return options; 711541Srgrimes } 721541Srgrimes 731541Srgrimes ConstraintManagerCreator getConstraintManagerCreator() { 741541Srgrimes return CreateConstraintMgr; 751541Srgrimes } 761541Srgrimes 771541Srgrimes CheckerManager *getCheckerManager() const { return CheckerMgr; } 781541Srgrimes 791541Srgrimes virtual ASTContext &getASTContext() { 801541Srgrimes return Ctx; 811541Srgrimes } 821541Srgrimes 831541Srgrimes virtual SourceManager &getSourceManager() { 841541Srgrimes return getASTContext().getSourceManager(); 851541Srgrimes } 861541Srgrimes 871541Srgrimes virtual DiagnosticsEngine &getDiagnostic() { 881541Srgrimes return Diags; 891541Srgrimes } 901541Srgrimes 911541Srgrimes const LangOptions &getLangOpts() const { 921541Srgrimes return LangOpts; 931541Srgrimes } 941541Srgrimes 951541Srgrimes ArrayRef<PathDiagnosticConsumer*> getPathDiagnosticConsumers() { 961541Srgrimes return PathConsumers; 971541Srgrimes } 981541Srgrimes 991541Srgrimes void FlushDiagnostics(); 1001541Srgrimes 1011541Srgrimes bool shouldVisualize() const { 1021541Srgrimes return options.visualizeExplodedGraphWithGraphViz || 1031541Srgrimes options.visualizeExplodedGraphWithUbiGraph; 1041541Srgrimes } 1051541Srgrimes 1061541Srgrimes bool shouldInlineCall() const { 1071541Srgrimes return options.getIPAMode() != IPAK_None; 1081541Srgrimes } 1091541Srgrimes 1101541Srgrimes CFG *getCFG(Decl const *D) { 1111541Srgrimes return AnaCtxMgr.getContext(D)->getCFG(); 1121541Srgrimes } 11352150Smarcel 1141541Srgrimes template <typename T> 1151541Srgrimes T *getAnalysis(Decl const *D) { 1161541Srgrimes return AnaCtxMgr.getContext(D)->getAnalysis<T>(); 1171541Srgrimes } 1181541Srgrimes 1191541Srgrimes ParentMap &getParentMap(Decl const *D) { 1201541Srgrimes return AnaCtxMgr.getContext(D)->getParentMap(); 12152150Smarcel } 1221541Srgrimes 1231541Srgrimes AnalysisDeclContext *getAnalysisDeclContext(const Decl *D) { 1241541Srgrimes return AnaCtxMgr.getContext(D); 1251541Srgrimes } 1261541Srgrimes}; 1271541Srgrimes 1281541Srgrimes} // enAnaCtxMgrspace 12914220Speter 1301541Srgrimes} // end clang namespace 1311541Srgrimes 1321541Srgrimes#endif 1331541Srgrimes