1 //===-- AnalysisManager.cpp -------------------------------------*- 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 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
11
12 using namespace clang;
13 using namespace ento;
14
anchor()15 void AnalysisManager::anchor() { }
16
AnalysisManager(ASTContext & ctx,DiagnosticsEngine & diags,const LangOptions & lang,const PathDiagnosticConsumers & PDC,StoreManagerCreator storemgr,ConstraintManagerCreator constraintmgr,CheckerManager * checkerMgr,AnalyzerOptions & Options,CodeInjector * injector)17 AnalysisManager::AnalysisManager(ASTContext &ctx, DiagnosticsEngine &diags,
18 const LangOptions &lang,
19 const PathDiagnosticConsumers &PDC,
20 StoreManagerCreator storemgr,
21 ConstraintManagerCreator constraintmgr,
22 CheckerManager *checkerMgr,
23 AnalyzerOptions &Options,
24 CodeInjector *injector)
25 : AnaCtxMgr(Options.UnoptimizedCFG,
26 /*AddImplicitDtors=*/true,
27 /*AddInitializers=*/true,
28 Options.includeTemporaryDtorsInCFG(),
29 Options.shouldSynthesizeBodies(),
30 Options.shouldConditionalizeStaticInitializers(),
31 /*addCXXNewAllocator=*/true,
32 injector),
33 Ctx(ctx),
34 Diags(diags),
35 LangOpts(lang),
36 PathConsumers(PDC),
37 CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
38 CheckerMgr(checkerMgr),
39 options(Options) {
40 AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
41 }
42
~AnalysisManager()43 AnalysisManager::~AnalysisManager() {
44 FlushDiagnostics();
45 for (PathDiagnosticConsumers::iterator I = PathConsumers.begin(),
46 E = PathConsumers.end(); I != E; ++I) {
47 delete *I;
48 }
49 }
50
FlushDiagnostics()51 void AnalysisManager::FlushDiagnostics() {
52 PathDiagnosticConsumer::FilesMade filesMade;
53 for (PathDiagnosticConsumers::iterator I = PathConsumers.begin(),
54 E = PathConsumers.end();
55 I != E; ++I) {
56 (*I)->FlushDiagnostics(&filesMade);
57 }
58 }
59